Skip to content
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] generate mipmaps for imagefilters #49794

Merged
merged 11 commits into from
Jan 16, 2024

Conversation

gaaclarke
Copy link
Member

This resolves Jonah's feedback on #49607 and Brandons feedback on #49607 and #49778.

This avoids the need to do a lookahead by storing the proper mip count value while building the drawing on the canvas.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Member

@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!

impeller/aiks/aiks_unittests.cc Outdated Show resolved Hide resolved
paint.image_filter->Visit(mip_count_visitor);
new_layer_pass.SetRequiredMipCount(
std::max(mip_count_visitor.GetRequiredMipCount(),
new_layer_pass.GetRequiredMipCount()));
Copy link
Member

@bdero bdero Jan 16, 2024

Choose a reason for hiding this comment

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

The new layer will always have a default required mip count. The place where the maxing needs to happen is when a layer is being appended that has a backdrop filter.

Copy link
Member Author

Choose a reason for hiding this comment

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

The place where the maxing needs to happen is when a layer is being appended that has a backdrop filter.

That still exists from the last PR. This covers both cases, image filter and backdrop filter. Is there a case this doesn't cover, or are you suggesting there is a singular place we can put this code instead of having it in 2 locations?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, you are saying the max needs to happen there as well? I'm not understanding the order of operations that is problematic. Can you lay it out for me?

Copy link
Member

@bdero bdero Jan 16, 2024

Choose a reason for hiding this comment

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

The mip count we need to use when allocating the texture is the maximum we detect for all reads. A backdrop texture is read by both subpass backdrop filters as well as the image filter that happened to be set at the time the SaveLayer was made.

Inside of Save(), the RequiredMipCount of the new layer is being set to the backdrop filter's mip count. But the backdrop filter will read from the parent layer's backdrop, not the new layer's backdrop.

Copy link
Member

@bdero bdero Jan 16, 2024

Choose a reason for hiding this comment

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

So when we come across a backdrop filter, we need to max the mip count with the parent pass mip count. And when an image filter is being applied via the paint state, no maxing is necessary when setting the mip count because nothing should have set the mip count yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yea I see, thanks. This started making the previous tests print out the "no mips" message when rendering the blur. I would like to have a way to assert that in the tests. We still have some tests that use the filter without mips (assuming they will have them at runtime) so I was a bit squishy with that. I'll see if I can find a way to assert it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay fixed. I added a logs check to make sure this doesn't regress. We don't have a better way to assert this currently. I can file an issue to make it a hard assert and migrate all the tests over.

@gaaclarke gaaclarke requested a review from bdero January 16, 2024 21:50
@@ -190,6 +190,9 @@ void Canvas::Save(bool create_subpass,
MipCountVisitor mip_count_visitor;
backdrop_filter->Visit(mip_count_visitor);
subpass->SetRequiredMipCount(mip_count_visitor.GetRequiredMipCount());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
subpass->SetRequiredMipCount(mip_count_visitor.GetRequiredMipCount());

Copy link
Member Author

Choose a reason for hiding this comment

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

done

impeller/aiks/canvas.cc Outdated Show resolved Hide resolved
@gaaclarke gaaclarke requested a review from bdero January 16, 2024 22:18
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

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 16, 2024
@auto-submit auto-submit bot merged commit 5d2fa4c into flutter:main Jan 16, 2024
28 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 17, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 17, 2024
…141664)

flutter/engine@d4b6b7e...1382ff7

2024-01-16 magder@google.com Remove iOS 12 availability checks (flutter/engine#49771)
2024-01-16 30870216+gaaclarke@users.noreply.github.com [Impeller] generate mipmaps for imagefilters (flutter/engine#49794)
2024-01-16 ditman@gmail.com [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777)
2024-01-16 737941+loic-sharma@users.noreply.github.com Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696)
2024-01-16 jonahwilliams@google.com [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780)

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 jonahwilliams@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://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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants