Skip to content

[Impeller] Report manual mip sampling as unsupported on Adreno Vulkan - #189897

Closed
bdero wants to merge 3 commits into
flutter:masterfrom
bdero:bdero/adreno-manual-mips-capability
Closed

bdero wants to merge 3 commits into
flutter:masterfrom
bdero:bdero/adreno-manual-mips-capability

Conversation

@bdero

@bdero bdero commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

On Adreno GPUs the mipmap workaround rewrites every sampler to MipFilter::kBase, so nothing can sample past the base mip level, but CapabilitiesVK::SupportsManuallyMippedTextures still returned an unconditional true. Clients that check the capability and upload their own mip chains sample only the base level, with no way to detect it. Flutter GPU exposes the capability as doesSupportManuallyMippedTextures; prefiltered environment maps that store one roughness band per mip level render every band fully sharp on these devices, reported downstream in bdero/flutter_scene#241.

This change records the workaround in CapabilitiesVK::ApplyWorkarounds and reports manually mipped textures as unsupported while it is active, so capability checks fall back the same way they do on backends that lack the feature. The capability docs are updated to match, and a new unit test verifies the capability is off for Adreno devices and on for Mali.

Pre-launch Checklist

The Adreno mipmap workaround rewrites every sampler to base-mip-only,
but SupportsManuallyMippedTextures still returned true, so clients that
upload their own mip chains sample only the base level with no way to
detect it. Record the workaround in CapabilitiesVK::ApplyWorkarounds and
report the capability truthfully.
@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 23, 2026
@github-project-automation github-project-automation Bot moved this to 🤔 Needs Triage in Flutter GPU Jul 23, 2026
@bdero
bdero marked this pull request as ready for review July 23, 2026 03:46

@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 Impeller's Vulkan backend to disable support for manually mipped textures on devices where the mipmap generation workaround is active (such as Adreno GPUs), and adds corresponding unit tests and documentation. Feedback on the changes highlights a potential buffer overflow or memory read issue in the test helper where std::string_view::copy is used without ensuring proper null-termination of the destination buffer.

@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, just a couple style notes

}

bool CanSampleManuallyWrittenMips(std::string_view driver_name,
bool qc = true) {

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.

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 0c811ed.

TEST(DriverInfoVKTest, ManuallyMippedTexturesDisabledWithMipWorkaround) {
// The mipmap workaround rewrites every sampler to base-mip-only, so the
// capability must not advertise hand-written mip chains on these devices.
EXPECT_FALSE(CanSampleManuallyWrittenMips("Adreno (TM) 540", true));

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.

Suggested change
EXPECT_FALSE(CanSampleManuallyWrittenMips("Adreno (TM) 540", true));
EXPECT_FALSE(CanSampleManuallyWrittenMips("Adreno (TM) 540", /*is_qualcom=*/true));

Please add labels to these literal arguments.

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 0c811ed.

Rename the qc parameter to is_qualcomm and label the literal arguments at the call sites in the manually-mipped capability test.
@bdero
bdero requested a review from gaaclarke July 29, 2026 01:59
@bdero

bdero commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

I don't think this is the right workaround. It's just pushing a preexisting hack along. The actual bug is that automatic mip generation doesn't work on some devices, and we worked around it in Impeller by silently rewriting all samplers to kBase, which is just wrong behavior. We should implement an alternative rendering path for MIPS on these affected devices (#190264) and/or stop propagating the hack to flutter_gpu's samplers, since flutter_gpu intentionally doesn't even support automatic mip generation (#190186).

@bdero bdero closed this Aug 1, 2026
@github-project-automation github-project-automation Bot moved this from 🤔 Needs Triage to ✅ Done in Flutter GPU Aug 1, 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. flutter-gpu team-fluttergpu Owned by Flutter GPU team

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants