Repository navigation
Commit b3cef5e
SSBO-based gradients in UberSDF (flutter#192962)
Moves most of the logic of uber_sdf.frag to uber_sdf_common.glsl. New
uber_sdf.frag and uber_sdf_ssbo.frag shaders import uber_sdf_common.glsl
and implement `getGradientColor()` with a texture-based or SSBO-based
gradient implementation.
Gradient SSBO logic based off the existing SSBO gradient shaders like
https://github.com/flutter/flutter/blob/b138043fc75c1270e1bd9f1fa0a5c1299e86e638/engine/src/flutter/impeller/entity/shaders/gradients/linear_gradient_ssbo_fill.frag
Note that for GLES, SSBO is currently not supported.
https://github.com/flutter/flutter/blob/b138043fc75c1270e1bd9f1fa0a5c1299e86e638/engine/src/flutter/impeller/renderer/backend/gles/capabilities_gles.cc#L277-L279
This means that for Windows and Linux, which currently always have a
GLES backend, this change does not do anything.
This is a prerequisite for addressing
flutter#190401. This improves UberSDF
gradient rendering when SSBO is supported, but not on Windows. The next
step to address flutter#190401 is to
make Windows support SSBO:
flutter#193162
Tested this with the "Scrolling basic LinearGradient" benchmark app from
flutter#190401. I ran it 3 times, on
my Mac. The raster time goes down significantly, so that it is on par
with the solid color time.
## On Mac (my local dev machine, M3 MacBook Pro):
### Before:
| | Avg raster p50 |
|--|--|
| Solid | 1.250ms |
| Gradient | 2.596ms |
<details> <summary> Full results </summary>
```
Note: This says "Windows" because that's hard-coded in the benchmark app. But this was run on my Mac.
flutter: === Windows linear-gradient comparison ===
flutter: mode=profile speed=1400px/s
flutter: Solid color | frames=240 fps=59.75 | ui p50/p95=1.085/1.661ms | raster p50/p90/p95/p99/max=1.278/1.701/1.764/1.857/1.999ms | raster_over_budget=0/240 (0.0%)
flutter: Linear gradient | frames=240 fps=59.75 | ui p50/p95=1.460/2.101ms | raster p50/p90/p95/p99/max=2.639/3.182/3.325/3.727/4.102ms | raster_over_budget=0/240 (0.0%)
flutter: ================================================
flutter: === Windows linear-gradient comparison ===
flutter: mode=profile speed=1400px/s
flutter: Solid color | frames=240 fps=59.75 | ui p50/p95=0.904/1.400ms | raster p50/p90/p95/p99/max=1.232/1.635/1.752/1.918/2.125ms | raster_over_budget=0/240 (0.0%)
flutter: Linear gradient | frames=240 fps=59.75 | ui p50/p95=1.490/2.262ms | raster p50/p90/p95/p99/max=2.686/3.368/3.615/3.863/4.256ms | raster_over_budget=0/240 (0.0%)
flutter: ================================================
flutter: === Windows linear-gradient comparison ===
flutter: mode=profile speed=1400px/s
flutter: Solid color | frames=240 fps=59.75 | ui p50/p95=0.903/1.426ms | raster p50/p90/p95/p99/max=1.240/1.655/1.727/1.879/2.097ms | raster_over_budget=0/240 (0.0%)
flutter: Linear gradient | frames=240 fps=59.75 | ui p50/p95=1.176/2.259ms | raster p50/p90/p95/p99/max=2.463/3.069/3.270/3.706/3.934ms | raster_over_budget=0/240 (0.0%)
flutter: ================================================
```
</details>
### After:
| | Avg raster p50 |
|--|--|
| Solid | 1.271ms |
| Gradient | 1.286ms |
<details> <summary> Full results </summary>
```
Note: This says "Windows" because that's hard-coded in the benchmark app. But this was run on my Mac.
flutter: === Windows linear-gradient comparison ===
flutter: mode=profile speed=1400px/s
flutter: Solid color | frames=240 fps=59.75 | ui p50/p95=1.290/1.816ms | raster p50/p90/p95/p99/max=1.365/1.748/1.823/1.953/1.990ms | raster_over_budget=0/240 (0.0%)
flutter: Linear gradient | frames=240 fps=59.75 | ui p50/p95=1.523/2.281ms | raster p50/p90/p95/p99/max=1.286/1.457/1.528/1.722/1.812ms | raster_over_budget=0/240 (0.0%)
flutter: ================================================
flutter: === Windows linear-gradient comparison ===
flutter: mode=profile speed=1400px/s
flutter: Solid color | frames=240 fps=59.75 | ui p50/p95=0.957/1.108ms | raster p50/p90/p95/p99/max=1.192/1.354/1.385/1.462/1.854ms | raster_over_budget=0/240 (0.0%)
flutter: Linear gradient | frames=240 fps=59.75 | ui p50/p95=1.572/3.112ms | raster p50/p90/p95/p99/max=1.263/1.455/1.542/1.702/1.859ms | raster_over_budget=0/240 (0.0%)
flutter: ================================================
flutter: === Windows linear-gradient comparison ===
flutter: mode=profile speed=1400px/s
flutter: Solid color | frames=240 fps=59.75 | ui p50/p95=1.044/1.657ms | raster p50/p90/p95/p99/max=1.256/1.721/1.770/1.892/1.919ms | raster_over_budget=0/240 (0.0%)
flutter: Linear gradient | frames=240 fps=59.75 | ui p50/p95=1.925/3.021ms | raster p50/p90/p95/p99/max=1.308/1.536/1.589/1.722/1.905ms | raster_over_budget=0/240 (0.0%)
flutter: ================================================
```
</details>
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
---------
Co-authored-by: gaaclarke <[email protected]>1 parent 0d2859d commit b3cef5e
13 files changed
Lines changed: 753 additions & 412 deletions
File tree
- engine/src/flutter/impeller
- display_list
- entity
- contents
- shaders
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
55 | 116 | | |
56 | 117 | | |
57 | 118 | | |
| |||
65 | 126 | | |
66 | 127 | | |
67 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
68 | 135 | | |
69 | 136 | | |
70 | 137 | | |
| |||
224 | 291 | | |
225 | 292 | | |
226 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
227 | 300 | | |
228 | 301 | | |
229 | 302 | | |
| |||
333 | 406 | | |
334 | 407 | | |
335 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
336 | 421 | | |
337 | 422 | | |
338 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
341 | 347 | | |
342 | 348 | | |
343 | | - | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
| |||
638 | 639 | | |
639 | 640 | | |
640 | 641 | | |
641 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
642 | 647 | | |
643 | 648 | | |
644 | 649 | | |
| |||
1209 | 1214 | | |
1210 | 1215 | | |
1211 | 1216 | | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1212 | 1222 | | |
1213 | 1223 | | |
1214 | 1224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| |||
0 commit comments