diff --git a/src/dawn/native/opengl/ContextEGL.cpp b/src/dawn/native/opengl/ContextEGL.cpp index 7f25852c1b8..6a057cb030e 100644 --- a/src/dawn/native/opengl/ContextEGL.cpp +++ b/src/dawn/native/opengl/ContextEGL.cpp @@ -54,6 +54,11 @@ #define EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE 0x3481 #endif +// https://chromium.googlesource.com/angle/angle/+/main/extensions/EGL_ANGLE_create_context_webgl_compatibility.txt +#ifndef EGL_CONTEXT_HARDENED_ANGLE +#define EGL_CONTEXT_HARDENED_ANGLE 0x34F8 +#endif + namespace dawn::native::opengl { namespace { @@ -191,6 +196,16 @@ MaybeError ContextEGL::Initialize(wgpu::BackendType backend, AddAttrib(EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE, angleVirtualizationGroup); } + // Dawn's GL backend feeds Tint-generated GLSL (which can declare std430 + // SSBO types up to ~4 GiB) into ANGLE. Request a hardened ANGLE context so + // that ANGLE enables rejectWebglShadersWithLargeVariables and rejects such + // shaders before forwarding them to the native driver. This mirrors the + // protection that Chrome's GLES2 command-buffer applies to all non-WebGL + // passthrough contexts (gpu/command_buffer/service/service_utils.cc). + if (egl.HasExt(EGLExt::ANGLECreateContextWebGLCompatibility)) { + AddAttrib(EGL_CONTEXT_HARDENED_ANGLE, EGL_TRUE); + } + // The attrib list is finished with an EGL_NONE tag. attribs.push_back(EGL_NONE); diff --git a/src/dawn/native/opengl/EGLFunctions.cpp b/src/dawn/native/opengl/EGLFunctions.cpp index 3e1c7e670d5..297ed1d2399 100644 --- a/src/dawn/native/opengl/EGLFunctions.cpp +++ b/src/dawn/native/opengl/EGLFunctions.cpp @@ -97,6 +97,8 @@ static constexpr std::array kExtensionInfos{{ NeverPromoted, ExtType::Display}, {EGLExt::ANGLEContextVirtualization, "EGL_ANGLE_context_virtualization", NeverPromoted, ExtType::Display}, + {EGLExt::ANGLECreateContextWebGLCompatibility, + "EGL_ANGLE_create_context_webgl_compatibility", NeverPromoted, ExtType::Display}, // }}; diff --git a/src/dawn/native/opengl/EGLFunctions.h b/src/dawn/native/opengl/EGLFunctions.h index b0c9d4dde9d..78cbe69a3f9 100644 --- a/src/dawn/native/opengl/EGLFunctions.h +++ b/src/dawn/native/opengl/EGLFunctions.h @@ -69,6 +69,7 @@ enum class EGLExt : uint32_t { ANGLECreateContextBackwardsCompatible, // EGL_ANGLE_create_context_backwards_compatible ANGLECreateContextExtensionsEnabled, // EGL_ANGLE_create_context_extensions_enabled ANGLEContextVirtualization, // EGL_ANGLE_context_virtualization + ANGLECreateContextWebGLCompatibility, // EGL_ANGLE_create_context_webgl_compatibility EnumCount, };