From 81f77f999b5a4de9115c0f22c36c1953b57aeea7 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 19 Dec 2022 12:00:42 -0500 Subject: [PATCH] glx/dri3: Simplify protocol version tracking This is really just a single elaborate capability check, so stash a boolean in the display state for it. Part-of: --- src/glx/dri3_glx.c | 21 ++++++++++++--------- src/glx/dri3_priv.h | 10 +--------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 949ef0c40da..f957a431dc7 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -356,10 +356,7 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable, pdraw->base.psc = &psc->base; #ifdef HAVE_DRI3_MODIFIERS - if ((psc->image && psc->image->base.version >= 15) && - (pdp->dri3Major > 1 || (pdp->dri3Major == 1 && pdp->dri3Minor >= 2)) && - (pdp->presentMajor > 1 || - (pdp->presentMajor == 1 && pdp->presentMinor >= 2))) + if (pdp->has_multibuffer && psc->image && psc->image->base.version >= 15) has_multibuffer = true; #endif @@ -1095,7 +1092,7 @@ dri3_create_display(Display * dpy) PRESENT_SUPPORTED_MAJOR, PRESENT_SUPPORTED_MINOR); - pdp = malloc(sizeof *pdp); + pdp = calloc(1, sizeof *pdp); if (pdp == NULL) return NULL; @@ -1105,8 +1102,8 @@ dri3_create_display(Display * dpy) goto no_extension; } - pdp->dri3Major = dri3_reply->major_version; - pdp->dri3Minor = dri3_reply->minor_version; + int dri3Major = dri3_reply->major_version; + int dri3Minor = dri3_reply->minor_version; free(dri3_reply); present_reply = xcb_present_query_version_reply(c, present_cookie, &error); @@ -1114,10 +1111,16 @@ dri3_create_display(Display * dpy) free(error); goto no_extension; } - pdp->presentMajor = present_reply->major_version; - pdp->presentMinor = present_reply->minor_version; + int presentMajor = present_reply->major_version; + int presentMinor = present_reply->minor_version; free(present_reply); +#ifdef HAVE_DRI3_MODIFIERS + if ((dri3Major > 1 || (dri3Major == 1 && dri3Minor >= 2)) && + (presentMajor > 1 || (presentMajor == 1 && presentMinor >= 2))) + pdp->has_multibuffer = true; +#endif + pdp->base.destroyDisplay = dri3_destroy_display; pdp->base.createScreen = dri3_create_screen; diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h index c7ef8dff19c..862ce32baba 100644 --- a/src/glx/dri3_priv.h +++ b/src/glx/dri3_priv.h @@ -67,15 +67,7 @@ struct dri3_display __GLXDRIdisplay base; const __DRIextension **loader_extensions; - - /* DRI3 bits */ - int dri3Major; - int dri3Minor; - - /* Present bits */ - int hasPresent; - int presentMajor; - int presentMinor; + int has_multibuffer; }; struct dri3_screen {