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

[Flutter GPU] Add 2D texture array support - #190036

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
bdero:bdero/flutter-gpu-texture-2d-array
Sep 24, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
bdero:bdero/flutter-gpu-texture-2d-array

Conversation

@bdero

@bdero bdero commented Jul 26, 2026

Copy link
Copy Markdown
Member

Related to #188776.

Adds 2D array texture support to Flutter GPU. TextureType.texture2DArray with a layerCount argument on GpuContext.createTexture creates the texture, Texture.overwrite and ColorAttachment.slice address each layer as a slice, and GpuContext.doesSupportTextureArrays reports availability. On the engine side, Capabilities::SupportsTextureArrays reports backend support, BlitPass::AddCopy validates slices against the texture type rather than a fixed cubemap bound, and the GLES backend gains buffer-to-array-layer blits. The capability reports false on GLES for now because shader bundles cannot carry an ES 3.0 shader variant yet, so user shaders there cannot sample arrays.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • 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 flutter-gpu team-fluttergpu Owned by Flutter GPU team labels Jul 26, 2026
@github-project-automation github-project-automation Bot moved this to 🤔 Needs Triage in Flutter GPU Jul 26, 2026
@bdero bdero added the CICD Run CI/CD label Jul 26, 2026
@bdero
bdero marked this pull request as ready for review July 26, 2026 04: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 adds support for 2D array textures (TextureType::kTexture2DArray) to the Impeller GLES backend and exposes it to the Flutter GPU Dart API, enabling multi-layer texture allocation, uploading, and sampling. Feedback recommends explicitly casting variables to GLint and GLsizei in OpenGL calls to prevent narrowing conversion warnings, and replacing assert statements with standard expect assertions in Dart tests to ensure they execute across all build modes.

Comment thread engine/src/flutter/testing/dart/gpu_test.dart
@gaaclarke

Copy link
Copy Markdown
Member

@bdero how about this one too, ready to review?

@bdero

bdero commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

ready to go now!

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks good, testing looks good, design looks good. I just have a few notes.

Comment on lines +186 to +188
VALIDATION_LOG
<< "2D array textures are not supported on this context.";
return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like the sort of thing we should surface up to Dart. Can we add some TODO and file a follow up issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved directly instead of deferring: GpuContext.createTexture now throws when a texture2DArray is requested but doesSupportTextureArrays is false, so callers get a clear error at creation rather than a failed upload. It reads the cached capability at creation time only, nothing on the draw path. This engine check stays as a backstop. No follow-up issue needed. (8cfb9ef)

desc.size = {width, height};
desc.format = flutter::gpu::ToImpellerPixelFormat(format);
desc.mip_count = static_cast<size_t>(mip_level_count);
desc.array_layer_count = static_cast<uint16_t>(layer_count);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fml_dcheck( layer_count <= uint16_max)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in a2fd5fa.

Comment thread engine/src/flutter/prebuilts Outdated
@@ -0,0 +1 @@
/Users/bdero/projects/flutter/flutter/engine/src/flutter/prebuilts No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

checked in on accident?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, that was an accidental checkin of a local build symlink (the repo .gitignore only matches the prebuilts/ directory, not a symlink, so git add -A caught it). Removed. (d41651d)

@bdero
bdero force-pushed the bdero/flutter-gpu-texture-2d-array branch from b7870c1 to a2fd5fa Compare August 6, 2026 00:22
@bdero bdero added CICD Run CI/CD and removed CICD Run CI/CD labels Aug 6, 2026
@gaaclarke
gaaclarke self-requested a review August 17, 2026 18:19
gaaclarke
gaaclarke previously approved these changes Aug 17, 2026

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm when passes ci

@flutter-dashboard

Copy link
Copy Markdown

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@bdero
bdero force-pushed the bdero/flutter-gpu-texture-2d-array branch from 209fb5a to b03257e Compare September 21, 2026 12:40
@bdero bdero added CICD Run CI/CD and removed CICD Run CI/CD labels Sep 21, 2026
@bdero
bdero force-pushed the bdero/flutter-gpu-texture-2d-array branch from b03257e to 78566dc Compare September 21, 2026 13:51
@bdero bdero added CICD Run CI/CD and removed CICD Run CI/CD labels Sep 21, 2026
@bdero bdero added the CICD Run CI/CD label Sep 23, 2026
@bdero
bdero requested a review from gaaclarke September 23, 2026 17:53

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@bdero bdero added CICD Run CI/CD and removed CICD Run CI/CD labels Sep 23, 2026
TextureType.texture2DArray plus a layerCount argument on
GpuContext.createTexture create the texture, Texture.overwrite and
ColorAttachment.slice address each layer as a slice, and
GpuContext.doesSupportTextureArrays reports availability.

Capabilities::SupportsTextureArrays reports backend support,
BlitPass::AddCopy validates slices against the texture type rather
than a fixed cubemap bound, and the GLES backend gains
buffer-to-array-layer blits. The capability reports false on GLES for
now because shader bundles cannot carry an ES 3.0 shader variant yet,
so user shaders there cannot sample arrays.
GpuContext.createTexture now throws when a texture2DArray is requested
but doesSupportTextureArrays is false, so callers get a clear error at
creation instead of a failed upload later. The check reads a cached
capability and runs only at creation, not on any draw path.
@bdero
bdero force-pushed the bdero/flutter-gpu-texture-2d-array branch from d488a58 to 916b679 Compare September 23, 2026 19:20
@bdero bdero added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App and removed CICD Run CI/CD labels Sep 23, 2026
@bdero

bdero commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

At the time of writing, Google testing has been stuck for 5 hours. 🤔

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. flutter-gpu team-fluttergpu Owned by Flutter GPU team

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants