diff --git a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc index 0aa4a41cd9d95..f0af27b66fafa 100644 --- a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc @@ -62,7 +62,8 @@ TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipeline) { // GL_OES_EGL_image_external isn't supported on MacOS hosts. #if !defined(FML_OS_MACOSX) TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipelineExternalOES) { - if (GetParam() != PlaygroundBackend::kOpenGLES) { + if (GetParam() != PlaygroundBackend::kOpenGLES && + GetParam() != PlaygroundBackend::kOpenGLESSDF) { GTEST_SKIP() << "External OES textures are only valid for the OpenGLES backend."; } diff --git a/engine/src/flutter/impeller/entity/entity_unittests.cc b/engine/src/flutter/impeller/entity/entity_unittests.cc index 414e2d2290506..61e988fe53108 100644 --- a/engine/src/flutter/impeller/entity/entity_unittests.cc +++ b/engine/src/flutter/impeller/entity/entity_unittests.cc @@ -1750,7 +1750,8 @@ static std::vector> CreateTestYUVTextures( } TEST_P(EntityTest, YUVToRGBFilter) { - if (GetParam() == PlaygroundBackend::kOpenGLES) { + if (GetParam() == PlaygroundBackend::kOpenGLES || + GetParam() == PlaygroundBackend::kOpenGLESSDF) { // TODO(114588) : Support YUV to RGB filter on OpenGLES backend. GTEST_SKIP() << "YUV to RGB filter is not supported on OpenGLES backend yet."; diff --git a/engine/src/flutter/impeller/golden_tests/golden_playground_test_mac.cc b/engine/src/flutter/impeller/golden_tests/golden_playground_test_mac.cc index fcc3b89a96851..a1d5380b46e1e 100644 --- a/engine/src/flutter/impeller/golden_tests/golden_playground_test_mac.cc +++ b/engine/src/flutter/impeller/golden_tests/golden_playground_test_mac.cc @@ -61,24 +61,35 @@ const std::unique_ptr& GetSharedVulkanPlayground( } } -std::unique_ptr MakeOpenGLESPlayground() { +std::unique_ptr MakeOpenGLESPlayground(bool use_sdfs = false) { FML_CHECK(::glfwInit() == GLFW_TRUE); PlaygroundSwitches playground_switches; playground_switches.use_angle = true; - return PlaygroundImpl::Create(PlaygroundBackend::kOpenGLES, - playground_switches); + playground_switches.flags.use_sdfs = use_sdfs; + return PlaygroundImpl::Create( + use_sdfs ? PlaygroundBackend::kOpenGLESSDF : PlaygroundBackend::kOpenGLES, + playground_switches); } // Returns a static instance to an OpenGL ES playground that can be used across // tests. -const std::unique_ptr& GetSharedOpenGLESPlayground() { - static absl::NoDestructor> opengl_playground( - MakeOpenGLESPlayground()); - // TODO(142237): This can be removed when the thread local storage is - // removed. - static fml::ScopedCleanupClosure context_cleanup( - [&] { (*opengl_playground)->GetContext()->Shutdown(); }); - return *opengl_playground; +const std::unique_ptr& GetSharedOpenGLESPlayground( + bool use_sdfs) { + if (use_sdfs) { + static absl::NoDestructor> + opengl_playground(MakeOpenGLESPlayground(/*use_sdfs=*/true)); + static fml::ScopedCleanupClosure context_cleanup( + [&] { (*opengl_playground)->GetContext()->Shutdown(); }); + return *opengl_playground; + } else { + static absl::NoDestructor> + opengl_playground(MakeOpenGLESPlayground(/*use_sdfs=*/false)); + // TODO(142237): This can be removed when the thread local storage is + // removed. + static fml::ScopedCleanupClosure context_cleanup( + [&] { (*opengl_playground)->GetContext()->Shutdown(); }); + return *opengl_playground; + } } } // namespace @@ -215,6 +226,9 @@ void GoldenPlaygroundTest::SetUp() { std::make_unique(playground); break; } + case PlaygroundBackend::kOpenGLESSDF: + switches.flags.use_sdfs = true; + [[fallthrough]]; case PlaygroundBackend::kOpenGLES: { if (switches.enable_wide_gamut) { GTEST_SKIP() << "OpenGLES doesn't support wide gamut golden tests."; @@ -224,7 +238,7 @@ void GoldenPlaygroundTest::SetUp() { << "OpenGLES doesn't support antialiased lines golden tests."; } const std::unique_ptr& playground = - GetSharedOpenGLESPlayground(); + GetSharedOpenGLESPlayground(switches.flags.use_sdfs); ::glfwMakeContextCurrent( reinterpret_cast(playground->GetWindowHandle())); pimpl_->screenshotter = @@ -378,10 +392,12 @@ std::shared_ptr GoldenPlaygroundTest::MakeContext() const { pimpl_->screenshotter = std::make_unique( pimpl_->test_vulkan_playground); return pimpl_->test_vulkan_playground->GetContext(); - } else if (GetParam() == PlaygroundBackend::kOpenGLES) { + } else if (GetParam() == PlaygroundBackend::kOpenGLES || + GetParam() == PlaygroundBackend::kOpenGLESSDF) { FML_CHECK(!pimpl_->test_opengl_playground) << "We don't support creating multiple contexts for one test"; - pimpl_->test_opengl_playground = MakeOpenGLESPlayground(); + bool use_sdfs = (GetParam() == PlaygroundBackend::kOpenGLESSDF); + pimpl_->test_opengl_playground = MakeOpenGLESPlayground(use_sdfs); pimpl_->screenshotter = std::make_unique( pimpl_->test_opengl_playground); return pimpl_->test_opengl_playground->GetContext(); diff --git a/engine/src/flutter/impeller/playground/playground.cc b/engine/src/flutter/impeller/playground/playground.cc index 35d19560cd8aa..87e898fa2c97a 100644 --- a/engine/src/flutter/impeller/playground/playground.cc +++ b/engine/src/flutter/impeller/playground/playground.cc @@ -52,6 +52,8 @@ std::string PlaygroundBackendToString(PlaygroundBackend backend) { return "MetalSDF"; case PlaygroundBackend::kOpenGLES: return "OpenGLES"; + case PlaygroundBackend::kOpenGLESSDF: + return "OpenGLESSDF"; case PlaygroundBackend::kVulkan: return "Vulkan"; } @@ -111,6 +113,7 @@ bool Playground::SupportsBackend(PlaygroundBackend backend) { return false; #endif // IMPELLER_ENABLE_METAL case PlaygroundBackend::kOpenGLES: + case PlaygroundBackend::kOpenGLESSDF: #if IMPELLER_ENABLE_OPENGLES return true; #else // IMPELLER_ENABLE_OPENGLES diff --git a/engine/src/flutter/impeller/playground/playground.h b/engine/src/flutter/impeller/playground/playground.h index 69c7c39f23b1c..3c8b251bf8018 100644 --- a/engine/src/flutter/impeller/playground/playground.h +++ b/engine/src/flutter/impeller/playground/playground.h @@ -27,6 +27,7 @@ enum class PlaygroundBackend { kMetal, kMetalSDF, kOpenGLES, + kOpenGLESSDF, kVulkan, }; diff --git a/engine/src/flutter/impeller/playground/playground_impl.cc b/engine/src/flutter/impeller/playground/playground_impl.cc index a112b84ce0d36..22a9909e3c4d0 100644 --- a/engine/src/flutter/impeller/playground/playground_impl.cc +++ b/engine/src/flutter/impeller/playground/playground_impl.cc @@ -36,6 +36,9 @@ std::unique_ptr PlaygroundImpl::Create( #if IMPELLER_ENABLE_OPENGLES case PlaygroundBackend::kOpenGLES: return std::make_unique(switches); + case PlaygroundBackend::kOpenGLESSDF: + switches.flags.use_sdfs = true; + return std::make_unique(switches); #endif // IMPELLER_ENABLE_OPENGLES #if IMPELLER_ENABLE_VULKAN case PlaygroundBackend::kVulkan: diff --git a/engine/src/flutter/impeller/playground/playground_test.cc b/engine/src/flutter/impeller/playground/playground_test.cc index d35150190df36..935c46949bb1b 100644 --- a/engine/src/flutter/impeller/playground/playground_test.cc +++ b/engine/src/flutter/impeller/playground/playground_test.cc @@ -106,6 +106,7 @@ std::string PlaygroundTest::GetWindowTitle() const { case PlaygroundBackend::kMetalSDF: break; case PlaygroundBackend::kOpenGLES: + case PlaygroundBackend::kOpenGLESSDF: if (switches_.use_angle) { stream << " (Angle) "; } diff --git a/engine/src/flutter/impeller/playground/playground_test.h b/engine/src/flutter/impeller/playground/playground_test.h index 36944112e3e7f..309c8e787d169 100644 --- a/engine/src/flutter/impeller/playground/playground_test.h +++ b/engine/src/flutter/impeller/playground/playground_test.h @@ -63,7 +63,8 @@ class PlaygroundTest : public Playground, Play, playground, \ ::testing::Values( \ PlaygroundBackend::kMetal, PlaygroundBackend::kMetalSDF, \ - PlaygroundBackend::kOpenGLES, PlaygroundBackend::kVulkan), \ + PlaygroundBackend::kOpenGLES, PlaygroundBackend::kOpenGLESSDF, \ + PlaygroundBackend::kVulkan), \ [](const ::testing::TestParamInfo& info) { \ return PlaygroundBackendToString(info.param); \ }); diff --git a/engine/src/flutter/impeller/renderer/renderer_unittests.cc b/engine/src/flutter/impeller/renderer/renderer_unittests.cc index 9b9526cc3f1e9..5386f6e3508ea 100644 --- a/engine/src/flutter/impeller/renderer/renderer_unittests.cc +++ b/engine/src/flutter/impeller/renderer/renderer_unittests.cc @@ -419,7 +419,8 @@ TEST_P(RendererTest, CanRenderToTexture) { } TEST_P(RendererTest, CanRenderInstanced) { - if (GetParam() == PlaygroundBackend::kOpenGLES) { + if (GetParam() == PlaygroundBackend::kOpenGLES || + GetParam() == PlaygroundBackend::kOpenGLESSDF) { // This test drives instancing through gl_InstanceIndex and a storage // buffer, both of which require OpenGL ES 3.1. The portable instance-rate // vertex attribute path, which works down to OpenGL ES 2.0, is covered by @@ -485,7 +486,8 @@ TEST_P(RendererTest, CanRenderInstanced) { } TEST_P(RendererTest, CanBlitTextureToTexture) { - if (GetBackend() == PlaygroundBackend::kOpenGLES) { + if (GetBackend() == PlaygroundBackend::kOpenGLES || + GetBackend() == PlaygroundBackend::kOpenGLESSDF) { GTEST_SKIP() << "Mipmap test shader not supported on GLES."; } auto context = GetContext(); @@ -595,7 +597,8 @@ TEST_P(RendererTest, CanBlitTextureToTexture) { } TEST_P(RendererTest, CanBlitTextureToBuffer) { - if (GetBackend() == PlaygroundBackend::kOpenGLES) { + if (GetBackend() == PlaygroundBackend::kOpenGLES || + GetBackend() == PlaygroundBackend::kOpenGLESSDF) { GTEST_SKIP() << "Mipmap test shader not supported on GLES."; } auto context = GetContext(); @@ -724,7 +727,8 @@ TEST_P(RendererTest, CanBlitTextureToBuffer) { } TEST_P(RendererTest, CanGenerateMipmaps) { - if (GetBackend() == PlaygroundBackend::kOpenGLES) { + if (GetBackend() == PlaygroundBackend::kOpenGLES || + GetBackend() == PlaygroundBackend::kOpenGLESSDF) { GTEST_SKIP() << "Mipmap test shader not supported on GLES."; } auto context = GetContext(); diff --git a/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc b/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc index 90443653c3f9b..00e2ecdd4e107 100644 --- a/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc +++ b/engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc @@ -88,7 +88,9 @@ TEST_P(RuntimeStageTest, CanReadUniforms) { [[fallthrough]]; case PlaygroundBackend::kMetalSDF: [[fallthrough]]; - case PlaygroundBackend::kOpenGLES: { + case PlaygroundBackend::kOpenGLES: + [[fallthrough]]; + case PlaygroundBackend::kOpenGLESSDF: { ASSERT_EQ(stage->GetUniforms().size(), 14u); { // uFloat diff --git a/engine/src/flutter/impeller/toolkit/interop/impeller_unittests.cc b/engine/src/flutter/impeller/toolkit/interop/impeller_unittests.cc index 9c460b4fdf67a..8c82c20881401 100644 --- a/engine/src/flutter/impeller/toolkit/interop/impeller_unittests.cc +++ b/engine/src/flutter/impeller/toolkit/interop/impeller_unittests.cc @@ -47,7 +47,8 @@ TEST_P(InteropPlaygroundTest, CanCreateDisplayListBuilder) { } TEST_P(InteropPlaygroundTest, CanCreateSurface) { - if (GetBackend() != PlaygroundBackend::kOpenGLES) { + if (GetBackend() != PlaygroundBackend::kOpenGLES && + GetBackend() != PlaygroundBackend::kOpenGLESSDF) { GTEST_SKIP() << "This test checks wrapping FBOs which is an OpenGL ES only call."; return; diff --git a/engine/src/flutter/impeller/toolkit/interop/playground_test.cc b/engine/src/flutter/impeller/toolkit/interop/playground_test.cc index 4bc9b84edfb87..268dbeef5e958 100644 --- a/engine/src/flutter/impeller/toolkit/interop/playground_test.cc +++ b/engine/src/flutter/impeller/toolkit/interop/playground_test.cc @@ -62,7 +62,8 @@ ScopedObject PlaygroundTest::CreateContext() const { case PlaygroundBackend::kMetalSDF: return Adopt( ImpellerContextCreateMetalNew(ImpellerGetVersion())); - case PlaygroundBackend::kOpenGLES: { + case PlaygroundBackend::kOpenGLES: + case PlaygroundBackend::kOpenGLESSDF: { Playground::GLProcAddressResolver playground_gl_proc_address_callback = CreateGLProcAddressResolver(); ImpellerProcAddressCallback gl_proc_address_callback = @@ -112,6 +113,7 @@ static ScopedObject CreateSharedSurface( #if IMPELLER_ENABLE_OPENGLES case PlaygroundBackend::kOpenGLES: + case PlaygroundBackend::kOpenGLESSDF: return Adopt( new SurfaceGLES(context, std::move(shared_surface))); #endif @@ -156,6 +158,7 @@ static ScopedObject CreateSharedContext( #endif #if IMPELLER_ENABLE_OPENGLES case PlaygroundBackend::kOpenGLES: + case PlaygroundBackend::kOpenGLESSDF: return ContextGLES::Create(std::move(shared_context)); #endif #if IMPELLER_ENABLE_VULKAN diff --git a/engine/src/flutter/impeller/typographer/typographer_unittests.cc b/engine/src/flutter/impeller/typographer/typographer_unittests.cc index 3a1a586e85656..c0579bb82b947 100644 --- a/engine/src/flutter/impeller/typographer/typographer_unittests.cc +++ b/engine/src/flutter/impeller/typographer/typographer_unittests.cc @@ -475,7 +475,8 @@ TEST(TypographerTest, RectanglePackerFillsRows) { } TEST_P(TypographerTest, GlyphAtlasTextureWillGrowTilMaxTextureSize) { - if (GetBackend() == PlaygroundBackend::kOpenGLES) { + if (GetBackend() == PlaygroundBackend::kOpenGLES || + GetBackend() == PlaygroundBackend::kOpenGLESSDF) { GTEST_SKIP() << "Atlas growth isn't supported for OpenGLES currently."; }