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] implements new blur tile mode #48805

Merged
merged 6 commits into from Dec 8, 2023
Merged

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Dec 7, 2023

fixes flutter/flutter#139165

before

Screenshot 2023-12-07 at 2 18 42 PM

after

Screenshot 2023-12-07 at 2 14 39 PM

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.

@gaaclarke gaaclarke marked this pull request as ready for review December 7, 2023 22:39
@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 #48805 at sha c65e3a1

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.

I haven't scrutinized how the UV mapping works super closely yet, but overall this LGTM!

Entity::TileMode tile_mode) {
switch (tile_mode) {
case Entity::TileMode::kDecal:
if (renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode()) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a todo/issue for emulating this when it's not supported? The halo won't render correctly on some devices w/ the current technique without this.

We already have a specialized pipeline that the old blur uses for this w/ the same vertex/uniform layouts (GaussianBlurDecalPipeline).

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: flutter/flutter#139773

How do we look up availability on gpuinfo.org? I had a hard time finding it. It's just available to everyone on Vulkan right? The check is just for OpenGLES?

Copy link
Member

@bdero bdero Dec 7, 2023

Choose a reason for hiding this comment

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

Yeah decal is supported for Metal (via MTLSamplerAddressModeClampToZero) and our min Vulkan profile without any extensions. For OpenGLES we check for GL_EXT_texture_border_clamp or GL_NV_texture_border_clamp.

image

This looks worse than the situation actually is, though. I'm pretty sure "coverage" on gpuinfo.org is just "percentage of devices in the database" and doesn't weight for an estimation of actual usage. And of course, there are ancient devices on the list that Flutter doesn't support.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yea, good point. Over time the usefulness of gpuinfo.org will wane if they don't have some sort of filter for old devices. Something like filtering based on operating system would probably work since the OS developers will start dropping support.

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!

@gaaclarke
Copy link
Member Author

gaaclarke commented Dec 7, 2023

I haven't scrutinized how the UV mapping works super closely yet, but overall this LGTM!

So, first we attempt to create the gutter by expanding the clip coverage to get the snapshot. That may or may not contain all the content for the gutter we need in the snapshot. Then when we downsample we blow out the uvs of the snapshot to create the gutter.

One place where this may not work is if we draw an image filter on an image whose "source rect" is smaller than the full image. I guess that may be possible with Canvas::DrawImageRect. It may not work because it will be grabbing extra content from the source texture, not creating the transparent gutter with kDecale.

@@ -82,21 +108,22 @@ std::shared_ptr<Texture> MakeDownsampleSubpass(
// creates a halo effect. This compensates for when the expanded clip
// region can't give us the full gutter we want.
Vector2 texture_size = Vector2(input_texture->GetSize());
Quad vertices =
Quad guttered_uvs =
Copy link
Member Author

Choose a reason for hiding this comment

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

This math may assume that the centroid of the uv's is 0.5, 0.5 too so it may not work if that isn't the case? @bdero

@gaaclarke
Copy link
Member Author

I'm not certain if this handles all cases yet. This passes all of our existing tests and passes 1 new one so it's a step forward. The broken cases may be rare enough to ingore for now. I'm going to land it, implement clamping the sigma then poke around to see if I can break this.

@gaaclarke gaaclarke merged commit 6a687be into flutter:main Dec 8, 2023
27 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 8, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Dec 8, 2023
…139781)

flutter/engine@89ad167...6a687be

2023-12-08 30870216+gaaclarke@users.noreply.github.com [Impeller] implements new blur tile mode (flutter/engine#48805)
2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from dd7e37c0e2bd to 9e89d96899f4 (2 revisions) (flutter/engine#48809)
2023-12-07 matanlurey@users.noreply.github.com Add a note that rolling clang_version manually is dangerous. (flutter/engine#48808)

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 chinmaygarde@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
Markzipan pushed a commit to Markzipan/flutter that referenced this pull request Jan 9, 2024
…lutter#139781)

flutter/engine@89ad167...6a687be

2023-12-08 30870216+gaaclarke@users.noreply.github.com [Impeller] implements new blur tile mode (flutter/engine#48805)
2023-12-07 skia-flutter-autoroll@skia.org Roll Skia from dd7e37c0e2bd to 9e89d96899f4 (2 revisions) (flutter/engine#48809)
2023-12-07 matanlurey@users.noreply.github.com Add a note that rolling clang_version manually is dangerous. (flutter/engine#48808)

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 chinmaygarde@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
Projects
No open projects
Archived in project
3 participants