Skip to content

Revert "[Impeller] Allow attaching specific texture mip levels and slices"#187445

Merged
jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-187066-1780415932
Jun 2, 2026
Merged

Revert "[Impeller] Allow attaching specific texture mip levels and slices"#187445
jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-187066-1780415932

Conversation

@flutteractionsbot
Copy link
Copy Markdown
Contributor

Reverts: [Impeller] Allow attaching specific texture mip levels and slices

Initiated by: @jtmcdole

Reason for reverting: breaking several tests in post

Original PR Author: @bdero

Reviewed By: @walley892

The original PR description is provided below:

Fixes #145014 (the attachment half; uploading specific mip levels and slices already landed).

Impeller could only attach the base mip level and slice of a texture as a render target. This adds mip_level and slice to the HAL Attachment struct so a render pass can target a specific mip level, cube map face, or array layer. The render target size follows the selected mip level.

  • Metal: sets the attachment descriptor's level and slice.
  • Vulkan: creates one 2D attachment view per mip level and layer, and bypasses the framebuffer cache for non-base subresources.
  • OpenGL ES: attaches the cube face target and mip level, allocates the subresource on demand, and gates non-zero mip levels on ES 3.0 or GL_OES_fbo_render_mipmap. Rendering to cube faces works down to ES 2.0.

Tests cover attachment validation, cross-backend rendering to a slice and to a mip level, and a renderer golden that samples two mip levels.

Pre-launch Checklist

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 2, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 2, 2026
Copy link
Copy Markdown
Contributor

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

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 removes support for rendering directly into specific texture subresources (mip levels and slices/layers) across the GLES, Metal, and Vulkan backends, simplifying render target validation, framebuffer caching, and texture source management. Feedback on the changes suggests replacing a fragile index calculation based on sample count with an explicit mapping helper to prevent potential out-of-bounds access.

Comment on lines 61 to 69
void TextureSourceVK::SetCachedFrameData(const FramebufferAndRenderPass& data,
SampleCount sample_count,
uint32_t mip_level,
uint32_t slice) {
for (auto& entry : frame_data_) {
if (entry.sample_count == sample_count && entry.mip_level == mip_level &&
entry.slice == slice) {
entry.data = data;
return;
}
}
frame_data_.push_back({sample_count, mip_level, slice, data});
SampleCount sample_count) {
frame_data_[static_cast<int>(sample_count) / 4] = data;
}

