Sitelet https://github.com/flutter/flutter/pull/189332
Skip to content

[Impeller] Validate GLES texture units against the combined limit - #189332

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
bdero:bdero/gles-combined-texture-units
Aug 6, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
bdero:bdero/gles-combined-texture-units

Conversation

@bdero

@bdero bdero commented Jul 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #189331.

The GLES backend allocates fragment stage texture units after the vertex stage's, but validated the running unit index against the per-stage maximum. On a driver reporting the minimum 16 fragment units (ANGLE on D3D11), a draw using all 16 fragment samplers plus a vertex stage texture failed validation and the render pass aborted, crashing skinned-mesh rendering in Flutter GPU apps on Windows.

Texture units are a combined resource in GL; the per-stage limits bound only how many samplers one stage references. This validates the unit index against the combined limit and the per-stage sampler count against the per-stage limit. Adds unit tests for the previously rejected case and both overflow cases.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jul 12, 2026
@bdero
bdero requested review from jason-simmons and walley892 July 12, 2026 03:43
@bdero
bdero marked this pull request as ready for review July 12, 2026 03:43

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GLES backend's texture binding logic to track per-stage texture counts separately from active indices, validating both per-stage and combined texture unit limits. It also adds corresponding unit tests and updates the GLES mock implementation. Feedback suggests removing unnecessary friend declarations in buffer_bindings_gles.h since the new tests only access public APIs, and explicitly mocking GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in the combined limit test to improve robustness.

jason-simmons
jason-simmons previously approved these changes Jul 13, 2026
walley892
walley892 previously approved these changes Jul 14, 2026
@bdero
bdero dismissed stale reviews from walley892 and jason-simmons via 9f4d1c9 July 29, 2026 01:25
@bdero
bdero force-pushed the bdero/gles-combined-texture-units branch 2 times, most recently from 9f4d1c9 to 750b7b1 Compare July 30, 2026 03:53
bdero added 4 commits August 5, 2026 17:18
BufferBindingsGLES allocates fragment stage texture units after the vertex stage's, but validated the running unit index against the per-stage maximum. On a driver reporting the GLES minimum of 16 fragment units (ANGLE on D3D11), a draw whose fragment shader uses all 16 samplers then failed validation as soon as the vertex stage sampled a texture, since the last fragment sampler lands on unit index 16. Texture units are a combined resource in GL, glActiveTexture and sampler uniform values are valid up to the combined limit, and the per-stage limits only bound how many samplers a single stage references. Validate the unit index against the combined limit and the per-stage sampler count against the per-stage limit.
@bdero
bdero force-pushed the bdero/gles-combined-texture-units branch from 750b7b1 to adadc02 Compare August 6, 2026 00:19
@bdero

bdero commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Getting around to cleaning up/rebasing my PRs. This one should be ready to go!

@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 6, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 6, 2026
Merged via the queue into flutter:master with commit e26b384 Aug 6, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] GLES rejects draws that sample a texture in the vertex stage when the fragment shader uses all 16 samplers

3 participants