Visitar URL original
add sdf golden variants for OpenGL (#187246) · flutter/flutter@b4e5291 · GitHub
Skip to content

Commit b4e5291

Browse files
authored
add sdf golden variants for OpenGL (#187246)
Adds SDF variants for OpenGL golden tests ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
1 parent bb9f0ae commit b4e5291

13 files changed

Lines changed: 63 additions & 25 deletions

File tree

‎engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipeline) {
6262
// GL_OES_EGL_image_external isn't supported on MacOS hosts.
6363
#if !defined(FML_OS_MACOSX)
6464
TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipelineExternalOES) {
65-
if (GetParam() != PlaygroundBackend::kOpenGLES) {
65+
if (GetParam() != PlaygroundBackend::kOpenGLES &&
66+
GetParam() != PlaygroundBackend::kOpenGLESSDF) {
6667
GTEST_SKIP()
6768
<< "External OES textures are only valid for the OpenGLES backend.";
6869
}

‎engine/src/flutter/impeller/entity/entity_unittests.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,8 @@ static std::vector<std::shared_ptr<Texture>> CreateTestYUVTextures(
17501750
}
17511751

17521752
TEST_P(EntityTest, YUVToRGBFilter) {
1753-
if (GetParam() == PlaygroundBackend::kOpenGLES) {
1753+
if (GetParam() == PlaygroundBackend::kOpenGLES ||
1754+
GetParam() == PlaygroundBackend::kOpenGLESSDF) {
17541755
// TODO(114588) : Support YUV to RGB filter on OpenGLES backend.
17551756
GTEST_SKIP()
17561757
<< "YUV to RGB filter is not supported on OpenGLES backend yet.";

‎engine/src/flutter/impeller/golden_tests/golden_playground_test_mac.cc‎

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,35 @@ const std::unique_ptr<PlaygroundImpl>& GetSharedVulkanPlayground(
6161
}
6262
}
6363

64-
std::unique_ptr<PlaygroundImpl> MakeOpenGLESPlayground() {
64+
std::unique_ptr<PlaygroundImpl> MakeOpenGLESPlayground(bool use_sdfs = false) {
6565
FML_CHECK(::glfwInit() == GLFW_TRUE);
6666
PlaygroundSwitches playground_switches;
6767
playground_switches.use_angle = true;
68-
return PlaygroundImpl::Create(PlaygroundBackend::kOpenGLES,
69-
playground_switches);
68+
playground_switches.flags.use_sdfs = use_sdfs;
69+
return PlaygroundImpl::Create(
70+
use_sdfs ? PlaygroundBackend::kOpenGLESSDF : PlaygroundBackend::kOpenGLES,
71+
playground_switches);
7072
}
7173

7274
// Returns a static instance to an OpenGL ES playground that can be used across
7375
// tests.
74-
const std::unique_ptr<PlaygroundImpl>& GetSharedOpenGLESPlayground() {
75-
static absl::NoDestructor<std::unique_ptr<PlaygroundImpl>> opengl_playground(
76-
MakeOpenGLESPlayground());
77-
// TODO(142237): This can be removed when the thread local storage is
78-
// removed.
79-
static fml::ScopedCleanupClosure context_cleanup(
80-
[&] { (*opengl_playground)->GetContext()->Shutdown(); });
81-
return *opengl_playground;
76+
const std::unique_ptr<PlaygroundImpl>& GetSharedOpenGLESPlayground(
77+
bool use_sdfs) {
78+
if (use_sdfs) {
79+
static absl::NoDestructor<std::unique_ptr<PlaygroundImpl>>
80+
opengl_playground(MakeOpenGLESPlayground(/*use_sdfs=*/true));
81+
static fml::ScopedCleanupClosure context_cleanup(
82+
[&] { (*opengl_playground)->GetContext()->Shutdown(); });
83+
return *opengl_playground;
84+
} else {
85+
static absl::NoDestructor<std::unique_ptr<PlaygroundImpl>>
86+
opengl_playground(MakeOpenGLESPlayground(/*use_sdfs=*/false));
87+
// TODO(142237): This can be removed when the thread local storage is
88+
// removed.
89+
static fml::ScopedCleanupClosure context_cleanup(
90+
[&] { (*opengl_playground)->GetContext()->Shutdown(); });
91+
return *opengl_playground;
92+
}
8293
}
8394

8495
} // namespace
@@ -215,6 +226,9 @@ void GoldenPlaygroundTest::SetUp() {
215226
std::make_unique<testing::VulkanScreenshotter>(playground);
216227
break;
217228
}
229+
case PlaygroundBackend::kOpenGLESSDF:
230+
switches.flags.use_sdfs = true;
231+
[[fallthrough]];
218232
case PlaygroundBackend::kOpenGLES: {
219233
if (switches.enable_wide_gamut) {
220234
GTEST_SKIP() << "OpenGLES doesn't support wide gamut golden tests.";
@@ -224,7 +238,7 @@ void GoldenPlaygroundTest::SetUp() {
224238
<< "OpenGLES doesn't support antialiased lines golden tests.";
225239
}
226240
const std::unique_ptr<PlaygroundImpl>& playground =
227-
GetSharedOpenGLESPlayground();
241+
GetSharedOpenGLESPlayground(switches.flags.use_sdfs);
228242
::glfwMakeContextCurrent(
229243
reinterpret_cast<GLFWwindow*>(playground->GetWindowHandle()));
230244
pimpl_->screenshotter =
@@ -378,10 +392,12 @@ std::shared_ptr<Context> GoldenPlaygroundTest::MakeContext() const {
378392
pimpl_->screenshotter = std::make_unique<testing::VulkanScreenshotter>(
379393
pimpl_->test_vulkan_playground);
380394
return pimpl_->test_vulkan_playground->GetContext();
381-
} else if (GetParam() == PlaygroundBackend::kOpenGLES) {
395+
} else if (GetParam() == PlaygroundBackend::kOpenGLES ||
396+
GetParam() == PlaygroundBackend::kOpenGLESSDF) {
382397
FML_CHECK(!pimpl_->test_opengl_playground)
383398
<< "We don't support creating multiple contexts for one test";
384-
pimpl_->test_opengl_playground = MakeOpenGLESPlayground();
399+
bool use_sdfs = (GetParam() == PlaygroundBackend::kOpenGLESSDF);
400+
pimpl_->test_opengl_playground = MakeOpenGLESPlayground(use_sdfs);
385401
pimpl_->screenshotter = std::make_unique<testing::VulkanScreenshotter>(
386402
pimpl_->test_opengl_playground);
387403
return pimpl_->test_opengl_playground->GetContext();

‎engine/src/flutter/impeller/playground/playground.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ std::string PlaygroundBackendToString(PlaygroundBackend backend) {
5252
return "MetalSDF";
5353
case PlaygroundBackend::kOpenGLES:
5454
return "OpenGLES";
55+
case PlaygroundBackend::kOpenGLESSDF:
56+
return "OpenGLESSDF";
5557
case PlaygroundBackend::kVulkan:
5658
return "Vulkan";
5759
}
@@ -111,6 +113,7 @@ bool Playground::SupportsBackend(PlaygroundBackend backend) {
111113
return false;
112114
#endif // IMPELLER_ENABLE_METAL
113115
case PlaygroundBackend::kOpenGLES:
116+
case PlaygroundBackend::kOpenGLESSDF:
114117
#if IMPELLER_ENABLE_OPENGLES
115118
return true;
116119
#else // IMPELLER_ENABLE_OPENGLES

‎engine/src/flutter/impeller/playground/playground.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum class PlaygroundBackend {
2727
kMetal,
2828
kMetalSDF,
2929
kOpenGLES,
30+
kOpenGLESSDF,
3031
kVulkan,
3132
};
3233

‎engine/src/flutter/impeller/playground/playground_impl.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ std::unique_ptr<PlaygroundImpl> PlaygroundImpl::Create(
3636
#if IMPELLER_ENABLE_OPENGLES
3737
case PlaygroundBackend::kOpenGLES:
3838
return std::make_unique<PlaygroundImplGLES>(switches);
39+
case PlaygroundBackend::kOpenGLESSDF:
40+
switches.flags.use_sdfs = true;
41+
return std::make_unique<PlaygroundImplGLES>(switches);
3942
#endif // IMPELLER_ENABLE_OPENGLES
4043
#if IMPELLER_ENABLE_VULKAN
4144
case PlaygroundBackend::kVulkan:

‎engine/src/flutter/impeller/playground/playground_test.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ std::string PlaygroundTest::GetWindowTitle() const {
106106
case PlaygroundBackend::kMetalSDF:
107107
break;
108108
case PlaygroundBackend::kOpenGLES:
109+
case PlaygroundBackend::kOpenGLESSDF:
109110
if (switches_.use_angle) {
110111
stream << " (Angle) ";
111112
}

‎engine/src/flutter/impeller/playground/playground_test.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class PlaygroundTest : public Playground,
6363
Play, playground, \
6464
::testing::Values( \
6565
PlaygroundBackend::kMetal, PlaygroundBackend::kMetalSDF, \
66-
PlaygroundBackend::kOpenGLES, PlaygroundBackend::kVulkan), \
66+
PlaygroundBackend::kOpenGLES, PlaygroundBackend::kOpenGLESSDF, \
67+
PlaygroundBackend::kVulkan), \
6768
[](const ::testing::TestParamInfo<PlaygroundTest::ParamType>& info) { \
6869
return PlaygroundBackendToString(info.param); \
6970
});

‎engine/src/flutter/impeller/renderer/renderer_unittests.cc‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ TEST_P(RendererTest, CanRenderToTexture) {
419419
}
420420

421421
TEST_P(RendererTest, CanRenderInstanced) {
422-
if (GetParam() == PlaygroundBackend::kOpenGLES) {
422+
if (GetParam() == PlaygroundBackend::kOpenGLES ||
423+
GetParam() == PlaygroundBackend::kOpenGLESSDF) {
423424
// This test drives instancing through gl_InstanceIndex and a storage
424425
// buffer, both of which require OpenGL ES 3.1. The portable instance-rate
425426
// vertex attribute path, which works down to OpenGL ES 2.0, is covered by
@@ -485,7 +486,8 @@ TEST_P(RendererTest, CanRenderInstanced) {
485486
}
486487

487488
TEST_P(RendererTest, CanBlitTextureToTexture) {
488-
if (GetBackend() == PlaygroundBackend::kOpenGLES) {
489+
if (GetBackend() == PlaygroundBackend::kOpenGLES ||
490+
GetBackend() == PlaygroundBackend::kOpenGLESSDF) {
489491
GTEST_SKIP() << "Mipmap test shader not supported on GLES.";
490492
}
491493
auto context = GetContext();
@@ -595,7 +597,8 @@ TEST_P(RendererTest, CanBlitTextureToTexture) {
595597
}
596598

597599
TEST_P(RendererTest, CanBlitTextureToBuffer) {
598-
if (GetBackend() == PlaygroundBackend::kOpenGLES) {
600+
if (GetBackend() == PlaygroundBackend::kOpenGLES ||
601+
GetBackend() == PlaygroundBackend::kOpenGLESSDF) {
599602
GTEST_SKIP() << "Mipmap test shader not supported on GLES.";
600603
}
601604
auto context = GetContext();
@@ -724,7 +727,8 @@ TEST_P(RendererTest, CanBlitTextureToBuffer) {
724727
}
725728

726729
TEST_P(RendererTest, CanGenerateMipmaps) {
727-
if (GetBackend() == PlaygroundBackend::kOpenGLES) {
730+
if (GetBackend() == PlaygroundBackend::kOpenGLES ||
731+
GetBackend() == PlaygroundBackend::kOpenGLESSDF) {
728732
GTEST_SKIP() << "Mipmap test shader not supported on GLES.";
729733
}
730734
auto context = GetContext();

‎engine/src/flutter/impeller/runtime_stage/runtime_stage_unittests.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ TEST_P(RuntimeStageTest, CanReadUniforms) {
8888
[[fallthrough]];
8989
case PlaygroundBackend::kMetalSDF:
9090
[[fallthrough]];
91-
case PlaygroundBackend::kOpenGLES: {
91+
case PlaygroundBackend::kOpenGLES:
92+
[[fallthrough]];
93+
case PlaygroundBackend::kOpenGLESSDF: {
9294
ASSERT_EQ(stage->GetUniforms().size(), 14u);
9395
{
9496
// uFloat

0 commit comments

Comments
 (0)