From 91b7617fc5372e0a5053b1850cb8c567d2c7e0c6 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 13 Mar 2025 14:42:54 -0700 Subject: [PATCH] [Impeller] disable depth-stencil and MSAA for gaussian and downsample. (#165137) Using MSAA w/ depth stencil requires extra work on the GPU to track multiple samples and clear the depth/stencil textures. See also: https://docs.qualcomm.com/bundle/publicresource/topics/80-78185-2/best_practices.html Its unclear _how_ much this matters, but adreno recommends minimizing bin count and as such minimizing msaa samples. Well, we can fully minimize it by not enabling it. Removing depth stencil was also considered in the past, this should be removed as it requires us to clear, which isn't free. Its likely this won't have a huge performance impact, but seems like a good best practice. --- .../impeller/entity/contents/content_context.cc | 14 ++++++++++---- .../filters/gaussian_blur_filter_contents.cc | 13 +++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/content_context.cc b/engine/src/flutter/impeller/entity/contents/content_context.cc index fe38c47047..7a245eaf72 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.cc +++ b/engine/src/flutter/impeller/entity/contents/content_context.cc @@ -307,6 +307,12 @@ ContentContext::ContentContext( .primitive_type = PrimitiveType::kTriangleStrip, .color_attachment_pixel_format = context_->GetCapabilities()->GetDefaultColorFormat()}; + auto options_no_msaa_no_depth_stencil = ContentContextOptions{ + .sample_count = SampleCount::kCount1, + .primitive_type = PrimitiveType::kTriangleStrip, + .color_attachment_pixel_format = + context_->GetCapabilities()->GetDefaultColorFormat(), + .has_depth_stencil_attachments = false}; const auto supports_decal = static_cast( context_->GetCapabilities()->SupportsDecalSamplerAddressMode()); @@ -380,14 +386,14 @@ ContentContext::ContentContext( clip_pipelines_.SetDefault( options, std::make_unique(*context_, clip_pipeline_descriptor)); - texture_downsample_pipelines_.CreateDefault(*context_, - options_trianglestrip); + texture_downsample_pipelines_.CreateDefault( + *context_, options_no_msaa_no_depth_stencil); rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip); texture_strict_src_pipelines_.CreateDefault(*context_, options); tiled_texture_pipelines_.CreateDefault(*context_, options, {supports_decal}); - gaussian_blur_pipelines_.CreateDefault(*context_, options_trianglestrip, - {supports_decal}); + gaussian_blur_pipelines_.CreateDefault( + *context_, options_no_msaa_no_depth_stencil, {supports_decal}); border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip); color_matrix_color_filter_pipelines_.CreateDefault(*context_, options_trianglestrip); 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 b2e81ce1dc..0d85fc6694 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 @@ -377,7 +377,9 @@ fml::StatusOr MakeDownsampleSubpass( return pass.Draw().ok(); }; return renderer.MakeSubpass("Gaussian Blur Filter", pass_args.subpass_size, - command_buffer, subpass_callback); + command_buffer, subpass_callback, + /*msaa_enabled=*/false, + /*depth_stencil_enabled=*/false); } else { // This assumes we don't scale below 1/16. Scalar edge = 1.0; @@ -446,7 +448,9 @@ fml::StatusOr MakeDownsampleSubpass( return pass.Draw().ok(); }; return renderer.MakeSubpass("Gaussian Blur Filter", pass_args.subpass_size, - command_buffer, subpass_callback); + command_buffer, subpass_callback, + /*msaa_enabled=*/false, + /*depth_stencil_enabled=*/false); } } @@ -511,8 +515,9 @@ fml::StatusOr MakeBlurSubpass( destination_target.value(), command_buffer, subpass_callback); } else { - return renderer.MakeSubpass("Gaussian Blur Filter", subpass_size, - command_buffer, subpass_callback); + return renderer.MakeSubpass( + "Gaussian Blur Filter", subpass_size, command_buffer, subpass_callback, + /*msaa_enabled=*/false, /*depth_stencil_enabled=*/false); } }