dawn/opengl: require EGL_EXT_create_context_robustness

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 <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2022-10-03 14:45:12 +00:00 committed by Dawn LUCI CQ
parent 4bdbc989cd
commit 6ff74a6d3e
3 changed files with 20 additions and 1 deletions

View File

@ -19,6 +19,10 @@
#include "dawn/native/opengl/UtilsEGL.h" #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 { namespace dawn::native::opengl {
ResultOrError<std::unique_ptr<ContextEGL>> ContextEGL::Create(const EGLFunctions& egl, ResultOrError<std::unique_ptr<ContextEGL>> ContextEGL::Create(const EGLFunctions& egl,
@ -61,8 +65,21 @@ ResultOrError<std::unique_ptr<ContextEGL>> ContextEGL::Create(const EGLFunctions
major = 4; major = 4;
minor = 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[] = { 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); EGLContext context = egl.CreateContext(display, config, EGL_NO_CONTEXT, attrib_list);
DAWN_TRY(CheckEGL(egl, context != EGL_NO_CONTEXT, "eglCreateContext")); DAWN_TRY(CheckEGL(egl, context != EGL_NO_CONTEXT, "eglCreateContext"));

View File

@ -38,6 +38,7 @@ void EGLFunctions::Init(void* (*getProc)(const char*)) {
GetError = reinterpret_cast<PFNEGLGETERRORPROC>(GetProcAddress("eglGetError")); GetError = reinterpret_cast<PFNEGLGETERRORPROC>(GetProcAddress("eglGetError"));
Initialize = reinterpret_cast<PFNEGLINITIALIZEPROC>(GetProcAddress("eglInitialize")); Initialize = reinterpret_cast<PFNEGLINITIALIZEPROC>(GetProcAddress("eglInitialize"));
MakeCurrent = reinterpret_cast<PFNEGLMAKECURRENTPROC>(GetProcAddress("eglMakeCurrent")); MakeCurrent = reinterpret_cast<PFNEGLMAKECURRENTPROC>(GetProcAddress("eglMakeCurrent"));
QueryString = reinterpret_cast<PFNEGLQUERYSTRINGPROC>(GetProcAddress("eglQueryString"));
} }
} // namespace dawn::native::opengl } // namespace dawn::native::opengl

View File

@ -36,6 +36,7 @@ struct EGLFunctions {
PFNEGLGETPROCADDRESSPROC GetProcAddress; PFNEGLGETPROCADDRESSPROC GetProcAddress;
PFNEGLINITIALIZEPROC Initialize; PFNEGLINITIALIZEPROC Initialize;
PFNEGLMAKECURRENTPROC MakeCurrent; PFNEGLMAKECURRENTPROC MakeCurrent;
PFNEGLQUERYSTRINGPROC QueryString;
}; };
} // namespace dawn::native::opengl } // namespace dawn::native::opengl