diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-02 04:34:57 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-02 04:34:57 +0000 |
commit | 32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 (patch) | |
tree | fc5893a490729ebf6b87b83eebf5d4ebfdfccf27 /lib/mesa/src/glx/create_context.c | |
parent | 286ec9d289bada8abb84753c461cfa3432866e98 (diff) |
Import Mesa 23.1.9
Diffstat (limited to 'lib/mesa/src/glx/create_context.c')
-rw-r--r-- | lib/mesa/src/glx/create_context.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/lib/mesa/src/glx/create_context.c b/lib/mesa/src/glx/create_context.c index 471321641..1c2bbb1cf 100644 --- a/lib/mesa/src/glx/create_context.c +++ b/lib/mesa/src/glx/create_context.c @@ -54,7 +54,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, struct glx_screen *psc; xcb_generic_error_t *err; xcb_void_cookie_t cookie; - unsigned dummy_err = 0; + unsigned error = BadImplementation; uint32_t xid, share_xid; int screen = -1; @@ -100,25 +100,35 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, direct = true; } - +#ifdef GLX_USE_APPLEGL + gc = applegl_create_context(psc, cfg, share, 0); +#else if (direct && psc->vtable->create_context_attribs) { - /* GLX drops the error returned by the driver. The expectation is that - * an error will also be returned by the server. The server's error - * will be delivered to the application. - */ gc = psc->vtable->create_context_attribs(psc, cfg, share, num_attribs, - (const uint32_t *) attrib_list, - &dummy_err); + (const uint32_t *) attrib_list, + &error); + } else if (!direct) { + gc = indirect_create_context_attribs(psc, cfg, share, num_attribs, + (const uint32_t *) attrib_list, + &error); } +#endif if (gc == NULL) { -#ifdef GLX_USE_APPLEGL - gc = applegl_create_context(psc, cfg, share, 0); -#else - gc = indirect_create_context_attribs(psc, cfg, share, num_attribs, - (const uint32_t *) attrib_list, - &dummy_err); -#endif + /* Increment dpy->request in order to give a unique serial number to the error. + * This may break creating contexts on some video cards, if libx11 <1.7.4 is used. + * However, this fixes creating contexts (on some video cards) if libx11 >=1.7.4 is used. + */ + XNoOp(dpy); + /* -1 isn't a legal XID, which is sort of the point, we've failed + * before we even got to XID allocation. + */ + if (error == GLXBadContext || error == GLXBadFBConfig || + error == GLXBadProfileARB) + __glXSendError(dpy, error, -1, 0, False); + else + __glXSendError(dpy, error, -1, 0, True); + return NULL; } xid = xcb_generate_id(c); @@ -150,15 +160,6 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, __glXSendErrorForXcb(dpy, err); free(err); - } else if (!gc) { - /* the server thought the context description was okay, but we failed - * somehow on the client side. clean up the server resource and panic. - */ - xcb_glx_destroy_context(c, xid); - /* increment dpy->request in order to give a unique serial number to the - * error */ - XNoOp(dpy); - __glXSendError(dpy, GLXBadFBConfig, xid, 0, False); } else { gc->xid = xid; gc->share_xid = share_xid; |