From e716088c24a5544dc81c8118273bcb018d46c5b0 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 22 Apr 2021 13:10:44 -0400 Subject: [PATCH] glx: Stop pretending the GLX major number isn't 1 Clarify the comments and logic accordingly. Part-of: --- src/glx/clientinfo.c | 8 ++++---- src/glx/glx_pbuffer.c | 14 +++++--------- src/glx/glxclient.h | 7 ++++--- src/glx/glxcmds.c | 4 ++-- src/glx/glxext.c | 16 ++++++++-------- src/glx/indirect_glx.c | 2 +- src/glx/tests/clientinfo_unittest.cpp | 1 - 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/glx/clientinfo.c b/src/glx/clientinfo.c index aed2619888e..9ea7cb2d868 100644 --- a/src/glx/clientinfo.c +++ b/src/glx/clientinfo.c @@ -96,7 +96,7 @@ __glX_send_client_info(struct glx_display *glx_dpy) /* There are three possible flavors of the client info structure that the * client could send to the server. The version sent depends on the * combination of GLX versions and extensions supported by the client and - * the server. + * the server. This client only supports GLX major version 1. * * Server supports Client sends * ---------------------------------------------------------------------- @@ -117,7 +117,7 @@ __glX_send_client_info(struct glx_display *glx_dpy) * requirement in this case does not seem like a limitation. */ - if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 0) + if (glx_dpy->minorVersion == 0) return; /* Determine whether any screen on the server supports either of the @@ -170,7 +170,7 @@ __glX_send_client_info(struct glx_display *glx_dpy) * THE ORDER IS IMPORTANT. We want to send the most recent version of the * protocol that the server can support. */ - if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 4 + if (glx_dpy->minorVersion == 4 && any_screen_has_ARB_create_context_profile) { xcb_glx_set_client_info_2arb(c, GLX_MAJOR_VERSION, GLX_MINOR_VERSION, @@ -181,7 +181,7 @@ __glX_send_client_info(struct glx_display *glx_dpy) gl_versions_profiles, gl_extension_string, glx_extensions); - } else if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 4 + } else if (glx_dpy->minorVersion == 4 && any_screen_has_ARB_create_context) { xcb_glx_set_client_info_arb(c, GLX_MAJOR_VERSION, GLX_MINOR_VERSION, diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c index 7de6430b51a..59bdda36daa 100644 --- a/src/glx/glx_pbuffer.c +++ b/src/glx/glx_pbuffer.c @@ -102,7 +102,7 @@ ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable, LockDisplay(dpy); - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + if (priv->minorVersion >= 3) { xGLXChangeDrawableAttributesReq *req; GetReqExtra(GLXChangeDrawableAttributes, 8 * num_attribs, req); @@ -272,7 +272,6 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable, unsigned int length; unsigned int i; unsigned int num_attributes; - GLboolean use_glx_1_3; int found = 0; #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) @@ -296,11 +295,8 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable, if (priv == NULL) return 0; - use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); - *value = 0; - opcode = __glXSetupForCommand(dpy); if (!opcode) return 0; @@ -351,7 +347,7 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable, LockDisplay(dpy); - if (use_glx_1_3) { + if (priv->minorVersion >= 3) { xGLXGetDrawableAttributesReq *req; GetReq(GLXGetDrawableAttributes, req); @@ -381,7 +377,7 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable, length = reply.length; if (length) { - num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; + num_attributes = (priv->minorVersion > 2) ? reply.numAttribs : length / 2; data = malloc(length * sizeof(CARD32)); if (data == NULL) { /* Throw data on the floor */ @@ -569,7 +565,7 @@ CreatePbuffer(Display * dpy, struct glx_config *config, LockDisplay(dpy); id = XAllocID(dpy); - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + if (priv->minorVersion >= 3) { xGLXCreatePbufferReq *req; unsigned int extra = (size_in_attribs) ? 0 : 2; @@ -658,7 +654,7 @@ DestroyPbuffer(Display * dpy, GLXDrawable drawable) LockDisplay(dpy); - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + if (priv->minorVersion >= 3) { xGLXDestroyPbufferReq *req; GetReq(GLXDestroyPbuffer, req); diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index a3d2447be0a..78fe46e53af 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -574,12 +574,13 @@ struct glx_display int majorOpcode; /** - * \name Server Version + * \name Minor Version * - * Major and minor version returned by the server during initialization. + * Minor version returned by the server during initialization. The major + * version is asserted to be 1 during extension setup. */ /*@{ */ - int majorVersion, minorVersion; + int minorVersion; /*@} */ /** diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 4c946a246b5..e39521503fd 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -531,7 +531,7 @@ glXQueryVersion(Display * dpy, int *major, int *minor) return False; if (major) - *major = priv->majorVersion; + *major = GLX_MAJOR_VERSION; if (minor) *minor = priv->minorVersion; return True; @@ -1461,7 +1461,7 @@ glXImportContextEXT(Display *dpy, GLXContextID contextID) /* Send the glXQueryContextInfoEXT request */ LockDisplay(dpy); - if (priv->majorVersion > 1 || priv->minorVersion >= 3) { + if (priv->minorVersion >= 3) { xGLXQueryContextReq *req; GetReq(GLXQueryContext, req); diff --git a/src/glx/glxext.c b/src/glx/glxext.c index d016a737892..548982436c6 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -720,7 +720,7 @@ getVisualConfigs(struct glx_screen *psc, } static GLboolean - getFBConfigs(struct glx_screen *psc, struct glx_display *priv, int screen) +getFBConfigs(struct glx_screen *psc, struct glx_display *priv, int screen) { xGLXGetFBConfigsReq *fb_req; xGLXGetFBConfigsSGIXReq *sgi_req; @@ -738,8 +738,7 @@ static GLboolean LockDisplay(dpy); psc->configs = NULL; - if (priv->majorVersion > 1 || - (priv->majorVersion == 1 && priv->minorVersion >= 3)) { + if (priv->minorVersion >= 3) { GetReq(GLXGetFBConfigs, fb_req); fb_req->reqType = priv->majorOpcode; fb_req->glxCode = X_GLXGetFBConfigs; @@ -874,7 +873,7 @@ __glXInitialize(Display * dpy) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) Bool glx_direct, glx_accel; #endif - int i; + int i, majorVersion = 0; _XLockMutex(_Xglobal_lock); @@ -903,12 +902,13 @@ __glXInitialize(Display * dpy) dpyPriv->serverGLXvendor = 0x0; dpyPriv->serverGLXversion = 0x0; - /* See if the versions are compatible. This GLX implementation does not - * work with servers that only support GLX 1.0. + /* This GLX implementation requires X_GLXQueryExtensionsString + * and X_GLXQueryServerString, which are new in GLX 1.1. */ if (!QueryVersion(dpy, dpyPriv->majorOpcode, - &dpyPriv->majorVersion, &dpyPriv->minorVersion) - || (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion < 1)) { + &majorVersion, &dpyPriv->minorVersion) + || (majorVersion != 1) + || (majorVersion == 1 && dpyPriv->minorVersion < 1)) { free(dpyPriv); return NULL; } diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index fb60cc0ff5b..db26605b8b2 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -90,7 +90,7 @@ SendMakeCurrentRequest(Display * dpy, GLXContextID gc_id, * not the SGI extension. */ - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + if (priv->minorVersion >= 3) { xGLXMakeContextCurrentReq *req; GetReq(GLXMakeContextCurrent, req); diff --git a/src/glx/tests/clientinfo_unittest.cpp b/src/glx/tests/clientinfo_unittest.cpp index fe168d2677a..991e0170241 100644 --- a/src/glx/tests/clientinfo_unittest.cpp +++ b/src/glx/tests/clientinfo_unittest.cpp @@ -43,7 +43,6 @@ public: this->next = 0; this->dpy = dpy; this->majorOpcode = 0; - this->majorVersion = major; this->minorVersion = minor; this->serverGLXvendor = 0; this->serverGLXversion = 0;