Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

This implements part of flutter/flutter#131345


Makes all porter-duff draw atlas blending avoid subpass creation, by tweaking the existing porter duff shader to support per-vertex colors and output opacity. This requires a small trick: What the blend shaders and what (drawAtlas/drawVertices) consider the source and destination is reversed. That is a blend mode color filter treats the color as the source whereas drawVertices/drawAtlas treat their per-vertex colors as the destination. Therefore I cannot simply make all color inputs per vertex and use the exact same shaders :(

However, for the porter duff blends we should just be able to reverse the blend mode (srcover -> dstOver, xor->xor) (I'm pretty sure I did this correctly) so that the blending is still correct. I don't think we can do this for the advanced blends, but supporting those is less important than the common atlas blending parameters like dstIn.

This PR only updates drawAtlas.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

jonahwilliams added 2 commits July 26, 2023 20:39
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #44059 at sha f7fe3c3

"filename": "flutter/impeller/entity/gles/porter_duff_blend.frag.gles",
"has_side_effects": false,
"has_uniform_computation": true,
"has_uniform_computation": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

These moved to the vert.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #44059 at sha 76e8765

jonahwilliams added 2 commits July 27, 2023 09:23
@jonahwilliams jonahwilliams requested a review from bdero July 27, 2023 16:26
@chinmaygarde chinmaygarde changed the title [Impeller] make porter duff blended atlas calls faster. [Impeller] Make porter duff blended atlas calls faster. Jul 27, 2023
@jonahwilliams
Copy link
Contributor Author

Friendly ping 😄

Copy link
Contributor

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

@bdero said he would take a look yesterday but he may be preoccupied. I took a stab instead and LGTM. If he has further comments, we can handle it in a later pass. Thanks!

"filename": "flutter/impeller/entity/gles/porter_duff_blend.frag.gles",
"has_side_effects": false,
"has_uniform_computation": true,
"has_uniform_computation": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

These moved to the vert.

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

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

LGTM, but can we add a golden that uses AtlasContents?

Summary of my understanding:

In an engine sync you mentioned that the blend isn't behaving correctly, but I wasn't able to spot a potential problem.

@jonahwilliams
Copy link
Contributor Author

In an engine sync you mentioned that the blend isn't behaving correctly, but I wasn't able to spot a potential problem.

I might have mispoke, I didn't mean with this patch but at ToT. In general there is a problem with some of the blending with the current implementation. Those issues are linked in the above issue but in particular: flutter/flutter#118914

So I'm trying to move us closer to what Skia is doing without adding more shaders.

@bdero
Copy link
Member

bdero commented Aug 4, 2023

Oh! I notice that issue is from January. We discovered some tricky alpha management issues while comprehensively covering the blends with goldens & comparing with Skia -- maybe it's already fixed by #43283?

BTW, if you're planning to employ a trick like this to make the advanced blends faster in DrawAtlas and/or DrawVertices, I think that would also be a great way to resolve the mask tracking issue I was worried about. Although in the case of DrawAtlas/DrawVertices, the issue is confined to edges looking a bit discolored rather than the whole blended square getting colored in for some blend modes.

@jonahwilliams
Copy link
Contributor Author

Oh nice, that's right you fixed that. I'll need to recheck.

@chinmaygarde
Copy link
Contributor

Are we landing this?

@jonahwilliams
Copy link
Contributor Author

Waiting on benchmarks

@jonahwilliams
Copy link
Contributor Author

Benchmarks have landed, will monitor and ensure those are running and then land later this week.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 15, 2023
@auto-submit auto-submit bot merged commit bddb6ab into flutter:main Aug 15, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 15, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 15, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 16, 2023
flutter/engine@22f03ff...a9da721

2023-08-15 skia-flutter-autoroll@skia.org Roll Skia from c7c9e85a8657 to b07a6964a1cf (2 revisions) (flutter/engine#44733)
2023-08-15 jonahwilliams@google.com [Impeller] Make porter duff blended atlas calls faster. (flutter/engine#44059)
2023-08-15 skia-flutter-autoroll@skia.org Roll Skia from 4beb6fd05f4f to c7c9e85a8657 (7 revisions) (flutter/engine#44729)
2023-08-15 skia-flutter-autoroll@skia.org Roll Dart SDK from 19c87486f0a9 to b36934aae968 (1 revision) (flutter/engine#44728)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
This implements part of flutter/flutter#131345

---

Makes all porter-duff draw atlas blending avoid subpass creation, by tweaking the existing porter duff shader to support per-vertex colors and output opacity. This requires a small trick: What the blend shaders and what (drawAtlas/drawVertices) consider the source and destination is reversed. That is a blend mode color filter treats the color as the source whereas drawVertices/drawAtlas treat their per-vertex colors as the destination. Therefore I cannot simply make all color inputs per vertex and use the exact same shaders :(

However, for the porter duff blends we should just be able to reverse the blend mode (srcover -> dstOver, xor->xor) (I'm pretty sure I did this correctly) so that the blending is still correct. I don't think we can do this for the advanced blends, but supporting those is less important than the common atlas blending parameters like dstIn.

This PR only updates drawAtlas.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants