Skip to content

[impeller] the blur can discard fidelity from an overflow with the correct scale + sigma #150462

@gaaclarke

Description

@gaaclarke

Certain combinations of scale + sigma can cause the shader to overflow now that we are scaling the sigma based on the entity's transform.

I played around with this a bit and just increasing the sigma from zero to 1000 won't cause a crash. A scale is required.

The following patch will make it never possible. It seems like it isn't throwing much away in the case that hits this. The way that this should work is that GaussianBlurFilterContents::CalculateScale should accommodate for large sigmas with a counteracting downscale. There is a certain range of input that is falling through the cracks though.

diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
index 035109e519..96c585b3fe 100644
--- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
+++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
@@ -653,6 +660,13 @@ GaussianBlurPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
     x_offset = 1;
   }
 
+  // This is a safe-guard to make sure we don't overflow the fragment shader.
+  // The kernel size is multiplied by 2 since we'll use the lerp hack on the
+  // result.
+  if (result.sample_count > (2 * (kMaxKernelSize - 1))) {
+    result.sample_count = 2 * (kMaxKernelSize - 1);
+  }
+

reproduction steps

  1. run the EntityTest.GaussianBlurFilter
  2. set the x scale to 3.0
  3. set the sigma to combined
  4. start increasing the sigma
  5. notice that around 300 sigma, there will be a crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requeststeam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions