From 6ff74a6d3edac5b5c6421ecd805d269d97a780b6 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Mon, 3 Oct 2022 14:45:12 +0000 Subject: [PATCH] dawn/opengl: require EGL_EXT_create_context_robustness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Latest SwiftShader roll into Dawn failed because tests like TriangleStripPrimitiveRestartTests.Uint32WithoutPrimitiveRestart relies on robustness checks being enabled, but a recent change to SwiftShader no longer enabled robustness by default. This change makes sure to enable the robustness extension. Change-Id: I7168fc440ef19ef6acac1d1ce72f4bf5a947d4dd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104120 Kokoro: Kokoro Reviewed-by: Brandon Jones Reviewed-by: Alexis Hétu Commit-Queue: Antonio Maiorano --- src/dawn/native/opengl/ContextEGL.cpp | 19 ++++++++++++++++++- src/dawn/native/opengl/EGLFunctions.cpp | 1 + src/dawn/native/opengl/EGLFunctions.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/dawn/native/opengl/ContextEGL.cpp b/src/dawn/native/opengl/ContextEGL.cpp index b2618a32c8..ab42663b03 100644 --- a/src/dawn/native/opengl/ContextEGL.cpp +++ b/src/dawn/native/opengl/ContextEGL.cpp @@ -19,6 +19,10 @@ #include "dawn/native/opengl/UtilsEGL.h" +#ifndef EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#endif + namespace dawn::native::opengl { ResultOrError> ContextEGL::Create(const EGLFunctions& egl, @@ -61,8 +65,21 @@ ResultOrError> ContextEGL::Create(const EGLFunctions major = 4; minor = 4; } + + const char* extensions = egl.QueryString(display, EGL_EXTENSIONS); + if (strstr(extensions, "EGL_EXT_create_context_robustness") == nullptr) { + return DAWN_INTERNAL_ERROR("EGL_EXT_create_context_robustness must be supported"); + } + EGLint attrib_list[] = { - EGL_CONTEXT_MAJOR_VERSION, major, EGL_CONTEXT_MINOR_VERSION, minor, EGL_NONE, EGL_NONE, + EGL_CONTEXT_MAJOR_VERSION, + major, + EGL_CONTEXT_MINOR_VERSION, + minor, + EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, + EGL_TRUE, + EGL_NONE, + EGL_NONE, }; EGLContext context = egl.CreateContext(display, config, EGL_NO_CONTEXT, attrib_list); DAWN_TRY(CheckEGL(egl, context != EGL_NO_CONTEXT, "eglCreateContext")); diff --git a/src/dawn/native/opengl/EGLFunctions.cpp b/src/dawn/native/opengl/EGLFunctions.cpp index 5796131d42..67e68572cb 100644 --- a/src/dawn/native/opengl/EGLFunctions.cpp +++ b/src/dawn/native/opengl/EGLFunctions.cpp @@ -38,6 +38,7 @@ void EGLFunctions::Init(void* (*getProc)(const char*)) { GetError = reinterpret_cast(GetProcAddress("eglGetError")); Initialize = reinterpret_cast(GetProcAddress("eglInitialize")); MakeCurrent = reinterpret_cast(GetProcAddress("eglMakeCurrent")); + QueryString = reinterpret_cast(GetProcAddress("eglQueryString")); } } // namespace dawn::native::opengl diff --git a/src/dawn/native/opengl/EGLFunctions.h b/src/dawn/native/opengl/EGLFunctions.h index 5c2688fb66..399ee9d5df 100644 --- a/src/dawn/native/opengl/EGLFunctions.h +++ b/src/dawn/native/opengl/EGLFunctions.h @@ -36,6 +36,7 @@ struct EGLFunctions { PFNEGLGETPROCADDRESSPROC GetProcAddress; PFNEGLINITIALIZEPROC Initialize; PFNEGLMAKECURRENTPROC MakeCurrent; + PFNEGLQUERYSTRINGPROC QueryString; }; } // namespace dawn::native::opengl