Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Use downsample shader for blur instead of mip levels. #53760

Merged
merged 10 commits into from
Jul 9, 2024

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Jul 8, 2024

Fixes flutter/flutter#150973

On a Pixel 7 pro, this speeds up the repeated blur macrobenchmark by 20ms (~65 -> ~45). The mip computation for backdrop filters is especially wasteful, as most of the contents are unused. RIght now, we also need to continually re-generate mips every time we do a texture flip, even if there is only a single blur. This is because the mip level is a property of the texture, which gets reused in the entity pass backdrop.

@jonahwilliams jonahwilliams marked this pull request as ready for review July 8, 2024 17:19
@jonahwilliams
Copy link
Member Author

Marking ready for review so I can see goldens.

@jonahwilliams jonahwilliams changed the title [Impeller] remove mip usage for blur downsample, cap at 1/4 [Impeller] Use downsample shader for blur instead of mip levels. Jul 8, 2024
@jonahwilliams
Copy link
Member Author

okay I think this should be good. There appear to be minor golden diffs but nothing that holds up to visual inspection.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #53760 at sha 2e8f449

renderer.MakeSubpass("Gaussian Blur Filter", pass_args.subpass_size,
command_buffer, subpass_callback);
return render_target;
if (pass_args.effective_scalar.x >= 0.5f) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ui.Images will already have full mip chains generated and TiledTextureContents::RenderToSnapshot will passthrough in some cases, I think we can still go down this path to let mip filtering take care of the downsample when the input texture has a mip chain? Otherwise I think that case will regress.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm good point! Ill make it conditional based on mip count

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #53760 at sha eff3cb0

@jonahwilliams jonahwilliams requested a review from bdero July 9, 2024 19:18
Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 9, 2024
@auto-submit auto-submit bot merged commit 04e4989 into flutter:main Jul 9, 2024
31 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 9, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 10, 2024
…151495)

flutter/engine@d3269d5...9d943eb

2024-07-09 [email protected] Avoid using a private GTest macro to skip tests. (flutter/engine#53782)
2024-07-09 [email protected] [Impeller] Use downsample shader for blur instead of mip levels. (flutter/engine#53760)
2024-07-09 [email protected] [engine] support combined UI/Platform thread for iOS/Android. (flutter/engine#53656)
2024-07-09 [email protected] [Impeller] Enable framebuffer fetch tests disabled on OpenGL ES. (flutter/engine#53766)
2024-07-09 [email protected] [Impeller] implement experimental canvas in snapshot controller. (flutter/engine#53750)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@gaaclarke
Copy link
Member

This change has created shimmer in the blur at around 70 sigma. Sorry I don't have an automated test for this yet:

before

beforeblurchange.mov

after

afterblurchange.mov

@jonahwilliams we probably want to revert this and try to reland it when we've addressed the shimmering. I'm going to try to come up with an automated test for this.

@gaaclarke
Copy link
Member

I printed out the downscale factor to pinpoint it's relation to when the shimmering happens. At 1/16th downsample it is definitely shimmering. At 1/8th it mostly looks good until you get around sigma=40, then you can start to notice some artifacts.

@gaaclarke
Copy link
Member

Here is just a comparison of the downsample pass output before and after this change. There seems to be some sort of repeated fractional scaling factor happening in both cases. We should be able to get rid of that.

before

oldjumper.mov

after

jumper.mov

@gaaclarke
Copy link
Member

I've finally reproduced the problem in the shimmer test in flutter/flutter#152195. Without this PR the average rmse is 0.6, with this change it's 28. The only thing I changed was using the boston image. It didn't reproduce with the kalimba image for some reason.

before the change

out.mp4

after the change

w-downsample-shader.mp4

@gaaclarke
Copy link
Member

Here's the comparison of the just the downsample output. We can see that the jittering isn't unique to this change. It's just that the 1/16 down-scaler is just lower quality. We should now focus our effort on just making that better instead of trying to remove the jitters (as I have been).

before

out.mp4

after

jitters.mp4

gaaclarke added a commit to gaaclarke/engine that referenced this pull request Jul 26, 2024
gaaclarke added a commit to gaaclarke/engine that referenced this pull request Jul 26, 2024
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Jul 26, 2024
…tter#53760)

Fixes flutter/flutter#150973

On a Pixel 7 pro, this speeds up the repeated blur macrobenchmark by 20ms (~65 -> ~45). The mip computation for backdrop filters is especially wasteful, as most of the contents are unused. RIght now, we also need to continually re-generate mips every time we do a texture flip, even if there is only a single blur. This is because the mip level is a property of the texture, which gets reused in the entity pass backdrop.
gaaclarke added a commit that referenced this pull request Jul 26, 2024
…ls. (#53760)" (#54148)

This is reverted since it introduces shimmering when the downsample
scalar goes to 1/16th. It was reverted instead of fixed to allow the
test that should have blocked this to land in the meantime.

reverts #53760
fixed and relanded in #54149

Part of a series of gaussian blur changes:
1) #54148
1) #54116
1) #54150
1) #54149

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Jul 26, 2024
…tter#53760)

Fixes flutter/flutter#150973

On a Pixel 7 pro, this speeds up the repeated blur macrobenchmark by 20ms (~65 -> ~45). The mip computation for backdrop filters is especially wasteful, as most of the contents are unused. RIght now, we also need to continually re-generate mips every time we do a texture flip, even if there is only a single blur. This is because the mip level is a property of the texture, which gets reused in the entity pass backdrop.
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Jul 26, 2024
…tter#53760)

Fixes flutter/flutter#150973

On a Pixel 7 pro, this speeds up the repeated blur macrobenchmark by 20ms (~65 -> ~45). The mip computation for backdrop filters is especially wasteful, as most of the contents are unused. RIght now, we also need to continually re-generate mips every time we do a texture flip, even if there is only a single blur. This is because the mip level is a property of the texture, which gets reused in the entity pass backdrop.
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Jul 30, 2024
…tter#53760)

Fixes flutter/flutter#150973

On a Pixel 7 pro, this speeds up the repeated blur macrobenchmark by 20ms (~65 -> ~45). The mip computation for backdrop filters is especially wasteful, as most of the contents are unused. RIght now, we also need to continually re-generate mips every time we do a texture flip, even if there is only a single blur. This is because the mip level is a property of the texture, which gets reused in the entity pass backdrop.
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Jul 30, 2024
…tter#53760)

Fixes flutter/flutter#150973

On a Pixel 7 pro, this speeds up the repeated blur macrobenchmark by 20ms (~65 -> ~45). The mip computation for backdrop filters is especially wasteful, as most of the contents are unused. RIght now, we also need to continually re-generate mips every time we do a texture flip, even if there is only a single blur. This is because the mip level is a property of the texture, which gets reused in the entity pass backdrop.
auto-submit bot pushed a commit that referenced this pull request Jul 30, 2024
…ls. (#54149)

relands #53760
reverted in #54148

The fix for this was found with the help of Jonah.

Part of a series of gaussian blur changes:
1) #54148
1) #54116
1) #54150
1) #54149

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Impeller] mip computation for bdf blurs is wasteful if most of the contents are thrown away.
3 participants