From 591196f04deb97d8e8749b74968fa2bc6ffea301 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 1 Mar 2023 15:09:23 -0800 Subject: [PATCH 1/2] [Impeller] Reland uniquely label offscreen resources (#39987)" (#39993)" This reverts commit f2499194c22dd4633d9291bd3e93a4badd648c29. --- impeller/entity/contents/content_context.cc | 10 ++++++---- impeller/entity/contents/content_context.h | 3 ++- impeller/entity/contents/contents.cc | 3 ++- .../entity/contents/filters/blend_filter_contents.cc | 8 ++++---- .../filters/border_mask_blur_filter_contents.cc | 4 ++-- .../contents/filters/color_matrix_filter_contents.cc | 5 ++--- .../contents/filters/gaussian_blur_filter_contents.cc | 4 ++-- .../contents/filters/linear_to_srgb_filter_contents.cc | 5 ++--- .../contents/filters/morphology_filter_contents.cc | 4 ++-- .../contents/filters/srgb_to_linear_filter_contents.cc | 5 ++--- .../contents/filters/yuv_to_rgb_filter_contents.cc | 5 ++--- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/impeller/entity/contents/content_context.cc b/impeller/entity/contents/content_context.cc index fda3198c86527..8ba65593034d5 100644 --- a/impeller/entity/contents/content_context.cc +++ b/impeller/entity/contents/content_context.cc @@ -7,6 +7,7 @@ #include #include +#include "impeller/base/strings.h" #include "impeller/entity/entity.h" #include "impeller/renderer/command_buffer.h" #include "impeller/renderer/formats.h" @@ -308,6 +309,7 @@ bool ContentContext::IsValid() const { } std::shared_ptr ContentContext::MakeSubpass( + const std::string& label, ISize texture_size, const SubpassCallback& subpass_callback, bool msaa_enabled) const { @@ -317,11 +319,11 @@ std::shared_ptr ContentContext::MakeSubpass( if (context->GetDeviceCapabilities().SupportsOffscreenMSAA() && msaa_enabled) { subpass_target = RenderTarget::CreateOffscreenMSAA( - *context, texture_size, "Contents Offscreen MSAA", + *context, texture_size, SPrintF("%s Offscreen", label.c_str()), RenderTarget::kDefaultColorAttachmentConfigMSAA, std::nullopt); } else { subpass_target = RenderTarget::CreateOffscreen( - *context, texture_size, "Contents Offscreen", + *context, texture_size, SPrintF("%s Offscreen", label.c_str()), RenderTarget::kDefaultColorAttachmentConfig, std::nullopt); } auto subpass_texture = subpass_target.GetRenderTargetTexture(); @@ -330,7 +332,7 @@ std::shared_ptr ContentContext::MakeSubpass( } auto sub_command_buffer = context->CreateCommandBuffer(); - sub_command_buffer->SetLabel("Offscreen Contents Command Buffer"); + sub_command_buffer->SetLabel(SPrintF("%s CommandBuffer", label.c_str())); if (!sub_command_buffer) { return nullptr; } @@ -339,7 +341,7 @@ std::shared_ptr ContentContext::MakeSubpass( if (!sub_renderpass) { return nullptr; } - sub_renderpass->SetLabel("OffscreenContentsPass"); + sub_renderpass->SetLabel(SPrintF("%s RenderPass", label.c_str())); if (!subpass_callback(*this, *sub_renderpass)) { return nullptr; diff --git a/impeller/entity/contents/content_context.h b/impeller/entity/contents/content_context.h index c5a57882eda59..d32cc41f9df86 100644 --- a/impeller/entity/contents/content_context.h +++ b/impeller/entity/contents/content_context.h @@ -603,7 +603,8 @@ class ContentContext { /// @brief Creates a new texture of size `texture_size` and calls /// `subpass_callback` with a `RenderPass` for drawing to the texture. - std::shared_ptr MakeSubpass(ISize texture_size, + std::shared_ptr MakeSubpass(const std::string& label, + ISize texture_size, const SubpassCallback& subpass_callback, bool msaa_enabled = true) const; diff --git a/impeller/entity/contents/contents.cc b/impeller/entity/contents/contents.cc index 965ade2a7e750..437454d97f9e7 100644 --- a/impeller/entity/contents/contents.cc +++ b/impeller/entity/contents/contents.cc @@ -6,6 +6,7 @@ #include #include "fml/logging.h" +#include "impeller/base/strings.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/texture_contents.h" #include "impeller/renderer/command_buffer.h" @@ -82,7 +83,7 @@ std::optional Contents::RenderToSnapshot( } auto texture = renderer.MakeSubpass( - ISize::Ceil(coverage->size), + "Snapshot", ISize::Ceil(coverage->size), [&contents = *this, &entity, &coverage](const ContentContext& renderer, RenderPass& pass) -> bool { Entity sub_entity; diff --git a/impeller/entity/contents/filters/blend_filter_contents.cc b/impeller/entity/contents/filters/blend_filter_contents.cc index e47d2200a5d36..55c4c84decfee 100644 --- a/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/impeller/entity/contents/filters/blend_filter_contents.cc @@ -150,11 +150,11 @@ static std::optional AdvancedBlend( return true; }; - auto out_texture = renderer.MakeSubpass(ISize(coverage.size), callback); + auto out_texture = renderer.MakeSubpass("Advanced Blend Filter", + ISize(coverage.size), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("Advanced Blend Filter Texture"); return Contents::EntityFromSnapshot( Snapshot{.texture = out_texture, @@ -274,11 +274,11 @@ static std::optional PipelineBlend( return true; }; - auto out_texture = renderer.MakeSubpass(ISize(coverage.size), callback); + auto out_texture = renderer.MakeSubpass("Pipeline Blend Filter", + ISize(coverage.size), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("Pipeline Blend Filter Texture"); return Contents::EntityFromSnapshot( Snapshot{.texture = out_texture, diff --git a/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc b/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc index 94d3642fff0f0..9880e24e2547d 100644 --- a/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/border_mask_blur_filter_contents.cc @@ -122,11 +122,11 @@ std::optional BorderMaskBlurFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = renderer.MakeSubpass(ISize(coverage.size), callback); + auto out_texture = renderer.MakeSubpass("Border Mask Blur Filter", + ISize(coverage.size), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("BorderMaskBlurFilter Texture"); return Contents::EntityFromSnapshot( Snapshot{.texture = out_texture, diff --git a/impeller/entity/contents/filters/color_matrix_filter_contents.cc b/impeller/entity/contents/filters/color_matrix_filter_contents.cc index b0a0df6934cb7..e3aa364505a53 100644 --- a/impeller/entity/contents/filters/color_matrix_filter_contents.cc +++ b/impeller/entity/contents/filters/color_matrix_filter_contents.cc @@ -97,12 +97,11 @@ std::optional ColorMatrixFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = - renderer.MakeSubpass(input_snapshot->texture->GetSize(), callback); + auto out_texture = renderer.MakeSubpass( + "Color Matrix Filter", input_snapshot->texture->GetSize(), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("ColorMatrixFilter Texture"); return Contents::EntityFromSnapshot( Snapshot{.texture = out_texture, diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 87cecd9996816..29543df5aa80c 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -276,12 +276,12 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( Vector2 scaled_size = pass_texture_rect.size * scale; ISize floored_size = ISize(scaled_size.x, scaled_size.y); - auto out_texture = renderer.MakeSubpass(floored_size, callback); + auto out_texture = renderer.MakeSubpass("Directional Gaussian Blur Filter", + floored_size, callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("DirectionalGaussianBlurFilter Texture"); SamplerDescriptor sampler_desc; sampler_desc.min_filter = MinMagFilter::kLinear; diff --git a/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc b/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc index 83ddd54bce119..c21585f9e3419 100644 --- a/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc +++ b/impeller/entity/contents/filters/linear_to_srgb_filter_contents.cc @@ -74,12 +74,11 @@ std::optional LinearToSrgbFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = - renderer.MakeSubpass(input_snapshot->texture->GetSize(), callback); + auto out_texture = renderer.MakeSubpass( + "Linear to sRGB Filter", input_snapshot->texture->GetSize(), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("LinearToSrgb Texture"); return Contents::EntityFromSnapshot( Snapshot{.texture = out_texture, diff --git a/impeller/entity/contents/filters/morphology_filter_contents.cc b/impeller/entity/contents/filters/morphology_filter_contents.cc index 4fa9e34016ff8..ca49965856071 100644 --- a/impeller/entity/contents/filters/morphology_filter_contents.cc +++ b/impeller/entity/contents/filters/morphology_filter_contents.cc @@ -132,11 +132,11 @@ std::optional DirectionalMorphologyFilterContents::RenderFilter( return pass.AddCommand(cmd); }; - auto out_texture = renderer.MakeSubpass(ISize(coverage.size), callback); + auto out_texture = renderer.MakeSubpass("Directional Morphology Filter", + ISize(coverage.size), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("DirectionalMorphologyFilter Texture"); SamplerDescriptor sampler_desc; sampler_desc.min_filter = MinMagFilter::kLinear; diff --git a/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc b/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc index 954522edca0fb..675143abef432 100644 --- a/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc +++ b/impeller/entity/contents/filters/srgb_to_linear_filter_contents.cc @@ -74,12 +74,11 @@ std::optional SrgbToLinearFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = - renderer.MakeSubpass(input_snapshot->texture->GetSize(), callback); + auto out_texture = renderer.MakeSubpass( + "sRGB to Linear Filter", input_snapshot->texture->GetSize(), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("SrgbToLinear Texture"); return Contents::EntityFromSnapshot( Snapshot{.texture = out_texture, diff --git a/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc b/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc index 4ad85582e84ee..2428f0ad66072 100644 --- a/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc +++ b/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc @@ -111,12 +111,11 @@ std::optional YUVToRGBFilterContents::RenderFilter( return pass.AddCommand(std::move(cmd)); }; - auto out_texture = - renderer.MakeSubpass(y_input_snapshot->texture->GetSize(), callback); + auto out_texture = renderer.MakeSubpass( + "YUV to RGB Filter", y_input_snapshot->texture->GetSize(), callback); if (!out_texture) { return std::nullopt; } - out_texture->SetLabel("YUVToRGB Texture"); return Contents::EntityFromSnapshot(Snapshot{.texture = out_texture}, entity.GetBlendMode(), From abf52f43be885be169f78d2747e3cd5c021abaa4 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 1 Mar 2023 15:15:25 -0800 Subject: [PATCH 2/2] Add atlas blend label --- impeller/entity/contents/atlas_contents.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impeller/entity/contents/atlas_contents.cc b/impeller/entity/contents/atlas_contents.cc index 99ba234362059..cb636e89fb4d2 100644 --- a/impeller/entity/contents/atlas_contents.cc +++ b/impeller/entity/contents/atlas_contents.cc @@ -226,7 +226,8 @@ bool AtlasContents::Render(const ContentContext& renderer, #ifdef FML_OS_PHYSICAL_IOS auto new_texture = renderer.MakeSubpass( - sub_atlas->size, [&](const ContentContext& context, RenderPass& pass) { + "Atlas Blend", sub_atlas->size, + [&](const ContentContext& context, RenderPass& pass) { Entity entity; entity.SetContents(dst_contents); entity.SetBlendMode(BlendMode::kSource);