From 9c248c5f21dcbd6f8f974e04c5443f9cabfe0fd3 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 21 Oct 2015 02:00:38 +1100 Subject: [PATCH] egl: distinguish between unsupported api vs capabilities with EGL_CONTEXT_FLAGS 11cabc45b7124e51d5ead42db6dceb5a3755266b be only ever returned EGL_BAD_ATTRIBUTE for any unsupoorted configuration request to EGL_CONTEXT_FLAGS. However the EGL_KHR_create_context spec has two possible return values for invalid configurations based on whether the requested GL API supports the config at all. "If an attribute is specified that is not meaningful for the client API type determined by the current rendering API, an EGL_BAD_ATTRIBUTE error is generated." and "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." Provide such a distinction in the handling of EGL_CONTEXT_FLAGS. Cc: "10.6 11.0" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92552 Signed-off-by: Matthew Waters --- src/egl/main/eglcontext.c | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index ae19862..8850e4a 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -99,6 +99,25 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, EGLint attr = attrib_list[i++]; EGLint val = attrib_list[i]; + /* The EGL_KHR_create_context spec says regarding errors: + * + * "If an attribute is specified that is not meaningful for the + * client API type determined by the current rendering API, an + * EGL_BAD_ATTRIBUTE error is generated." + * and + * "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." + * + * Which essentially boils down to: + * if (attrib && api doesn't support attrib) + * err = BAD_ATTRIBUTE; + * if (attrib && not supported) + * err = BAD_MATCH; + */ + switch (attr) { case EGL_CONTEXT_CLIENT_VERSION: /* The EGL 1.4 spec says: @@ -178,10 +197,15 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, * forward-compatible context for OpenGL versions less than 3.0 * will generate an error." */ - if ((val & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) && - (api != EGL_OPENGL_API || ctx->ClientMajorVersion < 3)) { - err = EGL_BAD_ATTRIBUTE; - break; + if ((val & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR)) { + if (api != EGL_OPENGL_API) { + err = EGL_BAD_ATTRIBUTE; + break; + } + if (ctx->ClientMajorVersion < 3) { + err = EGL_BAD_MATCH; + break; + } } /* The EGL_KHR_create_context_spec says: @@ -194,11 +218,15 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, * extension, or a version of OpenGL incorporating equivalent * functionality. This bit is supported for OpenGL contexts. */ - if ((val & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) && - (api != EGL_OPENGL_API || - !dpy->Extensions.EXT_create_context_robustness)) { - err = EGL_BAD_ATTRIBUTE; - break; + if (val & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) { + if (api != EGL_OPENGL_API) { + err = EGL_BAD_ATTRIBUTE; + break; + } + if (!dpy->Extensions.EXT_create_context_robustness) { + err = EGL_BAD_MATCH; + break; + } } ctx->Flags |= val; -- 2.6.1