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

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Apr 12, 2023

The pipeline blend component of flutter/flutter#124025 . This should also land alongside flutter/flutter#124640 which was necessary before we had completely optimized the image filters for texture inputs.

Fixes flutter/flutter#121650
Fixes flutter/flutter#124025

@jonahwilliams jonahwilliams marked this pull request as ready for review April 12, 2023 00:47
@jonahwilliams jonahwilliams changed the title [Impeller] add a generic pipeline blend foreground shader. [Impeller] add a generic porterduff blend foreground shader. Apr 14, 2023
@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 jonahwilliams changed the title [Impeller] add a generic porterduff blend foreground shader. [Impeller] add a generic porter duff blend foreground shader. Apr 14, 2023
frag_color = IPBlendPlus(frag_info.color, dst_color);
} else {
frag_color = IPBlendModulate(frag_info.color, dst_color);
}
Copy link
Member

Choose a reason for hiding this comment

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

Rather than enumerating these on the GPU, most of these can be parameterized with 4 coefficients:

frag_color =
    src * (frag_info.src_coeff + dst.a * frag_info.src_coeff_dst_alpha) +
    dst * (frag_info.dst_coeff + src.a * frag_info.dst_coeff_src_alpha);

And then the coefficients can be pulled from a LUT on the CPU without enumeration or hashing:

{src_coeff, src_coeff_dst_alpha, dst_coeff, dst_coeff_src_alpha}

{0,  0,  0,  0}, // Clear
{1,  0,  0,  0}, // Source
{0,  0,  1,  0}, // Destination
{1,  0,  1, -1}, // SourceOver
{1, -1,  1,  0}, // DestinationOver
{0,  1,  0,  0}, // SourceIn
{0,  0,  0,  1}, // DestinationIn
{1, -1,  0,  0}, // SourceOut
{0,  0,  1, -1}, // DestinationOut
{0,  1,  1, -1}, // SourceATop
{1, -1,  0,  1}, // DestinationATop
{1, -1,  1, -1}, // Xor
{1,  0,  1,  0}, // Plus

I think we can also cover Modulate and Screen here by adding one more dst coefficient to multiply the source color in:

frag_color =
    src * (frag_info.src_coeff + dst.a * frag_info.src_coeff_dst_alpha) +
    dst * (frag_info.dst_coeff + src.a * frag_info.dst_coeff_src_alpha +
                                 src * frag_info.dst_coeff_src_color);

...and then the full table with all the blends becomes:

{src_coeff, src_coeff_dst_alpha, dst_coeff, dst_coeff_src_alpha, dst_coeff_src_color}

{0,  0,  0,  0,  0}, // Clear
{1,  0,  0,  0,  0}, // Source
{0,  0,  1,  0,  0}, // Destination
{1,  0,  1, -1,  0}, // SourceOver
{1, -1,  1,  0,  0}, // DestinationOver
{0,  1,  0,  0,  0}, // SourceIn
{0,  0,  0,  1,  0}, // DestinationIn
{1, -1,  0,  0,  0}, // SourceOut
{0,  0,  1, -1,  0}, // DestinationOut
{0,  1,  1, -1,  0}, // SourceATop
{1, -1,  0,  1,  0}, // DestinationATop
{1, -1,  1, -1,  0}, // Xor
{1,  0,  1,  0,  0}, // Plus
{0,  0,  0,  0,  1}, // Modulate
{0,  0,  1,  0, -1}, // Screen

+cc @flar in case he has a moment to check my math :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like a more technically sound approach, I'll make this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, lines up with the current behavior using a 0.5 alpha red and blue:

ToT

flutter_01

Patched:

flutter_03

@bdero bdero requested a review from flar April 14, 2023 22:23
@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 #41098 at sha 7cf5333

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!

@flutter-dashboard
Copy link

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

Changes reported for pull request #41098 at sha 6a22ec3

@jonahwilliams
Copy link
Contributor Author

Goldens revealed that the check to convert the foreground blend back into a snapshot wasn't quite working correctly so I took it out. now we only apply the foreground if we can absorb opacity (which should generally be always)

@flutter-dashboard
Copy link

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

Changes reported for pull request #41098 at sha ee32ab7

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 15, 2023
@auto-submit auto-submit bot merged commit 6013a70 into flutter:main Apr 15, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 15, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 15, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 16, 2023
…124933)

flutter/engine@feb476b...da0805a

2023-04-15 [email protected] Roll Skia from 2a4d95762651 to 2d0b05335104 (1 revision) (flutter/engine#41250)
2023-04-15 [email protected] [Impeller] add a generic porter duff blend foreground shader. (flutter/engine#41098)
2023-04-15 [email protected] Roll Fuchsia Linux SDK from Y_tD90hDX_jiubGbC... to hacWN-gQSoWudziIS... (flutter/engine#41248)
2023-04-15 [email protected] Roll Fuchsia Mac SDK from RFyPoDrXzIiy-E3wn... to gI2knJ4Rh0yoK4Syd... (flutter/engine#41249)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from Y_tD90hDX_ji to hacWN-gQSoWu
  fuchsia/sdk/core/mac-amd64 from RFyPoDrXzIiy to gI2knJ4Rh0yo

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 [email protected],[email protected],[email protected] 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
exaby73 pushed a commit to NevercodeHQ/flutter that referenced this pull request Apr 17, 2023
…lutter#124933)

flutter/engine@feb476b...da0805a

2023-04-15 [email protected] Roll Skia from 2a4d95762651 to 2d0b05335104 (1 revision) (flutter/engine#41250)
2023-04-15 [email protected] [Impeller] add a generic porter duff blend foreground shader. (flutter/engine#41098)
2023-04-15 [email protected] Roll Fuchsia Linux SDK from Y_tD90hDX_jiubGbC... to hacWN-gQSoWudziIS... (flutter/engine#41248)
2023-04-15 [email protected] Roll Fuchsia Mac SDK from RFyPoDrXzIiy-E3wn... to gI2knJ4Rh0yoK4Syd... (flutter/engine#41249)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from Y_tD90hDX_ji to hacWN-gQSoWu
  fuchsia/sdk/core/mac-amd64 from RFyPoDrXzIiy to gI2knJ4Rh0yo

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 [email protected],[email protected],[email protected] 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
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 needs tests will affect goldens

Projects

No open projects
Archived in project

3 participants