Skip to content

Commit 91b7617

Browse files
author
Jonah Williams
authored
[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.
1 parent 5122ffd commit 91b7617

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

engine/src/flutter/impeller/entity/contents/content_context.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ ContentContext::ContentContext(
307307
.primitive_type = PrimitiveType::kTriangleStrip,
308308
.color_attachment_pixel_format =
309309
context_->GetCapabilities()->GetDefaultColorFormat()};
310+
auto options_no_msaa_no_depth_stencil = ContentContextOptions{
311+
.sample_count = SampleCount::kCount1,
312+
.primitive_type = PrimitiveType::kTriangleStrip,
313+
.color_attachment_pixel_format =
314+
context_->GetCapabilities()->GetDefaultColorFormat(),
315+
.has_depth_stencil_attachments = false};
310316
const auto supports_decal = static_cast<Scalar>(
311317
context_->GetCapabilities()->SupportsDecalSamplerAddressMode());
312318

@@ -380,14 +386,14 @@ ContentContext::ContentContext(
380386
clip_pipelines_.SetDefault(
381387
options,
382388
std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
383-
texture_downsample_pipelines_.CreateDefault(*context_,
384-
options_trianglestrip);
389+
texture_downsample_pipelines_.CreateDefault(
390+
*context_, options_no_msaa_no_depth_stencil);
385391
rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
386392
texture_strict_src_pipelines_.CreateDefault(*context_, options);
387393
tiled_texture_pipelines_.CreateDefault(*context_, options,
388394
{supports_decal});
389-
gaussian_blur_pipelines_.CreateDefault(*context_, options_trianglestrip,
390-
{supports_decal});
395+
gaussian_blur_pipelines_.CreateDefault(
396+
*context_, options_no_msaa_no_depth_stencil, {supports_decal});
391397
border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip);
392398
color_matrix_color_filter_pipelines_.CreateDefault(*context_,
393399
options_trianglestrip);

engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
377377
return pass.Draw().ok();
378378
};
379379
return renderer.MakeSubpass("Gaussian Blur Filter", pass_args.subpass_size,
380-
command_buffer, subpass_callback);
380+
command_buffer, subpass_callback,
381+
/*msaa_enabled=*/false,
382+
/*depth_stencil_enabled=*/false);
381383
} else {
382384
// This assumes we don't scale below 1/16.
383385
Scalar edge = 1.0;
@@ -446,7 +448,9 @@ fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
446448
return pass.Draw().ok();
447449
};
448450
return renderer.MakeSubpass("Gaussian Blur Filter", pass_args.subpass_size,
449-
command_buffer, subpass_callback);
451+
command_buffer, subpass_callback,
452+
/*msaa_enabled=*/false,
453+
/*depth_stencil_enabled=*/false);
450454
}
451455
}
452456

@@ -511,8 +515,9 @@ fml::StatusOr<RenderTarget> MakeBlurSubpass(
511515
destination_target.value(), command_buffer,
512516
subpass_callback);
513517
} else {
514-
return renderer.MakeSubpass("Gaussian Blur Filter", subpass_size,
515-
command_buffer, subpass_callback);
518+
return renderer.MakeSubpass(
519+
"Gaussian Blur Filter", subpass_size, command_buffer, subpass_callback,
520+
/*msaa_enabled=*/false, /*depth_stencil_enabled=*/false);
516521
}
517522
}
518523

0 commit comments

Comments
 (0)