-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] scales blur coverage to match rendered output #47621
Conversation
f216f4b
to
e6bdcc6
Compare
std::optional<Entity> result = | ||
contents->GetEntity(renderer, entity, coverage_hint); | ||
ASSERT_TRUE(result.has_value()); | ||
ASSERT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to have better asserts here about the coverage of the result. I'm not 100% up to date about what the values should be considering the coverage hint yet though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual approval should come from someone who understands the implementation IMO
impeller/renderer/testing/mocks.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these!
entity.SetTransformation(Matrix::MakeTranslation({100, 100, 0})); | ||
std::optional<Rect> coverage = contents->GetFilterCoverage( | ||
inputs, entity, /*effect_transform=*/Matrix::MakeScale({2.0, 2.0, 1.0})); | ||
ASSERT_EQ(coverage, Rect::MakeLTRB(100 - 2, 100, 200 + 2, 200)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and elsewhere:
I might either expand on the test name, or leave a comment (or does ASSERT support reasons, i.e. << "Reason") of why this is the expected result. From someone totally unfamiliar with this code, I don't understand what the test would mean if it failed or why this is the expected result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is an example I would use of questionable mock usage. the DirectionalGaussianBlur is written against the HAL, which we can already test on CI with the real implementations. See entity_unittests for examples, but we don't need to, nor should we mock out APIs that are already abstracted from the platform.
What is the value of the "real" HAL here? Or are you saying you wouldn't want to see tests that assert C++ math would want to see golden/UI tests produced from a real backend instead? |
Assertions on the contents are great! but you don't need to mock out the HAL to write this test. Just ... use the HAL as it already exists? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically to do so, you'd take a similar structure to the golden tests like https://github.com/flutter/engine/blob/main/impeller/entity/entity_unittests.cc#L261
Except rather than making an assertion on the pixels, you can introspect on the contents/entity
@jonahwilliams I gave Preferring concrete classes is why in these tests I used a real There are some potential scaling issues with that approach as well. Managing hardware profiles can be more cumbersome than directly specifying them in the test with the mocks. All tests will be run 3 times, which assuming the bottom layers are correct (a correct assumption for a unit test), will be redundant. Plus they are incurring extra cost of starting and tearing down the hardware contexts. I think it's really important we get the type of integration testing we'd get from using the real objects, for that we have the golden image tests. I'm in the middle of writing out the new blur but I'm using this testing harness to make sure I get coverage correct. I'll use golden images to make sure the visual results are correct. Sound good? I'm happy to discuss further over chat or brainjam on a design that broadens out your testing harness. |
Ugh, i really messed up this branch. I accidentally had it tracking the branch that I tried to split this from. I'll try to sort it out. |
Jonah Matan and I met and chatted about this. We agreed to move the tests to the concrete types and minimize the use of mocking to cases where it is unavoidable (such as upspecing the capabilities of the test hardware). We also agreed to come up with a mechanism to downspec the capabilities in these concrete classes to aide testing. |
impeller/renderer/testing/mocks.h
Outdated
(override)); | ||
}; | ||
|
||
class MockCapabilities : public Capabilities { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to MockCapabilities, there is a CapabilitiesBuilder/StandardCapabilities that lets you set whatever you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just removed all this work for now. They aren't used. I figured it didn't hurt and may potentially save time in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably end up landing most of this with the other blur anyways where it is actually used. We'll see.
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. |
std::optional<Rect> contents_coverage = contents->GetCoverage(entity); | ||
EXPECT_TRUE(result_coverage.has_value()); | ||
EXPECT_TRUE(contents_coverage.has_value()); | ||
if (result_coverage.has_value() && contents_coverage.has_value()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding an Expect_rect_near macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll problem happen if the new blur has better test coverage like i hope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
nit: this is adding more testings only right? I would adjust PR title if so.
Nope, there is actually a coverage fix in there. |
transform.TransformDirection(blur_direction_ * Radius{blur_sigma_}.radius) | ||
transform | ||
.TransformDirection(blur_direction_ * | ||
Radius{ScaleSigma(blur_sigma_)}.radius) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, missed this!
Oh, I missed that. Maybe "Ensure blur coverage sigma is also scaled..." or something like that. |
…137979) flutter/engine@461d815...b1a5d77 2023-11-07 skia-flutter-autoroll@skia.org Roll Skia from 7e3119240ae4 to 9106e374e08d (1 revision) (flutter/engine#47732) 2023-11-07 skia-flutter-autoroll@skia.org Roll Dart SDK from 82731b940e7f to aded6314af29 (1 revision) (flutter/engine#47731) 2023-11-07 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from HQfFSkurc6-jKM2jh... to wmM4lS2lYcphFSHPV... (flutter/engine#47730) 2023-11-07 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from _vGlgDiKOrtlKrZAP... to NaQb_BU6PSbKXSAoU... (flutter/engine#47728) 2023-11-07 skia-flutter-autoroll@skia.org Roll Skia from bd5f57c9bd1a to 7e3119240ae4 (10 revisions) (flutter/engine#47726) 2023-11-06 gspencergoog@users.noreply.github.com Add `KeyEventDeviceType` to `KeyData` (flutter/engine#47315) 2023-11-06 skia-flutter-autoroll@skia.org Roll Skia from 2b218381e226 to bd5f57c9bd1a (2 revisions) (flutter/engine#47719) 2023-11-06 skia-flutter-autoroll@skia.org Roll Dart SDK from 07d4c9d85a5a to 82731b940e7f (1 revision) (flutter/engine#47717) 2023-11-06 skia-flutter-autoroll@skia.org Roll Skia from 77aeee3b81a5 to 2b218381e226 (1 revision) (flutter/engine#47715) 2023-11-06 30870216+gaaclarke@users.noreply.github.com [Impeller] scales blur coverage to match rendered output (flutter/engine#47621) 2023-11-06 jonahwilliams@google.com [Impeller] Fix EntityPassTarget::Flip with implict MSAA. (flutter/engine#47701) 2023-11-06 skia-flutter-autoroll@skia.org Roll Dart SDK from 9211fc6406bb to 07d4c9d85a5a (1 revision) (flutter/engine#47709) 2023-11-06 jonahwilliams@google.com [Impeller] fix drawVertices dest fast path to apply alpha. (flutter/engine#47695) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from _vGlgDiKOrtl to NaQb_BU6PSbK fuchsia/sdk/core/mac-amd64 from HQfFSkurc6-j to wmM4lS2lYcph 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
in pursuit of: flutter/flutter#131580
I'm starting to write tests for the new blur, but I wanted to make tests for the old blur to make sure I understood the coverage rules. I decided to check this in separately while I work on the other blur.
Even though the goal is to delete this class eventually. Most of this work transfers over to the new blur.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.