[Impeller] Require the GLES multisampled_render_to_texture2 extension for offscreen MSAA (flutter/engine#56997)

Offscreen MSAA needs the ability to create multisample depth and stencil attachments.
This commit is contained in:
Jason Simmons 2024-12-06 07:43:23 -08:00 committed by GitHub
parent e9540f935e
commit 30289be8ba
2 changed files with 21 additions and 4 deletions

View File

@ -22,6 +22,10 @@ static const constexpr char* kNvidiaTextureBorderClampExt =
static const constexpr char* kMultisampledRenderToTextureExt = static const constexpr char* kMultisampledRenderToTextureExt =
"GL_EXT_multisampled_render_to_texture"; "GL_EXT_multisampled_render_to_texture";
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_multisampled_render_to_texture2.txt
static const constexpr char* kMultisampledRenderToTexture2Ext =
"GL_EXT_multisampled_render_to_texture2";
CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) { CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
{ {
GLint value = 0; GLint value = 0;
@ -123,10 +127,12 @@ CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
if (desc->HasExtension(kMultisampledRenderToTextureExt)) { if (desc->HasExtension(kMultisampledRenderToTextureExt)) {
supports_implicit_msaa_ = true; supports_implicit_msaa_ = true;
// We hard-code 4x MSAA, so let's make sure it's supported. if (desc->HasExtension(kMultisampledRenderToTexture2Ext)) {
GLint value = 0; // We hard-code 4x MSAA, so let's make sure it's supported.
gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value); GLint value = 0;
supports_offscreen_msaa_ = value >= 4; gl.GetIntegerv(GL_MAX_SAMPLES_EXT, &value);
supports_offscreen_msaa_ = value >= 4;
}
} }
is_es_ = desc->IsES(); is_es_ = desc->IsES();
is_angle_ = desc->IsANGLE(); is_angle_ = desc->IsANGLE();

View File

@ -63,5 +63,16 @@ TEST(CapabilitiesGLES, SupportsFramebufferFetch) {
EXPECT_TRUE(capabilities->SupportsFramebufferFetch()); EXPECT_TRUE(capabilities->SupportsFramebufferFetch());
} }
TEST(CapabilitiesGLES, SupportsMSAA) {
auto const extensions = std::vector<const unsigned char*>{
reinterpret_cast<const unsigned char*>(
"GL_EXT_multisampled_render_to_texture"),
};
auto mock_gles = MockGLES::Init(extensions);
auto capabilities = mock_gles->GetProcTable().GetCapabilities();
EXPECT_TRUE(capabilities->SupportsImplicitResolvingMSAA());
EXPECT_FALSE(capabilities->SupportsOffscreenMSAA());
}
} // namespace testing } // namespace testing
} // namespace impeller } // namespace impeller