FramebufferAndRenderPass TextureSourceVK::GetCachedFrameData(
SampleCount sample_count,
uint32_t mip_level,
uint32_t slice) const {
for (const auto& entry : frame_data_) {
if (entry.sample_count == sample_count && entry.mip_level == mip_level &&
entry.slice == slice) {
return entry.data;
}
}
return {};
const FramebufferAndRenderPass& TextureSourceVK::GetCachedFrameData(
SampleCount sample_count) const {
return frame_data_[static_cast<int>(sample_count) / 4];
}
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.

medium

Using static_cast<int>(sample_count) / 4 to index into frame_data_ is fragile because it relies on implicit enum values (where kCount1 is 1 and kCount4 is 4) and magic math. If SampleCount is ever extended (e.g., to support other MSAA levels like 2x or 8x), this division will produce incorrect indices or lead to out-of-bounds array access.

Instead, use an explicit switch statement or a helper function to map SampleCount to the array index. This makes the code safer, self-documenting, and allows the compiler to warn us if a new SampleCount value is added but not handled.

static size_t SampleCountToIndex(SampleCount sample_count) {
  switch (sample_count) {
    case SampleCount::kCount1:
      return 0;
    case SampleCount::kCount4:
      return 1;
  }
  FML_UNREACHABLE();
}

void TextureSourceVK::SetCachedFrameData(const FramebufferAndRenderPass& data,
                                         SampleCount sample_count) {
  frame_data_[SampleCountToIndex(sample_count)] = data;
}

const FramebufferAndRenderPass& TextureSourceVK::GetCachedFrameData(
    SampleCount sample_count) const {
  return frame_data_[SampleCountToIndex(sample_count)];
}

@jtmcdole jtmcdole added the emergency Jump the queue; land PR in front of all others; only use for emergencies label Jun 2, 2026
@flutter-dashboard
Copy link
Copy Markdown

Detected the emergency label.

If you add the autosubmit label, the bot will wait until all presubmits pass but ignore the tree status, allowing fixes for tree breakages while still validating that they don't break any existing presubmits.

The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue".

@jtmcdole
Copy link
Copy Markdown
Member

jtmcdole commented Jun 2, 2026

fuchsia tests look like another problem (failure to setup)

@jtmcdole jtmcdole added this pull request to the merge queue Jun 2, 2026
Merged via the queue into flutter:master with commit 22c17bf Jun 2, 2026
204 of 206 checks passed
@bdero
Copy link
Copy Markdown
Member

bdero commented Jun 2, 2026

The new test I landed was broken because it's not excluding a new GLES-backed playground target that lended on master in-between the last time the tests ran successfully and the PR landed. Straightforward reland is here: #187470

pull Bot pushed a commit to g-star1024/flutter that referenced this pull request Jun 3, 2026
…ices (flutter#187470)

Relands flutter#187066, reverted in flutter#187445.

The original PR passed every pre-submit check and merged cleanly, but
broke post-submit on Mac and Linux because a concurrent change (flutter#187246,
`b4e5291940c` "add sdf golden variants for OpenGL") added a
`kOpenGLESSDF` variant to `PlaygroundBackend` that was not present when
this PR's CI last ran. `CanRenderToMipLevel` only skipped `kOpenGLES`,
so on the post-submit master it ran on `kOpenGLESSDF` and aborted with
SIGABRT because the GLES test backend does not support rendering into
non-zero mip levels. This reland is identical to flutter#187066 plus the
missing `kOpenGLESSDF` skip in `CanRenderToMipLevel`, matching the skip
pattern that every other GLES-skipping test in `renderer_unittests.cc`
already uses after flutter#187246.

Failing test seen post-submit (Mac mac_unopt build 12910, Linux
linux_unopt build 18302):
`Play/RendererTest.CanRenderToMipLevel/OpenGLESSDF` returned/aborted
with exit code -6.

---

Fixes flutter#145014 (the attachment half; uploading specific
mip levels and slices already landed).

Impeller could only attach the base mip level and slice of a texture as
a render target. This adds `mip_level` and `slice` to the HAL
`Attachment` struct so a render pass can target a specific mip level,
cube map face, or array layer. The render target size follows the
selected mip level.

- Metal: sets the attachment descriptor's level and slice.
- Vulkan: creates one 2D attachment view per mip level and layer, and
the framebuffer cache is keyed on `(sample_count, mip_level, slice)` so
non-base subresources reuse cached framebuffers.
- OpenGL ES: attaches the cube face target and mip level, allocates the
subresource on demand, and gates non-zero mip levels on ES 3.0 or
`GL_OES_fbo_render_mipmap`. Rendering to cube faces works down to ES
2.0.

Tests cover attachment validation and cross-backend rendering to a slice
and to a mip level.

## 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 documentation (doc comments with `///`).
- [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.
- [ ] 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/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 3, 2026
…11832)

Manual roll requested by tarrinneal@google.com

flutter/flutter@701665b...2ba5420

2026-06-03 engine-flutter-autoroll@skia.org Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511)
2026-06-03 mdebbar@google.com Add new file patterns for team-web labeler (flutter/flutter#187397)
2026-06-03 engine-flutter-autoroll@skia.org Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483)
2026-06-03 chris@bracken.jp [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502)
2026-06-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478)
2026-06-03 bkonyi@google.com [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953)
2026-06-03 flar@google.com [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460)
2026-06-02 burak.karahan@mail.ru Remove Material imports from painting tests (flutter/flutter#186937)
2026-06-02 awolff@google.com Add android_hardware_smoke_test integration tests (flutter/flutter#187130)
2026-06-02 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187471)
2026-06-02 pq@users.noreply.github.com [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780)
2026-06-02 30870216+gaaclarke@users.noreply.github.com Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316)
2026-06-02 116356835+AbdeMohlbi@users.noreply.github.com Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631)
2026-06-02 1961493+harryterkelsen@users.noreply.github.com refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331)
2026-06-02 engine-flutter-autoroll@skia.org Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441)
2026-06-02 faheemabbas766@gmail.com Allow selecting multi-digit device options (flutter/flutter#186184)
2026-06-02 puneetkukreja98@gmail.com Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571)
2026-06-02 sanaullah.383@hotmail.com Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807)
2026-06-02 bkonyi@google.com [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369)
2026-06-02 mvincentong@gmail.com Clean up avoid_type_to_string suppressions (flutter/flutter#186869)
2026-06-02 202459002+Lukes-Lair@users.noreply.github.com Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354)
2026-06-02 154381524+flutteractionsbot@users.noreply.github.com Revert "[Impeller] Allow attaching specific texture mip levels and slices" (flutter/flutter#187445)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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 emergency Jump the queue; land PR in front of all others; only use for emergencies engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] HAL: Allow attaching and uploading specific Texture mip levels & slices.

3 participants