From 9cc3e842bb7f0d65228a94c96f958f5da8593c2c Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 10 Jan 2024 12:21:11 +0000 Subject: [PATCH] egl: Return BAD_CONFIG when robust access unsupported EGL_EXT_create_context_robustness provides separate knobs for device reset strategy and robust buffer access. As there is no separate query for both piecies of functionality, devices which do not support robust buffer access need to reject contexts created with that flag with EGL_BAD_CONFIG. Given that EGL can't do cap queries, we create a fake extension entry in the EGLDisplay to cover whether the device can do robust buffer access or just device-reset queries. Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 2 ++ src/egl/main/eglcontext.c | 12 ++++++++++++ src/egl/main/egldisplay.h | 1 + 3 files changed, 15 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 992f0e3d46d..64d654f7e0b 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -892,6 +892,8 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.EXT_create_context_robustness = get_screen_param(disp, PIPE_CAP_DEVICE_RESET_STATUS_QUERY); + disp->RobustBufferAccess = + get_screen_param(disp, PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR); /* EXT_query_reset_notification_strategy complements and requires * EXT_create_context_robustness. */ diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index fa14bdf3943..c0e5f97bb38 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -288,6 +288,18 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *disp, break; } + /* The EGL_EXT_create_context_robustness spec says: + * + * "EGL_BAD_CONFIG is generated if + * [EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT] is set to EGL_TRUE and + * no GL context supporting the GL_EXT_robustness extension and + * robust access as described therein can be created." + */ + if (val == EGL_TRUE && !disp->RobustBufferAccess) { + err = EGL_BAD_CONFIG; + break; + } + if (val == EGL_TRUE) ctx->Flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; break; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index b3510ae7a1d..86a0ef521e7 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -208,6 +208,7 @@ struct _egl_display { EGLint Version; /**< EGL version major*10+minor */ EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */ _EGLExtensions Extensions; /**< Extensions supported */ + EGLBoolean RobustBufferAccess; /**< Supports robust buffer access behavior */ /* these fields are derived from above */ char VersionString[100]; /**< EGL_VERSION */