From e433a333f35fb60b31fdc793ed99ec5ef3b9e94d Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Sun, 5 Nov 2023 19:38:10 -0800 Subject: [PATCH 1/3] ++ --- impeller/BUILD.gn | 1 - impeller/core/texture.h | 1 - impeller/entity/BUILD.gn | 13 +-- impeller/entity/entity_pass.cc | 5 +- impeller/entity/entity_pass_target.cc | 11 ++- .../entity/entity_pass_target_unittests.cc | 87 +++++++++++++++++++ 6 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 impeller/entity/entity_pass_target_unittests.cc diff --git a/impeller/BUILD.gn b/impeller/BUILD.gn index 3df283d93de75..2eaab0e2b76a8 100644 --- a/impeller/BUILD.gn +++ b/impeller/BUILD.gn @@ -98,7 +98,6 @@ impeller_component("impeller_unittests") { "aiks:aiks_unittests", "display_list:display_list_unittests", "entity:entity_unittests", - "entity:render_target_cache_unittests", "fixtures", "geometry:geometry_unittests", "image:image_unittests", diff --git a/impeller/core/texture.h b/impeller/core/texture.h index 95b21876afd97..8c6e3238b6448 100644 --- a/impeller/core/texture.h +++ b/impeller/core/texture.h @@ -6,7 +6,6 @@ #include -#include "flutter/fml/macros.h" #include "flutter/fml/mapping.h" #include "impeller/core/formats.h" #include "impeller/core/texture_descriptor.h" diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index 3ad9b09136979..6fc8e89c76040 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -274,6 +274,8 @@ impeller_component("entity_unittests") { "entity_playground.h", "entity_unittests.cc", "geometry/geometry_unittests.cc", + "render_target_cache_unittests.cc", + "entity_pass_target_unittests.cc", ] deps = [ @@ -283,14 +285,3 @@ impeller_component("entity_unittests") { "//flutter/impeller/typographer/backends/skia:typographer_skia_backend", ] } - -impeller_component("render_target_cache_unittests") { - testonly = true - - sources = [ "render_target_cache_unittests.cc" ] - - deps = [ - ":entity", - "//flutter/testing:testing_lib", - ] -} diff --git a/impeller/entity/entity_pass.cc b/impeller/entity/entity_pass.cc index f37bb4d4c1c3e..92cad9ad3f954 100644 --- a/impeller/entity/entity_pass.cc +++ b/impeller/entity/entity_pass.cc @@ -397,7 +397,10 @@ bool EntityPass::Render(ContentContext& renderer, entity.SetContents(contents); entity.SetBlendMode(BlendMode::kSource); - entity.Render(renderer, *render_pass); + if (!entity.Render(renderer, *render_pass)) { + VALIDATION_LOG << "Failed to render EntityPass root blit."; + return false; + } } if (!render_pass->EncodeCommands()) { diff --git a/impeller/entity/entity_pass_target.cc b/impeller/entity/entity_pass_target.cc index 46e7e47b4ffb3..6ba7f20335f3d 100644 --- a/impeller/entity/entity_pass_target.cc +++ b/impeller/entity/entity_pass_target.cc @@ -45,7 +45,16 @@ std::shared_ptr EntityPassTarget::Flip(Allocator& allocator) { } } - std::swap(color0.resolve_texture, secondary_color_texture_); + // If the color0 resolve texture is the same as the texture, then we're running + // on the GLES backend with implicit resolve. + if (color0.resolve_texture == color0.texture) { + auto new_secondary = color0.resolve_texture; + color0.resolve_texture = secondary_color_texture_; + color0.texture = secondary_color_texture_; + secondary_color_texture_ = new_secondary; + } else { + std::swap(color0.resolve_texture, secondary_color_texture_); + } target_.SetColorAttachment(color0, 0); diff --git a/impeller/entity/entity_pass_target_unittests.cc b/impeller/entity/entity_pass_target_unittests.cc new file mode 100644 index 0000000000000..ad0c1b2d53069 --- /dev/null +++ b/impeller/entity/entity_pass_target_unittests.cc @@ -0,0 +1,87 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +#include "flutter/testing/testing.h" +#include "gtest/gtest.h" +#include "impeller/entity/entity_pass_target.h" +#include "impeller/entity/entity_playground.h" + +namespace impeller { +namespace testing { + +using EntityPassTargetTest = EntityPlayground; +INSTANTIATE_PLAYGROUND_SUITE(EntityPassTargetTest); + +TEST_P(EntityPassTargetTest, SwapWithMSAATexture) { + if (GetContentContext() + ->GetDeviceCapabilities() + .SupportsImplicitResolvingMSAA()) { + GTEST_SKIP() << "Implicit MSAA is used on this device."; + } + auto content_context = GetContentContext(); + auto buffer = content_context->GetContext()->CreateCommandBuffer(); + auto render_target = RenderTarget::CreateOffscreenMSAA( + *content_context->GetContext(), + *GetContentContext()->GetRenderTargetCache(), {100, 100}); + + auto entity_pass_target = EntityPassTarget(render_target, false); + + auto color0 = entity_pass_target.GetRenderTarget() + .GetColorAttachments() + .find(0u) + ->second; + auto msaa_tex = color0.texture; + auto resolve_tex = color0.resolve_texture; + + entity_pass_target.Flip( + *content_context->GetContext()->GetResourceAllocator()); + + color0 = entity_pass_target.GetRenderTarget() + .GetColorAttachments() + .find(0u) + ->second; + + ASSERT_EQ(msaa_tex, color0.texture); + ASSERT_NE(resolve_tex, color0.resolve_texture); +} + +TEST_P(EntityPassTargetTest, SwapWithMSAAImplicitResolve) { + if (!GetContentContext() + ->GetDeviceCapabilities() + .SupportsImplicitResolvingMSAA()) { + GTEST_SKIP() << "Implicit MSAA is not used on this device."; + } + auto content_context = GetContentContext(); + auto buffer = content_context->GetContext()->CreateCommandBuffer(); + auto render_target = RenderTarget::CreateOffscreenMSAA( + *content_context->GetContext(), + *GetContentContext()->GetRenderTargetCache(), {100, 100}); + + auto entity_pass_target = EntityPassTarget(render_target, false); + + auto color0 = entity_pass_target.GetRenderTarget() + .GetColorAttachments() + .find(0u) + ->second; + auto msaa_tex = color0.texture; + auto resolve_tex = color0.resolve_texture; + + ASSERT_EQ(msaa_tex, resolve_tex); + + entity_pass_target.Flip( + *content_context->GetContext()->GetResourceAllocator()); + + color0 = entity_pass_target.GetRenderTarget() + .GetColorAttachments() + .find(0u) + ->second; + + ASSERT_EQ(msaa_tex, color0.texture); + ASSERT_NE(resolve_tex, color0.resolve_texture); +} + +} // namespace testing +} // namespace impeller From 1a36896567f9b663094073530f00a50331b38186 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Sun, 5 Nov 2023 19:39:15 -0800 Subject: [PATCH 2/3] ++ --- impeller/entity/BUILD.gn | 2 +- impeller/entity/entity_pass_target.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn index 6fc8e89c76040..0211f70e8d88b 100644 --- a/impeller/entity/BUILD.gn +++ b/impeller/entity/BUILD.gn @@ -270,12 +270,12 @@ impeller_component("entity_unittests") { sources = [ "contents/checkerboard_contents_unittests.cc", "contents/filters/inputs/filter_input_unittests.cc", + "entity_pass_target_unittests.cc", "entity_playground.cc", "entity_playground.h", "entity_unittests.cc", "geometry/geometry_unittests.cc", "render_target_cache_unittests.cc", - "entity_pass_target_unittests.cc", ] deps = [ diff --git a/impeller/entity/entity_pass_target.cc b/impeller/entity/entity_pass_target.cc index 6ba7f20335f3d..d9dbeb2f0a7f8 100644 --- a/impeller/entity/entity_pass_target.cc +++ b/impeller/entity/entity_pass_target.cc @@ -45,8 +45,8 @@ std::shared_ptr EntityPassTarget::Flip(Allocator& allocator) { } } - // If the color0 resolve texture is the same as the texture, then we're running - // on the GLES backend with implicit resolve. + // If the color0 resolve texture is the same as the texture, then we're + // running on the GLES backend with implicit resolve. if (color0.resolve_texture == color0.texture) { auto new_secondary = color0.resolve_texture; color0.resolve_texture = secondary_color_texture_; From 85e6df9d25d06abf2d53589413f52aaa7c2fb0c8 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Mon, 6 Nov 2023 08:22:06 -0800 Subject: [PATCH 3/3] ++ --- ci/licenses_golden/excluded_files | 1 + impeller/entity/entity_pass_target_unittests.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index 3e061375ff79d..3873d49850c5c 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -136,6 +136,7 @@ ../../../flutter/impeller/docs ../../../flutter/impeller/entity/contents/checkerboard_contents_unittests.cc ../../../flutter/impeller/entity/contents/filters/inputs/filter_input_unittests.cc +../../../flutter/impeller/entity/entity_pass_target_unittests.cc ../../../flutter/impeller/entity/entity_unittests.cc ../../../flutter/impeller/entity/geometry/geometry_unittests.cc ../../../flutter/impeller/entity/render_target_cache_unittests.cc diff --git a/impeller/entity/entity_pass_target_unittests.cc b/impeller/entity/entity_pass_target_unittests.cc index ad0c1b2d53069..725d2953c6d71 100644 --- a/impeller/entity/entity_pass_target_unittests.cc +++ b/impeller/entity/entity_pass_target_unittests.cc @@ -81,6 +81,7 @@ TEST_P(EntityPassTargetTest, SwapWithMSAAImplicitResolve) { ASSERT_EQ(msaa_tex, color0.texture); ASSERT_NE(resolve_tex, color0.resolve_texture); + ASSERT_TRUE(false); // see if this runs. } } // namespace testing