From 4915acf45c16ae88ca8657f164c986c532b0fd5e Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 22 Jun 2023 08:42:30 -0700 Subject: [PATCH 1/2] [Impeller] default sample count back to 1 (but configure to 4 in defaults) --- impeller/aiks/picture.cc | 18 ++++++++++++------ impeller/entity/contents/content_context.cc | 18 +++++++++++++++--- impeller/entity/contents/content_context.h | 2 +- impeller/renderer/pipeline_descriptor.h | 2 +- impeller/renderer/render_target.cc | 10 ++++++++++ 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/impeller/aiks/picture.cc b/impeller/aiks/picture.cc index 2f696a104c301..cb643b671ed43 100644 --- a/impeller/aiks/picture.cc +++ b/impeller/aiks/picture.cc @@ -61,16 +61,22 @@ std::shared_ptr Picture::RenderToTexture( size, // size "Picture Snapshot MSAA", // label RenderTarget:: - kDefaultColorAttachmentConfigMSAA, // color_attachment_config - std::nullopt // stencil_attachment_config + kDefaultColorAttachmentConfigMSAA // color_attachment_config +#ifndef FML_OS_ANDROID + , + std::nullopt // stencil_attachment_config +#endif // FML_OS_ANDROID ); } else { target = RenderTarget::CreateOffscreen( - *impeller_context, // context - size, // size - "Picture Snapshot", // label - RenderTarget::kDefaultColorAttachmentConfig, // color_attachment_config + *impeller_context, // context + size, // size + "Picture Snapshot", // label + RenderTarget::kDefaultColorAttachmentConfig // color_attachment_config +#ifndef FML_OS_ANDROID + , std::nullopt // stencil_attachment_config +#endif // FML_OS_ANDROID ); } if (!target.IsValid()) { diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index 00b06716e26f9..af4fd53b4731a 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -151,7 +151,8 @@ static std::unique_ptr CreateDefaultPipeline( // Apply default ContentContextOptions to the descriptor. const auto default_color_fmt = context.GetCapabilities()->GetDefaultColorFormat(); - ContentContextOptions{.color_attachment_pixel_format = default_color_fmt} + ContentContextOptions{.sample_count = SampleCount::kCount4, + .color_attachment_pixel_format = default_color_fmt} .ApplyToPipelineDescriptor(*desc); return std::make_unique(context, desc); } @@ -166,6 +167,7 @@ ContentContext::ContentContext(std::shared_ptr context) return; } default_options_ = ContentContextOptions{ + .sample_count = SampleCount::kCount4, .color_attachment_pixel_format = context_->GetCapabilities()->GetDefaultColorFormat()}; @@ -352,11 +354,21 @@ std::shared_ptr ContentContext::MakeSubpass( if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) { subpass_target = RenderTarget::CreateOffscreenMSAA( *context, texture_size, SPrintF("%s Offscreen", label.c_str()), - RenderTarget::kDefaultColorAttachmentConfigMSAA, std::nullopt); + RenderTarget::kDefaultColorAttachmentConfigMSAA // +#ifndef FML_OS_ANDROID + , + std::nullopt // stencil_attachment_config +#endif // FML_OS_ANDROID + ); } else { subpass_target = RenderTarget::CreateOffscreen( *context, texture_size, SPrintF("%s Offscreen", label.c_str()), - RenderTarget::kDefaultColorAttachmentConfig, std::nullopt); + RenderTarget::kDefaultColorAttachmentConfig // +#ifndef FML_OS_ANDROID + , + std::nullopt // stencil_attachment_config +#endif // FML_OS_ANDROID + ); } auto subpass_texture = subpass_target.GetRenderTargetTexture(); if (!subpass_texture) { diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index 046315f609e0f..d2e1a16c8f92c 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -291,7 +291,7 @@ using UvComputeShaderPipeline = ComputePipelineBuilder; /// Flutter application may easily require building hundreds of PSOs in total, /// but they shouldn't require e.g. 10s of thousands. struct ContentContextOptions { - SampleCount sample_count = SampleCount::kCount4; + SampleCount sample_count = SampleCount::kCount1; BlendMode blend_mode = BlendMode::kSourceOver; CompareFunction stencil_compare = CompareFunction::kEqual; StencilOperation stencil_operation = StencilOperation::kKeep; diff --git a/impeller/renderer/pipeline_descriptor.h b/impeller/renderer/pipeline_descriptor.h index 599a615c186af..3d0eddf880e28 100644 --- a/impeller/renderer/pipeline_descriptor.h +++ b/impeller/renderer/pipeline_descriptor.h @@ -133,7 +133,7 @@ class PipelineDescriptor final : public Comparable { private: std::string label_; - SampleCount sample_count_ = SampleCount::kCount4; + SampleCount sample_count_ = SampleCount::kCount1; WindingOrder winding_order_ = WindingOrder::kClockwise; CullMode cull_mode_ = CullMode::kNone; std::map> entrypoints_; diff --git a/impeller/renderer/render_target.cc b/impeller/renderer/render_target.cc index 67c18d95386e6..47ade6e242b9f 100644 --- a/impeller/renderer/render_target.cc +++ b/impeller/renderer/render_target.cc @@ -217,6 +217,11 @@ RenderTarget RenderTarget::CreateOffscreen( return {}; } +// Dont force additional PSO variants on Vulkan. +#ifdef FML_OS_ANDROID + FML_DCHECK(stencil_attachment_config.has_value()); +#endif // FML_OS_ANDROID + RenderTarget target; PixelFormat pixel_format = context.GetCapabilities()->GetDefaultColorFormat(); TextureDescriptor color_tex0; @@ -258,6 +263,11 @@ RenderTarget RenderTarget::CreateOffscreenMSAA( return {}; } +// Dont force additional PSO variants on Vulkan. +#ifdef FML_OS_ANDROID + FML_DCHECK(stencil_attachment_config.has_value()); +#endif // FML_OS_ANDROID + RenderTarget target; PixelFormat pixel_format = context.GetCapabilities()->GetDefaultColorFormat(); From 090731484eb36c586f4195b1db1646cc89f9d722 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 22 Jun 2023 09:54:41 -0700 Subject: [PATCH 2/2] add more comments. --- impeller/aiks/picture.cc | 4 ++-- impeller/entity/contents/content_context.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/impeller/aiks/picture.cc b/impeller/aiks/picture.cc index cb643b671ed43..7ad91fb63ef0c 100644 --- a/impeller/aiks/picture.cc +++ b/impeller/aiks/picture.cc @@ -62,7 +62,7 @@ std::shared_ptr Picture::RenderToTexture( "Picture Snapshot MSAA", // label RenderTarget:: kDefaultColorAttachmentConfigMSAA // color_attachment_config -#ifndef FML_OS_ANDROID +#ifndef FML_OS_ANDROID // Reduce PSO variants for Vulkan. , std::nullopt // stencil_attachment_config #endif // FML_OS_ANDROID @@ -73,7 +73,7 @@ std::shared_ptr Picture::RenderToTexture( size, // size "Picture Snapshot", // label RenderTarget::kDefaultColorAttachmentConfig // color_attachment_config -#ifndef FML_OS_ANDROID +#ifndef FML_OS_ANDROID // Reduce PSO variants for Vulkan. , std::nullopt // stencil_attachment_config #endif // FML_OS_ANDROID diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index af4fd53b4731a..18e2a50367600 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -355,7 +355,7 @@ std::shared_ptr ContentContext::MakeSubpass( subpass_target = RenderTarget::CreateOffscreenMSAA( *context, texture_size, SPrintF("%s Offscreen", label.c_str()), RenderTarget::kDefaultColorAttachmentConfigMSAA // -#ifndef FML_OS_ANDROID +#ifndef FML_OS_ANDROID // Reduce PSO variants for Vulkan. , std::nullopt // stencil_attachment_config #endif // FML_OS_ANDROID @@ -364,7 +364,7 @@ std::shared_ptr ContentContext::MakeSubpass( subpass_target = RenderTarget::CreateOffscreen( *context, texture_size, SPrintF("%s Offscreen", label.c_str()), RenderTarget::kDefaultColorAttachmentConfig // -#ifndef FML_OS_ANDROID +#ifndef FML_OS_ANDROID // Reduce PSO variants for Vulkan. , std::nullopt // stencil_attachment_config #endif // FML_OS_ANDROID