From ec0c103b329a8f8059fb803cc03085bb10f81ef9 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sat, 17 Aug 2024 04:25:36 +0200 Subject: [PATCH] egl: Add more errors cases during context creation In 9cc3e842bb7 an explicit check whether drivers support PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR was added to EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT. Add respective checks in similar places as well. Signed-off-by: Robert Mader Reviewed-by: Eric Engestrom Part-of: --- src/egl/main/eglcontext.c | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index c0e5f97bb38..f72a2ab18c3 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -217,6 +217,19 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *disp, break; } + /* The EGL_KHR_create_context spec says: + * "If does not support a client API context compatible + * with the requested API major and minor version, context flags, + * and context reset notification behavior (for client API types + * where these attributes are supported), then an EGL_BAD_MATCH + * error is generated." + */ + if ((val & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) && + !disp->RobustBufferAccess) { + err = EGL_BAD_MATCH; + break; + } + ctx->Flags |= val; break; @@ -263,6 +276,25 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *disp, break; } + /* The EGL 1.5 spec says: + * "An EGL_BAD_MATCH error is generated if an OpenGL or OpenGL ES + * context is requested with robust buffer access and with a + * specified reset notification behavior, and the implementation + * does not support that behavior." + * + * and the EGL_KHR_create_context spec says: + * "If does not support a client API context compatible + * with the requested API major and minor version, context flags, + * and context reset notification behavior (for client API types + * where these attributes are supported), then an EGL_BAD_MATCH + * error is generated." + */ + if (val != EGL_NO_RESET_NOTIFICATION_KHR && + !disp->Extensions.EXT_create_context_robustness) { + err = EGL_BAD_MATCH; + break; + } + ctx->ResetNotificationStrategy = val; break; @@ -310,6 +342,17 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *disp, break; } + /* The EGL 1.5 spec says: + * "An EGL_BAD_MATCH error is generated if an OpenGL or OpenGL ES + * context is requested with robust buffer access, and the + * implementation does not support the corresponding OpenGL or + * OpenGL ES extension". + */ + if (val == EGL_TRUE && !disp->RobustBufferAccess) { + err = EGL_BAD_MATCH; + break; + } + if (val == EGL_TRUE) ctx->Flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; break;