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

[Impeller] Fix alpha management issues for advanced blends. #50070

Merged
merged 10 commits into from
Jan 28, 2024

Conversation

bdero
Copy link
Member

@bdero bdero commented Jan 26, 2024

Resolves flutter/flutter#140970.

The issue is easy to miss in the goldens if you don't know what to look for, but it was always present in one way or another. In the "before" image below, we end up removing some of the backdrop alpha as a result of the blend, which should never happen with an advanced blend:

image

This was happening because we were lerping towards the original source alpha from the destination alpha. So in the sad smiley case, the RGB getting written to the framebuffer was exactly correct, but the alpha would end up being less than 1, which the window manager then blends against the black-initialized framebuffer.

Blending with the black background just so happened to perfectly match the appearance of the color being double-premultiplied, which is why increasing the source color's vibrancy by unpremultiplying also looks correct. But again, that only works iff the pass texture winds up being drawn to a black background, which is a rare case for offscreen passes.

Skia (Flutter documentation):
image

Impeller before:
image

Impeller after:
image

@flutter-dashboard

This comment was marked as outdated.

@bdero bdero force-pushed the bdero/fix-blend-alpha-issues branch from 24e89f0 to 8a7c6aa Compare January 26, 2024 02:08
@bdero bdero force-pushed the bdero/fix-blend-alpha-issues branch from 5d8f639 to 7da9005 Compare January 26, 2024 05:08
@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 #50070 at sha e5bf54e

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM!

@bdero
Copy link
Member Author

bdero commented Jan 26, 2024

This is close but the composite still isn't quite right, a subset of the advanced blends look like the output color is getting doubled up. Working on fixing it.

@bdero
Copy link
Member Author

bdero commented Jan 27, 2024

Fixed that issue and discovered a few new ones while combing through:

  • ColorDodge: CPU difference.
  • ColorBurn: CPU & Skia diffference, weird artifacts, src drawing over white.
  • Saturation: Skia difference, vertical strips look more pronounced, bird tail outline yellow instead of pink.
  • Color: Skia difference, vertical strips look more pronounced.
  • Luminosity: Skia difference, vertical strips are leaking through color from the source image.

Investigating those now. The CPU mismatches need to be fixed now because they need to exactly match up otherwise there may be color jumps when the clear color optimization kicks in. But I think the saturation/color/luminosity differences with Skia are preexisting. Pretty sure I know what's going on there though.

@bdero
Copy link
Member Author

bdero commented Jan 27, 2024

Okay figured out the cause of the CPU differences for ColorDodge/ColorBurn. Problem was CPU-side.

@flutter-dashboard
Copy link

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

Changes reported for pull request #50070 at sha 3999403

@flutter-dashboard
Copy link

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

Changes reported for pull request #50070 at sha caf0d80

@bdero
Copy link
Member Author

bdero commented Jan 28, 2024

The remaining issues w.r.t. the appearance of the source image vertical strips are fixed!

@bdero bdero self-assigned this Jan 28, 2024
@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 28, 2024
@auto-submit auto-submit bot merged commit e33f3b4 into flutter:main Jan 28, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 29, 2024
…142425)

flutter/engine@f3d48be...f15cb86

2024-01-29 [email protected] Revert Dart to Version 3.4.0-82.0.dev (flutter/engine#50131)
2024-01-28 [email protected] Roll Dart SDK from 639cf51f4472 to 1d0b890287a4 (1 revision) (flutter/engine#50129)
2024-01-28 [email protected] Roll Skia from 40205cafdb4e to d81204e28dcb (1 revision) (flutter/engine#50127)
2024-01-28 [email protected] Roll Fuchsia Linux SDK from GBTh3gOOgmndwT70X... to 5aijurFz23iIuRaMQ... (flutter/engine#50126)
2024-01-28 [email protected] [Impeller] Fix alpha management issues for advanced blends. (flutter/engine#50070)
2024-01-28 [email protected] Roll Skia from 0c1e352e87aa to 40205cafdb4e (1 revision) (flutter/engine#50124)
2024-01-27 [email protected] Roll Dart SDK from 422d048880a8 to 639cf51f4472 (1 revision) (flutter/engine#50123)
2024-01-27 [email protected] Revert "[Windows] Introduce `egl::Surface` and `egl::WindowSurface`" (flutter/engine#50104)
2024-01-27 [email protected] Roll Dart SDK from d0b48a008559 to 422d048880a8 (1 revision) (flutter/engine#50121)
2024-01-27 [email protected] Roll Skia from b9b80230c87b to 0c1e352e87aa (1 revision) (flutter/engine#50120)
2024-01-27 [email protected] Roll Dart SDK from 141ab6c14cd1 to d0b48a008559 (1 revision) (flutter/engine#50119)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from GBTh3gOOgmnd to 5aijurFz23iI

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://issues.skia.org/issues/new?component=1389291&template=1850622

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 will affect goldens
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Impeller] Svg with linear gradient rendering incorrectly.
3 participants