Mesa (master): glx: Fix the generated error when indirect contexts are not supported

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 2 16:23:42 UTC 2020


Module: Mesa
Branch: master
Commit: 770230aab110478330a54aad6237d40db6028e90
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=770230aab110478330a54aad6237d40db6028e90

Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Dec  1 10:53:41 2020 -0500

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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7859>

---

 src/glx/glxcmds.c | 6 ++++--
 1 file 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);
    }
 



More information about the mesa-commit mailing list