Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Created May 29, 2025 20:21
Show Gist options
  • Save jonahwilliams/4ad853c26fa1f8f48c666047b313c3cf to your computer and use it in GitHub Desktop.
Save jonahwilliams/4ad853c26fa1f8f48c666047b313c3cf to your computer and use it in GitHub Desktop.
diff --git a/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
index c1177434c18..342078596dc 100644
--- a/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
+++ b/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc
@@ -785,91 +785,20 @@ std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
return std::nullopt;
}
- Vector2 pass1_pixel_size =
- 1.0 / Vector2(pass1_out.value().GetRenderTargetTexture()->GetSize());
-
- Quad blur_uvs = {Point(0, 0), Point(1, 0), Point(0, 1), Point(1, 1)};
-
- std::shared_ptr<CommandBuffer> command_buffer_2 =
- renderer.GetContext()->CreateCommandBuffer();
- if (!command_buffer_2) {
- return std::nullopt;
- }
-
- fml::StatusOr<RenderTarget> pass2_out = MakeBlurSubpass(
- renderer, command_buffer_2, /*input_pass=*/pass1_out.value(),
- input_snapshot->sampler_descriptor, tile_mode_,
- BlurParameters{
- .blur_uv_offset = Point(0.0, pass1_pixel_size.y),
- .blur_sigma = blur_info.scaled_sigma.y *
- downsample_pass_args.effective_scalar.y,
- .blur_radius = ScaleBlurRadius(
- blur_info.blur_radius.y, downsample_pass_args.effective_scalar.y),
- .step_size = 1,
- },
- /*destination_target=*/std::nullopt, blur_uvs);
-
- if (!pass2_out.ok()) {
+ if (renderer.GetContext()->EnqueueCommandBuffer(
+ std::move(command_buffer_1))) {
return std::nullopt;
}
- std::shared_ptr<CommandBuffer> command_buffer_3 =
- renderer.GetContext()->CreateCommandBuffer();
- if (!command_buffer_3) {
- return std::nullopt;
- }
-
- // Only ping pong if the first pass actually created a render target.
- auto pass3_destination = pass2_out.value().GetRenderTargetTexture() !=
- pass1_out.value().GetRenderTargetTexture()
- ? std::optional<RenderTarget>(pass1_out.value())
- : std::optional<RenderTarget>(std::nullopt);
-
- fml::StatusOr<RenderTarget> pass3_out = MakeBlurSubpass(
- renderer, command_buffer_3, /*input_pass=*/pass2_out.value(),
- input_snapshot->sampler_descriptor, tile_mode_,
- BlurParameters{
- .blur_uv_offset = Point(pass1_pixel_size.x, 0.0),
- .blur_sigma = blur_info.scaled_sigma.x *
- downsample_pass_args.effective_scalar.x,
- .blur_radius = ScaleBlurRadius(
- blur_info.blur_radius.x, downsample_pass_args.effective_scalar.x),
- .step_size = 1,
- },
- pass3_destination, blur_uvs);
-
- if (!pass3_out.ok()) {
- return std::nullopt;
- }
-
- if (!(renderer.GetContext()->EnqueueCommandBuffer(
- std::move(command_buffer_1)) &&
- renderer.GetContext()->EnqueueCommandBuffer(
- std::move(command_buffer_2)) &&
- renderer.GetContext()->EnqueueCommandBuffer(
- std::move(command_buffer_3)))) {
- return std::nullopt;
- }
-
- // The ping-pong approach requires that each render pass output has the same
- // size.
- FML_DCHECK((pass1_out.value().GetRenderTargetSize() ==
- pass2_out.value().GetRenderTargetSize()) &&
- (pass2_out.value().GetRenderTargetSize() ==
- pass3_out.value().GetRenderTargetSize()));
-
- SamplerDescriptor sampler_desc = MakeSamplerDescriptor(
- MinMagFilter::kLinear, SamplerAddressMode::kClampToEdge);
-
Entity blur_output_entity = Entity::FromSnapshot(
- Snapshot{.texture = pass3_out.value().GetRenderTargetTexture(),
+ Snapshot{.texture = pass1_out.value().GetRenderTargetTexture(),
.transform =
entity.GetTransform() * //
Matrix::MakeScale(1.f / blur_info.source_space_scalar) * //
Matrix::MakeTranslation(-1 * blur_info.source_space_offset) *
downsample_pass_args.transform * //
Matrix::MakeScale(1 / downsample_pass_args.effective_scalar),
- .sampler_descriptor = sampler_desc,
+ .sampler_descriptor = {},
.opacity = input_snapshot->opacity},
entity.GetBlendMode());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment