From 2126a4814993eb56f199520bf61e0fbca7b96e6e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 19 Jul 2024 08:47:39 -0400 Subject: [PATCH] glx: move has_multibuffer to base glx_screen struct Reviewed-by: Adam Jackson Part-of: --- src/glx/dri3_glx.c | 11 +---------- src/glx/glxclient.h | 1 + src/glx/glxext.c | 10 ++++++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index ae0cb8b8a5c..ece0f573279 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -345,10 +345,6 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable, struct dri3_screen *psc = (struct dri3_screen *) base; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; bool has_multibuffer = false; -#ifdef HAVE_DRI3_MODIFIERS - const struct dri3_display *const pdp = (struct dri3_display *) - base->display->dri3Display; -#endif pdraw = calloc(1, sizeof(*pdraw)); if (!pdraw) @@ -360,7 +356,7 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable, pdraw->base.psc = &psc->base; #ifdef HAVE_DRI3_MODIFIERS - if (pdp->has_multibuffer && psc->image && psc->image->base.version >= 15) + if (base->display->has_multibuffer && psc->image && psc->image->base.version >= 15) has_multibuffer = true; #endif @@ -1060,15 +1056,10 @@ _X_HIDDEN __GLXDRIdisplay * dri3_create_display(Display * dpy) { struct dri3_display *pdp; - bool err = false; - bool has_multibuffer = loader_dri3_check_multibuffer(XGetXCBConnection(dpy), &err); - if (err) - return NULL; pdp = calloc(1, sizeof *pdp); if (pdp == NULL) return NULL; - pdp->has_multibuffer = has_multibuffer; return (void*)pdp; } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 0939916d99a..32fdce6240a 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -606,6 +606,7 @@ struct glx_display __GLXDRIdisplay *driswDisplay; __GLXDRIdisplay *dri2Display; __GLXDRIdisplay *dri3Display; + bool has_multibuffer; #endif #ifdef GLX_USE_WINDOWSGL __GLXDRIdisplay *windowsdriDisplay; diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 8f5b8b64824..d121a7028c1 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -903,6 +903,7 @@ __glXInitialize(Display * dpy) #if defined(GLX_DIRECT_RENDERING) && (!defined(GLX_USE_APPLEGL) || defined(GLX_USE_APPLE)) Bool glx_direct = !debug_get_bool_option("LIBGL_ALWAYS_INDIRECT", false); Bool glx_accel = !debug_get_bool_option("LIBGL_ALWAYS_SOFTWARE", false); + Bool dri3 = !debug_get_bool_option("LIBGL_DRI3_DISABLE", false); if (env && !strcmp(env, "zink")) glx_driver |= GLX_DRIVER_ZINK_YES; @@ -920,14 +921,15 @@ __glXInitialize(Display * dpy) ** (e.g., those called in AllocAndFetchScreenConfigs). */ #if defined(GLX_USE_DRM) + bool dri3_err = false; + if (glx_direct && glx_accel && dri3) + dpyPriv->has_multibuffer = loader_dri3_check_multibuffer(XGetXCBConnection(dpy), &dri3_err); if (glx_direct && glx_accel && (!(glx_driver & GLX_DRIVER_ZINK_YES) || debug_get_bool_option("LIBGL_KOPPER_DISABLE", false))) { #if defined(HAVE_DRI3) - if (!debug_get_bool_option("LIBGL_DRI3_DISABLE", false)) { - bool err = false; - loader_dri3_check_multibuffer(XGetXCBConnection(dpy), &err); + if (dri3) { /* dri3 is tried as long as this doesn't error; whether modifiers work is not relevant */ - if (!err) { + if (!dri3_err) { glx_driver |= GLX_DRIVER_DRI3; /* nouveau wants to fallback to zink so if we get a screen enable try_zink */ if (!debug_get_bool_option("LIBGL_KOPPER_DISABLE", false))