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

[Impeller] Don't draw the backdrop into itself when the pass has no offscreen MSAA - #193178

Closed
krll-kov wants to merge 7 commits into
flutter:masterfrom
krll-kov:impeller-backdrop-no-msaa-2
Closed

krll-kov wants to merge 7 commits into
flutter:masterfrom
krll-kov:impeller-backdrop-no-msaa-2

Conversation

@krll-kov

@krll-kov krll-kov commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #192918

When a device has no offscreen MSAA, the pass target has no resolve texture, so every pass after the first one loads and writes the same texture the backdrop is read from. FlipBackdrop then draws that texture into itself. D3D11 cannot bind it as a shader resource and a render target at the same time, so ANGLE unbinds the shader resource and the draw samples zeros. Everything drawn before the first BackdropFilter or advanced blend disappears from the frame.

Change

That draw is only needed when the pass writes to a different texture than the one the backdrop is read from, so it is skipped when they are the same texture.

Gemini's proposal in issue used a new DidLoadPreviousContents() flag for this. I compare the color attachment with input_texture instead. The flag says that the pass loaded its previous contents, not which texture it writes to. Those are the same thing only while the pass target is never swapped, and the grouped BackdropFilter case, which is described in same issue, swaps it to a second texture. With the flag alone the draw would then be skipped although it is needed, and the backdrop would be missing from the frame, silently in profile and release builds. The DCHECK keeps the invariant: a pass that writes into the backdrop texture must have loaded it.

Testing

BackdropFlipWithoutOffscreenMSAASkipsSelfDraw mocks a device with no offscreen MSAA and no framebuffer fetch, records an advanced blend and checks that the pass holds no MSAA backdrop draw. It runs on the GLES backend, because that is the backend that keeps the recorded commands. I tried Metal first, but it encodes the commands right away and keeps no list. For that the GLES playground needed the capability override that Metal already has, so this PR implements ContextGLES::SetCapabilities and PlaygroundImplGLES::SetCapabilities, which returned kUnimplemented before.

On a Radeon 890M new test fails on both GLES parameters without the fix, with one MSAA backdrop draw recorded, and passes with it.

I also ran 15 scenes with BackdropFilter, BackdropGroup and advanced blends on Windows at feature level 10_0. Without the fix 14 of them differ from the reference frame by 2.2 to 3.5 million pixels. With the fix 11 match the reference exactly. Two more differ only in antialiasing, since the reference has MSAA and feature level 10_0 does not. The last two are grouped BackdropFilters with different filters, which this change renders the way Skia does, not as normally working impeller when offscreen MSAA is available.

Pre-launch Checklist

@gaaclarke
gaaclarke self-requested a review September 22, 2026 20:47
@gaaclarke gaaclarke added the CICD Run CI/CD label Sep 22, 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 Sep 22, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 22, 2026
@krll-kov

krll-kov commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@gaaclarke can you add cicd again? i fixed test problem that appeared only in release builds, which i ran with host_debug_unopt_x64 locally before and did not notice that impeller::Command label is not available in release

@gaaclarke gaaclarke added the CICD Run CI/CD label Sep 23, 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.

The code looks good, the test is very flimsy though. I'll see if I can come up with a better alternative.

@krll-kov

Copy link
Copy Markdown
Contributor Author

The code looks good, the test is very flimsy though. I'll see if I can come up with a better alternative.

it was very difficult to make it without linux machine, and metal encoded commands without keeping the list. Test also depended on this pr #193189 that was reverted and needs adjustments

@krll-kov

Copy link
Copy Markdown
Contributor Author
Screenshot_20260924_202538_Firefox This was slightly better but it failed dashboard release tests because impeller::Command label is not available there

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 24, 2026
@gaaclarke gaaclarke added the CICD Run CI/CD label Sep 24, 2026
@gaaclarke

Copy link
Copy Markdown
Member

@krll-kov I pushed a more robust test. I think this was the easiest way to test exactly what we want. It required a lot of plumbing, but that's the sort of thing an LLM is good at hooking up.

Alternatively we could have tried to mock things at a higher level than opengles and it would have been cross-backend, but we don't have an existing example of that and it would have taken a lot of code to setup. This it's an integration test with a few other things too.

@gaaclarke

Copy link
Copy Markdown
Member

@krll-kov do you mind if I fork this PR into one that I created so it's not a "draft"? It should still attribute you as a collaborator since I'll move your commit over.

I don't have the ability to remove the "draft" status from this PR. I've complained to the people that have that power and I've been promised the process will be improved.

@krll-kov

Copy link
Copy Markdown
Contributor Author

@krll-kov do you mind if I fork this PR into one that I created so it's not a "draft"? It should still attribute you as a collaborator since I'll move your commit over.

I don't have the ability to remove the "draft" status from this PR. I've complained to the people that have that power and I've been promised the process will be improved.

It's even better since fix would land faster!

@gaaclarke

Copy link
Copy Markdown
Member

closed in lieu of #193306

@gaaclarke gaaclarke closed this Sep 24, 2026
pull Bot pushed a commit to Superoldman96/flutter that referenced this pull request Sep 26, 2026
…d framebufferfetch (flutter#193306)

My fork of flutter#193178 to avoid OP's
open PR limit.

Coauthored with @krll-kov 

Fixes flutter#192918

## 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 in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- 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/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Kyrylo K. <63228361+krll-kov@users.noreply.github.com>
DanTup pushed a commit to DanTup/flutter that referenced this pull request Sep 28, 2026
…d framebufferfetch (flutter#193306)

My fork of flutter#193178 to avoid OP's
open PR limit.

Coauthored with @krll-kov 

Fixes flutter#192918

## 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 in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- 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/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Kyrylo K. <63228361+krll-kov@users.noreply.github.com>
DanTup pushed a commit to DanTup/flutter that referenced this pull request Sep 28, 2026
…d framebufferfetch (flutter#193306)

My fork of flutter#193178 to avoid OP's
open PR limit.

Coauthored with @krll-kov 

Fixes flutter#192918

## 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 in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- 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/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Kyrylo K. <63228361+krll-kov@users.noreply.github.com>
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] [Windows] BackdropFilter erases content drawn before it when offscreen MSAA is unavailable (OpenGL ES 2.0, D3D11 feature level 10_0)

2 participants