[Impeller] Fix nullopt access and simplify coverage computation in GetSubpassCoverage.#47347
[Impeller] Fix nullopt access and simplify coverage computation in GetSubpassCoverage.#47347bdero merged 3 commits intoflutter:mainfrom
Conversation
impeller/entity/entity_pass.cc
Outdated
| if (backdrop_coverage.has_value()) { | ||
| if (unfiltered_coverage.has_value()) { | ||
| unfiltered_coverage = coverage->Union(*backdrop_coverage); | ||
| unfiltered_coverage = coverage.has_value() |
There was a problem hiding this comment.
I might be missing something, but I don't see how coverage.has_value() could ever be true here.
There was a problem hiding this comment.
Also, this tests backdrop_coverage.has_value() after it already used the -> operator on it...
There was a problem hiding this comment.
Is the bug here that the calculation should have been unfiltered_coverage->Union(*backdrop_coverage) all along?
There was a problem hiding this comment.
Fixed, yeah this was supposed to union with unfiltered_coverage.
impeller/entity/entity_pass.cc
Outdated
| if (unfiltered_coverage.has_value()) { | ||
| unfiltered_coverage = coverage->Union(*backdrop_coverage); | ||
| unfiltered_coverage = coverage.has_value() | ||
| ? coverage->Union(*backdrop_coverage) |
There was a problem hiding this comment.
I have new functions in #47183 that perform nullopt aware Union and Intersection that might simplify this code.
a3d1a82 to
86535a6
Compare
86535a6 to
b290657
Compare
| // backdrop filter, then incorporate the backdrop filter in the | ||
| // pre-filtered coverage of the subpass. | ||
| if (result.has_value() && subpass.backdrop_filter_proc_) { | ||
| if (accumulated_coverage.has_value() && subpass.backdrop_filter_proc_) { |
There was a problem hiding this comment.
Why is this based on accumulated_coverage? If there is a backdrop filter on one of the elements, then the subpass coverage should be automatically expanded to the coverage_limit, shouldn't it?
There was a problem hiding this comment.
This is wrong when backdrop filters are destructive color filters, but don't detect this right now. This is already being tracked here: flutter/flutter#137090
There was a problem hiding this comment.
Oh, I'm forgetting that BDF only operates on the current layer so it will depend on the accumulated coverage...
In the DiffContext partial repaint code BDF always accumulates the coverage_limit which is probably conservative for one that appears inside another layer (or one that appears with no previous "clear" command).
impeller/entity/entity_pass.cc
Outdated
| auto backdrop_coverage = backdrop_filter->GetCoverage({}); | ||
| backdrop_coverage->origin += result->origin; | ||
| if (backdrop_coverage.has_value()) { | ||
| backdrop_coverage->origin += accumulated_coverage->origin; |
There was a problem hiding this comment.
I'm not sure why this is done...? A BDF is independent of the prior content in the pass.
There was a problem hiding this comment.
I think this is a bug and removed it... Let's see those goldens. The filter's coverage is computed above with an identity transform, but the placeholder rect given to the filter input should already contain the offset.
impeller/entity/entity_pass.cc
Outdated
| if (unfiltered_coverage.has_value()) { | ||
| unfiltered_coverage = coverage->Union(*backdrop_coverage); | ||
| unfiltered_coverage = | ||
| unfiltered_coverage->Union(*backdrop_coverage); |
There was a problem hiding this comment.
This if/else can be replaced with unfiltered_coverage = Union(backdrop_coverage.value(), unfiltered_coverage)
impeller/entity/entity_pass.cc
Outdated
| } | ||
| result = result->Union(coverage.value()); | ||
| accumulated_coverage = | ||
| accumulated_coverage->Union(element_coverage.value()); |
There was a problem hiding this comment.
All of these lines (178-187) => accumulated_coverage = Union(accumulated_coverage, element_coverage)
impeller/entity/entity_pass.cc
Outdated
| if (element_coverage.has_value() && coverage_limit.has_value() && | ||
| (!image_filter || image_filter->IsTranslationOnly())) { | ||
| coverage = coverage->Intersection(coverage_limit.value()); | ||
| element_coverage = |
There was a problem hiding this comment.
My head is spinning a little here - why does image_filter disqualify this intersection?
There was a problem hiding this comment.
We shouldn't need to guard against this anymore now that the coverage_limit incorporates image filters as we walk the subpasses (not that it was a correct fix to begin with). Removed it.
b290657 to
0fccf6f
Compare
|
Whoops, didn't push my changes until now 😅 |
0fccf6f to
8e6b898
Compare
impeller/entity/entity_pass.cc
Outdated
| unfiltered_coverage = backdrop_coverage; | ||
| } | ||
| unfiltered_coverage = | ||
| Union(backdrop_coverage.value(), unfiltered_coverage); |
There was a problem hiding this comment.
This can be further simplified to Union(unfiltered_coverage, backdrop_coverage)
There was a problem hiding this comment.
(No need to test backdrop_coverage.has_value() around it as the Union overrides will do that for you.)
impeller/entity/entity_pass.cc
Outdated
| current_clip_coverage->Intersection( | ||
| element_entity.GetContents()->GetCoverageHint().value())); | ||
| element_coverage_hint.value().Intersection( | ||
| current_clip_coverage.value())); |
There was a problem hiding this comment.
Can all of this be replaced by
element_entity.GetContents()->SetCoverageHint(Intersection(element_coverage_hint, current_clip_coverage)?
|
Appreciate you taking a look for spots we can simplify with the new utils. I think it removes quite a bit of cognitive overhead while reading through this part of the codebase. |
flar
left a comment
There was a problem hiding this comment.
Looks good. We should look at using GetSourceCoverage in there at some point.
| if (!filter || filter->IsTranslationOnly()) { | ||
| coverage = coverage->Intersection(coverage_limit.value()); | ||
| element_coverage = | ||
| element_coverage->Intersection(coverage_limit.value()); |
There was a problem hiding this comment.
This looks like a good place to use filter->GetSourceCoverage, maybe as a follow-on?
|
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 or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use 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. |
db240bf to
c26fd1b
Compare
…on in GetSubpassCoverage. (flutter/engine#47347)
flutter/engine@db06c2e...a0ac6b4 2023-11-01 bdero@google.com [Impeller] Include cstdint everywhere that uint32_t is used. (flutter/engine#47533) 2023-11-01 bdero@google.com [Impeller] Fix nullopt access and simplify coverage computation in GetSubpassCoverage. (flutter/engine#47347) 2023-11-01 bdero@google.com [Impeller] OpenGLES: Ensure frag/vert textures are bound with unique texture units. (flutter/engine#47218) 2023-11-01 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from LCfhx_lTRJI51G0zc... to _TyF0etsONe5aqCbM... (flutter/engine#47532) 2023-11-01 jonahwilliams@google.com [Impeller] stencil buffer record/replay instead of MSAA storage. (flutter/engine#47397) 2023-11-01 chris@bracken.jp [macOS] Delete FlutterCompositor tests (flutter/engine#47527) 2023-10-31 bdero@google.com [Impeller] Place Rect statics under the Rect template. (flutter/engine#47529) 2023-10-31 skia-flutter-autoroll@skia.org Roll Skia from aaa225e0cc6d to 34ef20100acc (1 revision) (flutter/engine#47530) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from LCfhx_lTRJI5 to _TyF0etsONe5 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 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://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
Follow up for comments in #46130.
This case shouldn't actually be possible today, but we should be able to make this reasonably testable without goldens... added an issue to follow-up here: flutter/flutter#137356
This branch noise will also melt away with: flutter/flutter#137306