-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Use varying interpolation to compute some linear gradients. #53166
[Impeller] Use varying interpolation to compute some linear gradients. #53166
Conversation
|
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. |
|
Golden file changes are available for triage from new commit, Click here to view. |
|
Checked on wonderous - this hits almost all gradient usage, except for the shimmer icons which have a transform. |
chinmaygarde
left a comment
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.
Well worth the extra pipeline.
| in vec2 position; | ||
| in vec4 color; | ||
|
|
||
| out vec4 v_color; |
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.
Maybe add a comment here saying, "We exploit the simplicity of this gradient and make the varying unit perform the interpolation instead of performing the calculations ourselves."
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.
Done
| VertexBufferBuilder<VS::PerVertexData> vtx_builder; | ||
| vtx_builder.Reserve(6 * (stops_.size() - 1)); | ||
| Point prev = start_point_; | ||
| for (auto i = 1u; i < stops_.size(); i++) { |
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.
Beautiful.
| // the gradient is divided into regions based on the stop values. | ||
| // Currently restricted to rect geometry where the start and end points are | ||
| // perfectly horizontal/vertical, but could easily be expanded to StC cases | ||
| // provided that the start/end are on our outside the coverage rect. |
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.
Typo towards the end of the sentence?
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.
Fixed
| Geometry& geometry = *GetGeometry(); | ||
|
|
||
| // We already know this is an axis aligned rectangle, so the coverage will | ||
| // be approximately the same as the geometry. For non AARs, we can force |
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.
Just say "axis aligned rectangles" instead of AARs?
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.
Done
|
|
||
| // We already know this is an axis aligned rectangle, so the coverage will | ||
| // be approximately the same as the geometry. For non AARs, we can force | ||
| // stencil then cover (not done here). We give an identity transform to |
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.
A TODO with a followup for non-AARs?
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.
Done (below)
|
|
||
| namespace impeller { | ||
|
|
||
| using GradientPipeline = |
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.
FastGradientPipeline instead?
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.
Done
|
|
||
| void main() { | ||
| frag_color = IPPremultiply(v_color) * frag_info.alpha; | ||
| // mod operator is not supported in GLES 2.0 |
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.
Whats with this comment? Also, even though the operator is not supported, you can use the function.
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.
This shader would fail to load on GLES because the ordered dither uses a bunch of bit manipulation logic?
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.
Oh. Gotcha. That method has a mod in there somewhere.
We should be able to fix it using the mod() function though. It's just the operator that's bad in ES.
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.
Nothing to do in this patch. Was just curious.
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.
ahh TIL!
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.
what an odd restriction
…149658) flutter/engine@a6aa5d8...e211c43 2024-06-04 [email protected] Roll Fuchsia Linux SDK from lKBLxel8iBaHpT5q6... to pagJoGS4kQ8Efa_if... (flutter/engine#53192) 2024-06-04 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[display_list] allow applying opacity peephole to single glyph. (#53160)" (flutter/engine#53189) 2024-06-04 [email protected] Roll Dart SDK from 49b5590c8d80 to 9dce57c343ec (1 revision) (flutter/engine#53187) 2024-06-04 [email protected] [Impeller] Use varying interpolation to compute some linear gradients. (flutter/engine#53166) 2024-06-03 [email protected] [Impeller] match rrect_blur math to the gaussian math (flutter/engine#53130) 2024-06-03 [email protected] [web] Add Ethiopic font fallback. (flutter/engine#53180) 2024-06-03 [email protected] Fix rendering corruption by Flutter and GDK sharing the same OpenGL context (flutter/engine#53103) 2024-06-03 [email protected] [display_list] allow applying opacity peephole to single glyph. (flutter/engine#53160) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from lKBLxel8iBaH to pagJoGS4kQ8E 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
Create a fast gradient variant that assumes vertex interpolation is sufficient to compute the gradient color. This follows the approximate design from flutter/flutter#148651
This is only implemented for draws that are exactly horizontal or vertical gradients on a rectangle with an identity effect transform. This could be easily extended to all horizontal or vertical gradients by extending the drawGeometry call to make the cover rect customizable. Handling diagonal gradients and effect transforms is more work but feasible.
this is sufficient to make flutter/flutter#148496 about 2x as fast, at least for me. Applications with different gradients will not yet benefit.