Skip to content

[Impeller] Generate mipmaps with render passes on devices with broken blit generation - #190264

Draft
bdero wants to merge 5 commits into
flutter:masterfrom
bdero:bdero/adreno-render-pass-mipgen
Draft

bdero wants to merge 5 commits into
flutter:masterfrom
bdero:bdero/adreno-render-pass-mipgen

Conversation

@bdero

@bdero bdero commented Jul 30, 2026

Copy link
Copy Markdown
Member

Resolves #161283.

Adreno drivers corrupt blit-based mipmap generation, and the existing workaround clamps every Vulkan sampler to the base mip level, which disables mip sampling for all mipped textures on affected devices, including hand-uploaded chains sampled through Flutter GPU. This change generates the mip chain with render passes where the blit path is broken, then removes the sampler clamp so mip filters pass through unmodified.

The generator draws the downsample chain into scratch offscreens and stores each level into the target with same-size copies (only scaled blits corrupt on affected devices), so target textures need no additional usage flags. Dispatch sits behind a new SupportsBlitMipmapGeneration capability inside the shared AddMipmapGeneration helper; healthy devices keep blit generation and GLES keeps glGenerateMipmap. Vulkan image layouts are now tracked per subresource, which rendering into individual mip levels requires and which also fixes a latent attachment layout desync.

Supersedes #189897 and #189966.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide.
  • 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.
  • 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 30, 2026
bdero added 5 commits July 29, 2026 21:19
Replace the single whole-image layout on TextureSourceVK with a per (mip level, array layer) layout vector, and extend BarrierVK with a subresource range. Accessors default to whole-image/(0,0) so existing callers are unchanged. Groundwork for rendering into individual mip levels.
Read the attached (mip_level, slice) layout for a color attachment's initial layout, and record the render pass's implicit final layout on that subresource only, instead of the whole image. Lets a render pass target a single mip level without desyncing the layout of the others.
Texture to buffer copies gain a source mip level and texture to texture copies gain a destination mip level, threaded through every backend. Metal and Vulkan honor them; GLES rejects levels it cannot address yet.
…is broken

Adreno drivers corrupt blit-based mipmap generation, and the sampler workaround that hides it disables mip sampling entirely. This adds a SupportsBlitMipmapGeneration capability (false on affected Adreno Vulkan) and routes AddMipmapGeneration to a render-pass generator when blit generation cannot be trusted. The generator draws the downsample chain into scratch offscreens and copies each level into the target, so target textures need no extra usage flags. Decoded images, subpass targets, and canvas mipmaps all go through the shared helper; GLES keeps glGenerateMipmap.
With render-pass generation in place on devices with broken blit generation, samplers no longer need the base-level clamp. Mip filters now pass through unmodified, which also fixes sampling of hand-uploaded mip chains through Flutter GPU.
@bdero
bdero force-pushed the bdero/adreno-render-pass-mipgen branch from 2fa9077 to c853e24 Compare July 30, 2026 04:27
pull Bot pushed a commit to Dramaga11/flutter that referenced this pull request Sep 23, 2026
…cts (flutter#190186)

Fixes bdero/flutter_scene#241. Related to flutter#161283.

Adreno drivers corrupt blit-generated mip chains. The workaround for
that rewrote every Vulkan sampler to `MipFilter::kBase`, so nothing in
the process could be sampled past its base mip level. But the corruption
belongs to the texture whose levels were generated, not to the sampler,
so textures with hand-uploaded mip chains (prefiltered environment maps,
for one) lost their mip filtering for no reason. Flutter GPU is hit
hardest, since it exposes no mipmap generation at all and every mip
chain it binds was uploaded by the app.

The workaround now lives with the texture. On affected drivers a mipped
sampled texture also gets an image view covering only the base level,
and `TextureVK::GetSampledImageView` hands that view out for textures
those drivers mipped. Generated chains stay unreadable past the base
level, every other texture samples as requested, and the sampler
library, `SamplerDescriptor`, and `lib/gpu` no longer carry any of it.

A texture with `mip_count > 1` whose levels were never written is no
longer masked on these devices, which matches its behavior on every
other platform. flutter#190264 fixes the generation itself and will delete what
is left here.

## 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.
- [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/
[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
@Piinks

Piinks commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Hey @bdero! Would you like to continue working on this change? PRs marked as drafts are not typically reviewed, you can mark it ready for review when it is! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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] re-enable runtime mipmap generation on Adreno GPU.

2 participants