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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26972>
This commit is contained in:
Daniel Stone 2024-01-10 12:21:11 +00:00 committed by Marge Bot
parent 3fd44345c4
commit 9cc3e842bb
3 changed files with 15 additions and 0 deletions

View file

@ -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. */

View file

@ -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;

View file

@ -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 */