|
| 1 | +--- |
| 2 | +title: OpenGL ES render-to-texture content is stored top-down |
| 3 | +description: >- |
| 4 | + Impeller's OpenGL ES backend now stores render-to-texture content |
| 5 | + top-down, matching Metal and Vulkan, which can affect Flutter GPU |
| 6 | + apps that compensated for the previous bottom-up orientation. |
| 7 | +--- |
| 8 | + |
| 9 | +{% render "docs/breaking-changes.md" %} |
| 10 | + |
| 11 | +## Summary |
| 12 | + |
| 13 | +Impeller's OpenGL ES backend now stores render-to-texture content |
| 14 | +top-down, the same as the Metal and Vulkan backends. |
| 15 | +A Flutter GPU app that sampled a render-target texture on OpenGL ES and |
| 16 | +added a vertical flip to compensate for the old bottom-up orientation |
| 17 | +now renders that content upside down. |
| 18 | + |
| 19 | +## Background |
| 20 | + |
| 21 | +The OpenGL ES backend previously stored render-to-texture content |
| 22 | +bottom-up, unlike the Metal and Vulkan backends. |
| 23 | +The renderer carried that orientation difference through every texture |
| 24 | +sample as a per-sampler Y-coordinate scale. |
| 25 | +Impeller now absorbs the difference once, at the vertex stage, so |
| 26 | +render-target textures are stored top-down on every backend. |
| 27 | + |
| 28 | +This change is invisible to the framework and to Flutter's 2D rendering. |
| 29 | +The only surface where application code could observe the old |
| 30 | +orientation is Flutter GPU, the experimental `flutter_gpu` package, |
| 31 | +where an app drives render passes and samples render-target textures |
| 32 | +directly. |
| 33 | + |
| 34 | +## Migration guide |
| 35 | + |
| 36 | +If a Flutter GPU shader flipped the Y coordinate when sampling a |
| 37 | +render-target texture solely to make OpenGL ES match the other backends, |
| 38 | +remove that flip. |
| 39 | +Render-target textures are now top-down on every backend. |
| 40 | + |
| 41 | +Code before migration: |
| 42 | + |
| 43 | +```glsl |
| 44 | +// The flip only compensated for OpenGL ES's bottom-up render targets. |
| 45 | +uv.y = 1.0 - uv.y; |
| 46 | +frag_color = texture(u_texture, uv); |
| 47 | +``` |
| 48 | + |
| 49 | +Code after migration: |
| 50 | + |
| 51 | +```glsl |
| 52 | +frag_color = texture(u_texture, uv); |
| 53 | +``` |
| 54 | + |
| 55 | +## Timeline |
| 56 | + |
| 57 | +Landed in version: not yet released<br> |
| 58 | +In stable release: Not yet |
| 59 | + |
| 60 | +## References |
| 61 | + |
| 62 | +GitHub issue: |
| 63 | + |
| 64 | +* [Issue 186554][] |
| 65 | + |
| 66 | +Relevant PR: |
| 67 | + |
| 68 | +* [PR 186556][] |
| 69 | + |
| 70 | +[Issue 186554]: {{site.repo.flutter}}/issues/186554 |
| 71 | +[PR 186556]: {{site.repo.flutter}}/pull/186556 |
0 commit comments