From a5161bc8297428d9402fae6a18315d04aa331025 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 09:27:37 -0800 Subject: [PATCH 01/11] [Impeller] made the mipmap generation work for imagefilters --- impeller/aiks/aiks_unittests.cc | 24 +++++++++++++++++++ impeller/aiks/canvas.cc | 8 +++++++ .../contents/filters/filter_contents.cc | 2 ++ impeller/entity/entity_pass.cc | 14 ++--------- impeller/entity/entity_pass.h | 4 ---- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 3858ff0dca914..46a369940c028 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3820,5 +3820,29 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { EXPECT_EQ(max_mip_count, 1lu); } +TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { + Canvas canvas; + canvas.SaveLayer( + {.image_filter = ImageFilter::MakeBlur(Sigma(30), Sigma(30), + FilterContents::BlurStyle::kNormal, + Entity::TileMode::kClamp)}); + canvas.DrawCircle({200, 200}, 50, {.color = Color::Chartreuse()}); + + Picture picture = canvas.EndRecordingAsPicture(); + // ASSERT_TRUE(OpenPlaygroundHere(std::move(picture))); + std::shared_ptr cache = + std::make_shared(GetContext()->GetResourceAllocator()); + AiksContext aiks_context(GetContext(), nullptr, cache); + picture.ToImage(aiks_context, {1024, 768}); + + size_t max_mip_count = 0; + for (auto it = cache->GetTextureDataBegin(); it != cache->GetTextureDataEnd(); + ++it) { + max_mip_count = + std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); + } + EXPECT_EQ(max_mip_count, 4lu); +} + } // namespace testing } // namespace impeller diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc index f66da9a914cbf..29795af0253f7 100644 --- a/impeller/aiks/canvas.cc +++ b/impeller/aiks/canvas.cc @@ -725,6 +725,14 @@ void Canvas::SaveLayer(const Paint& paint, auto& new_layer_pass = GetCurrentPass(); new_layer_pass.SetBoundsLimit(bounds); + if (paint.image_filter) { + MipCountVisitor mip_count_visitor; + paint.image_filter->Visit(mip_count_visitor); + new_layer_pass.SetRequiredMipCount( + std::max(mip_count_visitor.GetRequiredMipCount(), + new_layer_pass.GetRequiredMipCount())); + } + // Only apply opacity peephole on default blending. if (paint.blend_mode == BlendMode::kSourceOver) { new_layer_pass.SetDelegate( diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index 235a53134c5e3..a9acd5ffd697d 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -50,6 +50,8 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( return blur; } +#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1 + #ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER const int32_t FilterContents::kBlurFilterRequiredMipCount = 4; #else diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index dec9a98b15ed7..4dcd8c5d0563e 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -344,7 +344,7 @@ bool EntityPass::Render(ContentContext& renderer, if (reads_from_onscreen_backdrop) { EntityPassTarget offscreen_target = CreateRenderTarget( renderer, root_render_target.GetRenderTargetSize(), - GetBackdropFilterMipCount(), + GetRequiredMipCount(), GetClearColorOrDefault(render_target.GetRenderTargetSize())); if (!OnRender(renderer, // renderer @@ -606,7 +606,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement( auto subpass_target = CreateRenderTarget( renderer, // renderer subpass_size, // size - subpass->GetBackdropFilterMipCount(), + subpass->GetRequiredMipCount(), subpass->GetClearColorOrDefault(subpass_size)); // clear_color if (!subpass_target.IsValid()) { @@ -1191,16 +1191,6 @@ void EntityPass::SetEnableOffscreenCheckerboard(bool enabled) { enable_offscreen_debug_checkerboard_ = enabled; } -int32_t EntityPass::GetBackdropFilterMipCount() const { - int32_t result = 1; - for (auto& element : elements_) { - if (auto subpass = std::get_if>(&element)) { - result = std::max(result, subpass->get()->GetRequiredMipCount()); - } - } - return result; -} - EntityPassClipRecorder::EntityPassClipRecorder() {} void EntityPassClipRecorder::RecordEntity(const Entity& entity, diff --git a/impeller/entity/entity_pass.h b/impeller/entity/entity_pass.h index cacf45776c029..7de68d0d9ad11 100644 --- a/impeller/entity/entity_pass.h +++ b/impeller/entity/entity_pass.h @@ -157,10 +157,6 @@ class EntityPass { required_mip_count_ = mip_count; } - /// Returns the mip map count that should be required for the render target - /// receiving this EntityPass. - int32_t GetBackdropFilterMipCount() const; - //---------------------------------------------------------------------------- /// @brief Computes the coverage of a given subpass. This is used to /// determine the texture size of a given subpass before it's rendered From f74684ae3ad86fc04c07423311ef59da64f73ead Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 09:29:24 -0800 Subject: [PATCH 02/11] tested everything with the filter on --- impeller/aiks/aiks_unittests.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 46a369940c028..6e6c241b937d0 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3767,7 +3767,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { return true; }); - EXPECT_EQ(1, max_mip_count); + EXPECT_EQ(4, max_mip_count); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { @@ -3791,7 +3791,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { @@ -3817,7 +3817,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); } TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { From b2f1c6987af70555b3b4ea7e7badfd8b053ec5d6 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 09:29:55 -0800 Subject: [PATCH 03/11] turned filter off --- impeller/aiks/aiks_unittests.cc | 8 ++++---- impeller/entity/contents/filters/filter_contents.cc | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 6e6c241b937d0..cecbeef831536 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3767,7 +3767,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { return true; }); - EXPECT_EQ(4, max_mip_count); + EXPECT_EQ(1, max_mip_count); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { @@ -3791,7 +3791,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { @@ -3817,7 +3817,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); } TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { @@ -3841,7 +3841,7 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); } } // namespace testing diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index a9acd5ffd697d..235a53134c5e3 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -50,8 +50,6 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( return blur; } -#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1 - #ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER const int32_t FilterContents::kBlurFilterRequiredMipCount = 4; #else From d6cbe11e5cc606171945a46fbc810732e6aef8d3 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 12:19:13 -0800 Subject: [PATCH 04/11] removed comment --- impeller/aiks/aiks_unittests.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index cecbeef831536..48dc5a556706c 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3829,7 +3829,6 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { canvas.DrawCircle({200, 200}, 50, {.color = Color::Chartreuse()}); Picture picture = canvas.EndRecordingAsPicture(); - // ASSERT_TRUE(OpenPlaygroundHere(std::move(picture))); std::shared_ptr cache = std::make_shared(GetContext()->GetResourceAllocator()); AiksContext aiks_context(GetContext(), nullptr, cache); From 768fbdc8b75abf344b6404ea8c662d4cc7239e5e Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 13:16:51 -0800 Subject: [PATCH 05/11] Revert "turned filter off" This reverts commit b2f1c6987af70555b3b4ea7e7badfd8b053ec5d6. --- impeller/aiks/aiks_unittests.cc | 8 ++++---- impeller/entity/contents/filters/filter_contents.cc | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 48dc5a556706c..f860aa83576b1 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3767,7 +3767,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { return true; }); - EXPECT_EQ(1, max_mip_count); + EXPECT_EQ(4, max_mip_count); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { @@ -3791,7 +3791,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { @@ -3817,7 +3817,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); } TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { @@ -3840,7 +3840,7 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); } } // namespace testing diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index 235a53134c5e3..a9acd5ffd697d 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -50,6 +50,8 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( return blur; } +#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1 + #ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER const int32_t FilterContents::kBlurFilterRequiredMipCount = 4; #else From 068fbfc8e8f0e294d7b3022a14fff7da61039e0a Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 13:43:03 -0800 Subject: [PATCH 06/11] added check for no mips --- impeller/aiks/aiks_unittests.cc | 7 +++++++ impeller/aiks/canvas.cc | 3 +++ .../contents/filters/gaussian_blur_filter_contents.cc | 5 ++++- .../contents/filters/gaussian_blur_filter_contents.h | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index f860aa83576b1..a6b450ebd7c54 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -22,6 +22,7 @@ #include "impeller/aiks/testing/context_spy.h" #include "impeller/core/capture.h" #include "impeller/entity/contents/conical_gradient_contents.h" +#include "impeller/entity/contents/filters/gaussian_blur_filter_contents.h" #include "impeller/entity/contents/filters/inputs/filter_input.h" #include "impeller/entity/contents/linear_gradient_contents.h" #include "impeller/entity/contents/radial_gradient_contents.h" @@ -3795,6 +3796,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { + fml::testing::LogCapture log_capture; Canvas canvas; canvas.DrawPaint({.color = Color::Wheat()}); canvas.SaveLayer({.blend_mode = BlendMode::kMultiply}); @@ -3818,9 +3820,12 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), + std::string::npos); } TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { + fml::testing::LogCapture log_capture; Canvas canvas; canvas.SaveLayer( {.image_filter = ImageFilter::MakeBlur(Sigma(30), Sigma(30), @@ -3841,6 +3846,8 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), + std::string::npos); } } // namespace testing diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc index 29795af0253f7..ce7029b4dccd3 100644 --- a/impeller/aiks/canvas.cc +++ b/impeller/aiks/canvas.cc @@ -190,6 +190,9 @@ void Canvas::Save(bool create_subpass, MipCountVisitor mip_count_visitor; backdrop_filter->Visit(mip_count_visitor); subpass->SetRequiredMipCount(mip_count_visitor.GetRequiredMipCount()); + current_pass_->SetRequiredMipCount( + std::max(current_pass_->GetRequiredMipCount(), + mip_count_visitor.GetRequiredMipCount())); } subpass->SetBlendMode(blend_mode); current_pass_ = GetCurrentPass().AddSubpass(std::move(subpass)); diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 13610bd184190..a58d8b26a56a8 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -189,6 +189,9 @@ Rect MakeReferenceUVs(const Rect& reference, const Rect& rect) { } } // namespace +std::string_view GaussianBlurFilterContents::kNoMipsError = + "Applying gaussian blur without mipmap."; + GaussianBlurFilterContents::GaussianBlurFilterContents( Scalar sigma_x, Scalar sigma_y, @@ -280,7 +283,7 @@ std::optional GaussianBlurFilterContents::RenderFilter( // In order to avoid shimmering in downsampling step, we should have mips. if (input_snapshot->texture->GetMipCount() <= 1) { - FML_DLOG(ERROR) << "Applying gaussian blur without mipmap."; + FML_DLOG(ERROR) << kNoMipsError; } FML_DCHECK(!input_snapshot->texture->NeedsMipmapGeneration()); diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.h b/impeller/entity/contents/filters/gaussian_blur_filter_contents.h index 1bb594f3e4ae6..4473318698df6 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.h +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.h @@ -27,6 +27,8 @@ KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo( /// Note: This will replace `DirectionalGaussianBlurFilterContents`. class GaussianBlurFilterContents final : public FilterContents { public: + static std::string_view kNoMipsError; + explicit GaussianBlurFilterContents(Scalar sigma_x, Scalar sigma_y, Entity::TileMode tile_mode); From 4ae792950d34ff7695a3d061664d2dee5a6788b4 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 13:44:54 -0800 Subject: [PATCH 07/11] removed the filter again --- impeller/aiks/aiks_unittests.cc | 8 ++++---- impeller/entity/contents/filters/filter_contents.cc | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index a6b450ebd7c54..a33d9bceae203 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3768,7 +3768,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { return true; }); - EXPECT_EQ(4, max_mip_count); + EXPECT_EQ(1, max_mip_count); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { @@ -3792,7 +3792,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { @@ -3819,7 +3819,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), std::string::npos); } @@ -3845,7 +3845,7 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), std::string::npos); } diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index a9acd5ffd697d..235a53134c5e3 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -50,8 +50,6 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( return blur; } -#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1 - #ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER const int32_t FilterContents::kBlurFilterRequiredMipCount = 4; #else From ce3aeeba07f12eb07c1bad3ad6167747e5d1424c Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 14:12:16 -0800 Subject: [PATCH 08/11] Revert "removed the filter again" This reverts commit 4ae792950d34ff7695a3d061664d2dee5a6788b4. --- impeller/aiks/aiks_unittests.cc | 8 ++++---- impeller/entity/contents/filters/filter_contents.cc | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index a33d9bceae203..a6b450ebd7c54 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3768,7 +3768,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { return true; }); - EXPECT_EQ(1, max_mip_count); + EXPECT_EQ(4, max_mip_count); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { @@ -3792,7 +3792,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { @@ -3819,7 +3819,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), std::string::npos); } @@ -3845,7 +3845,7 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 1lu); + EXPECT_EQ(max_mip_count, 4lu); EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), std::string::npos); } diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index 235a53134c5e3..a9acd5ffd697d 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -50,6 +50,8 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( return blur; } +#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1 + #ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER const int32_t FilterContents::kBlurFilterRequiredMipCount = 4; #else From 2c93439e6c1121f2508dc45f99b973fea8796636 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 14:15:54 -0800 Subject: [PATCH 09/11] removed setting of mipcount on subpass --- impeller/aiks/aiks_unittests.cc | 12 +----------- impeller/aiks/canvas.cc | 5 +---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index a6b450ebd7c54..7b7b36d03da49 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3758,17 +3758,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { canvas.Restore(); Picture picture = canvas.EndRecordingAsPicture(); - - int32_t max_mip_count = 0; - picture.pass->IterateAllElements([&](EntityPass::Element& element) -> bool { - if (auto subpass = std::get_if>(&element)) { - max_mip_count = - std::max(max_mip_count, subpass->get()->GetRequiredMipCount()); - } - return true; - }); - - EXPECT_EQ(4, max_mip_count); + EXPECT_EQ(4, picture.pass->GetRequiredMipCount()); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc index ce7029b4dccd3..a0d8f616bdbbf 100644 --- a/impeller/aiks/canvas.cc +++ b/impeller/aiks/canvas.cc @@ -189,7 +189,6 @@ void Canvas::Save(bool create_subpass, subpass->SetBackdropFilter(backdrop_filter_proc); MipCountVisitor mip_count_visitor; backdrop_filter->Visit(mip_count_visitor); - subpass->SetRequiredMipCount(mip_count_visitor.GetRequiredMipCount()); current_pass_->SetRequiredMipCount( std::max(current_pass_->GetRequiredMipCount(), mip_count_visitor.GetRequiredMipCount())); @@ -731,9 +730,7 @@ void Canvas::SaveLayer(const Paint& paint, if (paint.image_filter) { MipCountVisitor mip_count_visitor; paint.image_filter->Visit(mip_count_visitor); - new_layer_pass.SetRequiredMipCount( - std::max(mip_count_visitor.GetRequiredMipCount(), - new_layer_pass.GetRequiredMipCount())); + new_layer_pass.SetRequiredMipCount(mip_count_visitor.GetRequiredMipCount()); } // Only apply opacity peephole on default blending. From b128c282863cc1a471e8b27a624731c402061f7f Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 14:16:27 -0800 Subject: [PATCH 10/11] Reapply "removed the filter again" This reverts commit ce3aeeba07f12eb07c1bad3ad6167747e5d1424c. --- impeller/aiks/aiks_unittests.cc | 6 +++--- impeller/entity/contents/filters/filter_contents.cc | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 7b7b36d03da49..7bf8cc6a1ef23 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3782,7 +3782,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); } TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { @@ -3809,7 +3809,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), std::string::npos); } @@ -3835,7 +3835,7 @@ TEST_P(AiksTest, GaussianBlurMipMapImageFilter) { max_mip_count = std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count); } - EXPECT_EQ(max_mip_count, 4lu); + EXPECT_EQ(max_mip_count, 1lu); EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError), std::string::npos); } diff --git a/impeller/entity/contents/filters/filter_contents.cc b/impeller/entity/contents/filters/filter_contents.cc index a9acd5ffd697d..235a53134c5e3 100644 --- a/impeller/entity/contents/filters/filter_contents.cc +++ b/impeller/entity/contents/filters/filter_contents.cc @@ -50,8 +50,6 @@ std::shared_ptr FilterContents::MakeDirectionalGaussianBlur( return blur; } -#define IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER 1 - #ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER const int32_t FilterContents::kBlurFilterRequiredMipCount = 4; #else From 659a0c55bda7e62543144dd60747447a946e5c58 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 16 Jan 2024 14:17:30 -0800 Subject: [PATCH 11/11] fix bad merge --- impeller/aiks/aiks_unittests.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 7bf8cc6a1ef23..03cf5495b6b86 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -3758,7 +3758,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) { canvas.Restore(); Picture picture = canvas.EndRecordingAsPicture(); - EXPECT_EQ(4, picture.pass->GetRequiredMipCount()); + EXPECT_EQ(1, picture.pass->GetRequiredMipCount()); } TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) {