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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user