-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Use 32 bit Gaussian function in the 2-pass blur #42069
Conversation
37e0f32
to
d717881
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
We could also compute the integral on the CPU and expose via SSBO if performance is a problem. I suspect it will be fine though, texture read/write is the bottleneck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this turns out to be a regression for all sigmas, could we instead have two shaders, one for small sigmas, and one for large sigmas?
Or maybe only support up to some max sigma?
I think at that point we'd be better off computing the integral on the CPU. |
d717881
to
2c7c60b
Compare
The rub is that we still need the Gaussian function to weight the color, and so if we used a LUT for the integral we'd be exchanging only a few additions per cache miss (32 additions, since I think modern iPhones have 128 byte cache lines), which would likely work out to a net loss. Precomputing the Gaussian function itself would probably work out to be a benefit if we're careful about cache management:
|
2c7c60b
to
7c64188
Compare
7c64188
to
f642511
Compare
…126968) flutter/engine@1c775e3...87a03e1 2023-05-16 [email protected] [Impeller] Use 32 bit Gaussian function in the 2-pass blur (flutter/engine#42069) 2023-05-16 [email protected] Roll Skia from 9b0e912a1cb9 to 88d7a68694d9 (13 revisions) (flutter/engine#42081) 2023-05-16 [email protected] Use client ICU data with skwasm. (flutter/engine#42018) 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] 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
From Triage: This is patched and we are waiting on framework benchmarks to determine viability for cherry-picking. |
No relevant benchmark regressions showed up during the roll containing this change. Also, no malioc record adjustments. Texture fetches get reordered to start as soon as possible and happen in parallel, and so this is probably free because we have plenty of cycles to spare waiting for the texture sample within the scope of the loop. |
@bdero Since there were no perf regressions and the patch seems low-risk, could you file a CP request for this? cc @chinmaygarde |
…2069) Resolves flutter/flutter#126487. Increases the 2-pass blur quality and distribution limit. It turns out sigma was breaking down beyond ~255 (moderately high, but not unreasonable for users to rely on). The Gaussian function computes sigma^2, and half precision floats only have 5 bit exponents and overflow for numbers above 65k. Coincidentally, this also returns us to a state where we look a lot more like Skia's blurs for larger blur sigmas. Medium blurs have much less visual banding (although it's still there if you look closely). I suspect half precision isn't really enough for tracking the integral. Unfortunately, this means our SIMD pipelining isn't going to be as good. I'll be interested in watching the blur-driven benchmarks for the perf hit. (cherry picked from commit 87a03e1)
…2069) Resolves flutter/flutter#126487. Increases the 2-pass blur quality and distribution limit. It turns out sigma was breaking down beyond ~255 (moderately high, but not unreasonable for users to rely on). The Gaussian function computes sigma^2, and half precision floats only have 5 bit exponents and overflow for numbers above 65k. Coincidentally, this also returns us to a state where we look a lot more like Skia's blurs for larger blur sigmas. Medium blurs have much less visual banding (although it's still there if you look closely). I suspect half precision isn't really enough for tracking the integral. Unfortunately, this means our SIMD pipelining isn't going to be as good. I'll be interested in watching the blur-driven benchmarks for the perf hit. (cherry picked from commit 87a03e1)
…lutter#126968) flutter/engine@1c775e3...87a03e1 2023-05-16 [email protected] [Impeller] Use 32 bit Gaussian function in the 2-pass blur (flutter/engine#42069) 2023-05-16 [email protected] Roll Skia from 9b0e912a1cb9 to 88d7a68694d9 (13 revisions) (flutter/engine#42081) 2023-05-16 [email protected] Use client ICU data with skwasm. (flutter/engine#42018) 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] 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
It seems like after the fix the values you set to sigmaX/Y are doubled inside now. To match the result optically with my template in Figma I need to halve the desired value. Is there a new bug now? |
@kuemme01 Could you file a new issue? It's a bit difficult for the team to triage comments on closed PRs. |
Resolves flutter/flutter#126487.
Increases the 2-pass blur quality and distribution limit.
It turns out sigma was breaking down beyond ~255 (moderately high, but not unreasonable for users to rely on). The Gaussian function computes sigma^2, and half precision floats only have 5 bit exponents and overflow for numbers above 65k.
Coincidentally, this also returns us to a state where we look a lot more like Skia's blurs for larger blur sigmas. Medium blurs have much less visual banding (although it's still there if you look closely). I suspect half precision isn't really enough for tracking the integral.
Unfortunately, this means our SIMD pipelining isn't going to be as good. I'll be interested in watching the blur-driven benchmarks for the perf hit.
Before Impeller:
After Impeller:
Skia: