diff --git a/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp b/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp index 8ebc52f5ac..10ec3dffee 100644 --- a/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp +++ b/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp @@ -197,6 +197,12 @@ egl::Error DisplayEGL::initializeContext(EGLContext shareContext, { egl::AttributeMap attribsWithRobustness(attribs); + // Request robust buffer access on the native context. Without this + // bit, GL_KHR_robust_buffer_access_behavior advertised by the + // driver does not apply, and ANGLE incorrectly disables its own + // CPU-side OOB validation while the driver is free to fetch OOB. + // Matches GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB / WGL equivalent. + attribsWithRobustness.insert(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE); attribsWithRobustness.insert(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY, EGL_LOSE_CONTEXT_ON_RESET); if (mHasNVRobustnessVideoMemoryPurge) diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp index b8219a1080..26b79a2daa 100644 --- a/src/libANGLE/renderer/gl/renderergl_utils.cpp +++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp @@ -1712,8 +1712,16 @@ void GenerateCaps(const FunctionsGL *functions, functions->isAtLeastGLES(gl::Version(3, 2)) || functions->hasGLESExtension("GL_KHR_robustness"); + // GL_KHR_robust_buffer_access_behavior only guarantees defined OOB + // behaviour when the context was created with the robust-access flag. + // The extension string alone is insufficient — verify the flag is set so + // we don't disable ANGLE's CPU-side bounds validation against a context + // that the driver is permitted to fetch OOB on. + GLint nativeContextFlags = 0; + functions->getIntegerv(GL_CONTEXT_FLAGS, &nativeContextFlags); extensions->robustBufferAccessBehaviorKHR = extensions->robustnessEXT && + (nativeContextFlags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT) != 0 && (functions->hasGLExtension("GL_ARB_robust_buffer_access_behavior") || functions->hasGLESExtension("GL_KHR_robust_buffer_access_behavior"));