diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index d39cd85ce18..561a51d94c1 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -49,6 +49,7 @@ DRI_CONF_SECTION_DEBUG DRI_CONF_FORCE_GL_VENDOR() DRI_CONF_FORCE_GL_RENDERER() DRI_CONF_OVERRIDE_VRAM_SIZE() + DRI_CONF_GLX_CLEAR_CONTEXT_RESET_ISOLATION_BIT(false) DRI_CONF_GLX_EXTENSION_OVERRIDE() DRI_CONF_MESA_EXTENSION_OVERRIDE() DRI_CONF_INDIRECT_GL_EXTENSION_OVERRIDE() diff --git a/src/glx/create_context.c b/src/glx/create_context.c index 7f3f92365b6..ef314d3c439 100644 --- a/src/glx/create_context.c +++ b/src/glx/create_context.c @@ -22,6 +22,7 @@ */ #include +#include "dri_util.h" #include "glxclient.h" #include "glx_error.h" #include @@ -44,7 +45,7 @@ GLXContext glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, - const int *attrib_list) + const int *orig_attrib_list) { xcb_connection_t *const c = XGetXCBConnection(dpy); struct glx_config *const cfg = (struct glx_config *) config; @@ -57,6 +58,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, unsigned error = BadImplementation; uint32_t xid, share_xid; int screen = -1; + int *attrib_list = NULL; if (dpy == NULL) return NULL; @@ -64,8 +66,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, /* Count the number of attributes specified by the application. All * attributes appear in pairs, except the terminating None. */ - if (attrib_list != NULL) { - for (/* empty */; attrib_list[num_attribs * 2] != 0; num_attribs++) + if (orig_attrib_list != NULL) { + for (/* empty */; orig_attrib_list[num_attribs * 2] != 0; num_attribs++) /* empty */ ; } @@ -73,8 +75,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, screen = cfg->screen; } else { for (unsigned int i = 0; i < num_attribs; i++) { - if (attrib_list[i * 2] == GLX_SCREEN) - screen = attrib_list[i * 2 + 1]; + if (orig_attrib_list[i * 2] == GLX_SCREEN) + screen = orig_attrib_list[i * 2 + 1]; } if (screen == -1) { __glXSendError(dpy, BadValue, 0, X_GLXCreateContextAttribsARB, True); @@ -92,6 +94,27 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, assert(screen == psc->scr); + if (orig_attrib_list != NULL) { + attrib_list = malloc(sizeof(int) * num_attribs * 2); + + uint8_t clear_ctx_reset_isolation_bit = false; + dri2GalliumConfigQueryb(psc->frontend_screen, + "glx_clear_context_reset_isolation_bit", + &clear_ctx_reset_isolation_bit); + + for (unsigned i = 0; i < num_attribs; i++) { + attrib_list[i * 2] = orig_attrib_list[i * 2]; + if (clear_ctx_reset_isolation_bit && + attrib_list[i * 2] == GLX_CONTEXT_FLAGS_ARB) { + attrib_list[i * 2 + 1] = + orig_attrib_list[i * 2 + 1] & ~__DRI_CTX_FLAG_RESET_ISOLATION; + } else { + attrib_list[i * 2 + 1] = + orig_attrib_list[i * 2 + 1]; + } + } + } + /* Some application may request an indirect context but we may want to force a direct * one because Xorg only allows indirect contexts if they were enabled. */ @@ -130,6 +153,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, __glXSendError(dpy, error, -1, 0, False); else __glXSendError(dpy, error, -1, 0, True); + + free(attrib_list); return NULL; } @@ -167,5 +192,6 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, gc->share_xid = share_xid; } + free(attrib_list); return (GLXContext) gc; } diff --git a/src/util/driconf.h b/src/util/driconf.h index 25f6879c17b..42a1c213df1 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -308,6 +308,9 @@ DRI_CONF_OPT_S_NODEF(glx_extension_override, \ "Allow enabling/disabling a list of GLX extensions") +#define DRI_CONF_GLX_CLEAR_CONTEXT_RESET_ISOLATION_BIT(def) \ + DRI_CONF_OPT_B(glx_clear_context_reset_isolation_bit, def, "Clear context reset isolation bit before creating context") + #define DRI_CONF_INDIRECT_GL_EXTENSION_OVERRIDE() \ DRI_CONF_OPT_S_NODEF(indirect_gl_extension_override, \ "Allow enabling/disabling a list of indirect-GL extensions")