Repository navigation
Commit b6483d9
[Impeller] Deduplicate GLES render pass state (flutter#193427)
Deduplicates redundant OpenGL ES state transitions across draw commands
within `RenderPassGLES` (`EncodeCommandsInReactor`):
1. **Per-Pass Orthogonal GLES State Tracking (`RenderPassStateCache`)**:
- Encapsulates pass-scoped GL state tracking inside
`RenderPassStateCache` (`BlendStateCache`, `StencilFaceStateCache`,
`StencilStateCache`, and `DepthStateCache` in an anonymous namespace in
`render_pass_gles.cc`), tracking enabled/disabled state (`GL_BLEND`,
`GL_STENCIL_TEST`, `GL_DEPTH_TEST`, `GL_SCISSOR_TEST`), active program
handle (`std::optional<HandleGLES>` via `HandleGLES::Equal{}` so
pipeline variants sharing a compiled `UniqueHandleGLES` skip redundant
program binds and `_impeller_y_flip` uniform updates), color mask, blend
equations/factors, depth compare function and write mask, front/back
stencil functions/operations/write masks, viewport, scissor rect, cull
mode, and winding order across draw calls within
`EncodeCommandsInReactor`.
- `ResetGLState` initializes the tracked state once at pass entry before
`glClear`, eliminating the redundant pass-exit `ResetGLState` call while
ensuring no state leaks across passes, `ReactorGLES` handle operations,
or `BlitPassGLES` commands.
### WebGL 2.0 Call Count & CPU Command-Encoding Reduction (Web Impeller
/ WIMP)
| Workload (`1280x720`, `wimp_st`) | Metric | Before | After | Delta |
| :--- | :--- | :---: | :---: | :---: |
| **`bouncy` (`128` nodes, `441` draws)** | Total WebGL2 calls / frame |
`13,234` | `7,983` | **`-39.7%` (`-5,251` calls)** |
| | `glBlendEquationSeparate` + `glBlendFuncSeparate` / frame | `802` |
`4` | **`-99.5%`** |
| | `glStencilFuncSeparate` + `Op` + `Mask` / frame | `1,327` | `9` |
**`-99.3%`** |
| | `glColorMask` / frame | `443` | `3` | **`-99.3%`** |
| | `glEnable` + `glDisable` / frame | `1,506` | `225` | **`-85.1%`** |
| | `glDepthFunc` + `glDepthMask` / frame | `884` | `161` | **`-81.8%`**
|
| | `glUseProgram` / frame | `441` | `105` | **`-76.2%`** |
| | `glUniform1fv` (`_impeller_y_flip`) / frame | `441` | `105` |
**`-76.2%`** |
| | `glScissor` / frame | `175` | `117` | **`-33.1%`** |
| | CPU command-encoding raster time (`--disable-gl-drawing-for-tests`)
| `13.41 ms` | `12.47 ms` | **`-7.0%` (`-0.94 ms`, `1.08x` faster)** |
| **`grid` (`1000` nodes, `5,908` draws)** | Total WebGL2 calls / frame
| `154,521` | `94,517` | **`-38.8%` (`-60,004` calls)** |
| | `glBlendEquationSeparate` + `glBlendFuncSeparate` / frame | `9,474`
| `338` | **`-96.4%`** |
| | `glStencilFuncSeparate` + `Op` + `Mask` / frame | `17,726` | `844` |
**`-95.2%`** |
| | `glColorMask` / frame | `5,909` | `337` | **`-94.3%`** |
| | `glEnable` + `glDisable` / frame | `18,071` | `2,691` | **`-85.1%`**
|
| | `glUseProgram` / frame | `5,908` | `2,197` | **`-62.8%`** |
| | `glUniform1fv` (`_impeller_y_flip`) / frame | `5,908` | `2,197` |
**`-62.8%`** |
| | `glDepthFunc` + `glDepthMask` / frame | `11,817` | `6,051` |
**`-48.8%`** |
| | CPU command-encoding raster time (`--disable-gl-drawing-for-tests`)
| `60.86 ms` | `56.13 ms` | **`-7.8%` (`-4.73 ms`, `1.08x` faster)** |
Fixes flutter#192147
## 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.
<!-- 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.md1 parent e6224a4 commit b6483d9
4 files changed
Lines changed: 703 additions & 172 deletions
File tree
- engine/src/flutter/impeller/renderer/backend/gles
- test
0 commit comments