summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2020-12-01 10:53:41 -0500
committerMarge Bot <eric+marge@anholt.net>2020-12-02 16:07:27 +0000
commit770230aab110478330a54aad6237d40db6028e90 (patch)
tree5a9b22eea68d7eaff1ccd218d3270d7638bb997c
parent97858f3c9c15882da5c2cbd4d8a2dbc63d1d0b1a (diff)
glx: Fix the generated error when indirect contexts are not supported
When the server doesn't support indirect contexts it will generate a BadValue error, since the CreateContext request's isDirect field will have specified an unsupported value of False. We attempt to verify that context creation succeeded by asking whether the context's XID is direct or not after we create it. Due to the details of XCB error handling, if the context wasn't successfully created, the GLXBadContext error from the GLXIsDirect request will get raised first, hiding the BadValue from the application. To fix this, we change the behavior of __glXIsDirect based on the `error` outparameter. If it is NULL we still raise the error generated from the GLXIsDirect request, but if it is non-NULL we now just inform the caller that the request failed and silently eat the error. By doing this the BadValue (or whatever else) from the CreateContext request will bubble up to the application as expected. This is admittedly a bit subtle but it's the simplest way to get to the fix here. A better solution would be to convert all of CreateContext to XCB, but XCB doesn't have protocol for GLX_SGIX_fbconfig yet so we'd lose glXCreateContextWithConfigSGIX. Fixes: mesa/mesa#3907 Acked-by: Michel Dänzer <mdaenzer@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7859>
-rw-r--r--src/glx/glxcmds.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index cf546cc86dd..fcd82bab4a4 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -276,7 +276,8 @@ glx_context_init(struct glx_context *gc,
*
* \param dpy Display where the context was created.
* \param contextID ID of the context to be tested.
- * \param error Out parameter, set to True on error if not NULL
+ * \param error Out parameter, set to True on error if not NULL,
+ * otherwise raise the error to the application.
*
* \returns \c True if the context is direct rendering or not.
*/
@@ -301,7 +302,8 @@ __glXIsDirect(Display * dpy, GLXContextID contextID, Bool *error)
if (err != NULL) {
if (error)
*error = True;
- __glXSendErrorForXcb(dpy, err);
+ else
+ __glXSendErrorForXcb(dpy, err);
free(err);
}