Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a0d2169

Browse files
[Impeller] Require the GLES multisampled_render_to_texture2 extension for offscreen MSAA (#56997)
Offscreen MSAA needs the ability to create multisample depth and stencil attachments.
1 parent 31ba1e0 commit a0d2169

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

impeller/renderer/backend/gles/capabilities_gles.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ static const constexpr char* kNvidiaTextureBorderClampExt =
2222
static const constexpr char* kMultisampledRenderToTextureExt =
2323
"GL_EXT_multisampled_render_to_texture";
2424

25+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture2.txt
26+
static const constexpr char* kMultisampledRenderToTexture2Ext =
27+
"GL_EXT_multisampled_render_to_texture2";
28+
2529
CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
2630
{
2731
GLint value = 0;
@@ -123,10 +127,12 @@ CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
123127
if (desc->HasExtension(kMultisampledRenderToTextureExt)) {
124128
supports_implicit_msaa_ = true;
125129

126-
// We hard-code 4x MSAA, so let's make sure it's supported.
127-
GLint value = 0;
128-
gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
129-
supports_offscreen_msaa_ = value >= 4;
130+
if (desc->HasExtension(kMultisampledRenderToTexture2Ext)) {
131+
// We hard-code 4x MSAA, so let's make sure it's supported.
132+
GLint value = 0;
133+
gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
134+
supports_offscreen_msaa_ = value >= 4;
135+
}
130136
}
131137
is_es_ = desc->IsES();
132138
is_angle_ = desc->IsANGLE();

impeller/renderer/backend/gles/test/capabilities_unittests.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,16 @@ TEST(CapabilitiesGLES, SupportsFramebufferFetch) {
6363
EXPECT_TRUE(capabilities->SupportsFramebufferFetch());
6464
}
6565

66+
TEST(CapabilitiesGLES, SupportsMSAA) {
67+
auto const extensions = std::vector<const unsigned char*>{
68+
reinterpret_cast<const unsigned char*>(
69+
"GL_EXT_multisampled_render_to_texture"),
70+
};
71+
auto mock_gles = MockGLES::Init(extensions);
72+
auto capabilities = mock_gles->GetProcTable().GetCapabilities();
73+
EXPECT_TRUE(capabilities->SupportsImplicitResolvingMSAA());
74+
EXPECT_FALSE(capabilities->SupportsOffscreenMSAA());
75+
}
76+
6677
} // namespace testing
6778
} // namespace impeller

0 commit comments

Comments
 (0)