glx: Stop pretending the GLX major number isn't 1

Clarify the comments and logic accordingly.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10418>
This commit is contained in:
Adam Jackson 2021-04-22 13:10:44 -04:00 committed by Marge Bot
parent 96ec6b3d8f
commit e716088c24
7 changed files with 24 additions and 28 deletions

View File

@ -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 /* There are three possible flavors of the client info structure that the
* client could send to the server. The version sent depends on the * client could send to the server. The version sent depends on the
* combination of GLX versions and extensions supported by the client and * 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 * 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. * 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; return;
/* Determine whether any screen on the server supports either of the /* 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 * THE ORDER IS IMPORTANT. We want to send the most recent version of the
* protocol that the server can support. * 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) { && any_screen_has_ARB_create_context_profile) {
xcb_glx_set_client_info_2arb(c, xcb_glx_set_client_info_2arb(c,
GLX_MAJOR_VERSION, GLX_MINOR_VERSION, GLX_MAJOR_VERSION, GLX_MINOR_VERSION,
@ -181,7 +181,7 @@ __glX_send_client_info(struct glx_display *glx_dpy)
gl_versions_profiles, gl_versions_profiles,
gl_extension_string, gl_extension_string,
glx_extensions); glx_extensions);
} else if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 4 } else if (glx_dpy->minorVersion == 4
&& any_screen_has_ARB_create_context) { && any_screen_has_ARB_create_context) {
xcb_glx_set_client_info_arb(c, xcb_glx_set_client_info_arb(c,
GLX_MAJOR_VERSION, GLX_MINOR_VERSION, GLX_MAJOR_VERSION, GLX_MINOR_VERSION,

View File

@ -102,7 +102,7 @@ ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
LockDisplay(dpy); LockDisplay(dpy);
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { if (priv->minorVersion >= 3) {
xGLXChangeDrawableAttributesReq *req; xGLXChangeDrawableAttributesReq *req;
GetReqExtra(GLXChangeDrawableAttributes, 8 * num_attribs, req); GetReqExtra(GLXChangeDrawableAttributes, 8 * num_attribs, req);
@ -272,7 +272,6 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
unsigned int length; unsigned int length;
unsigned int i; unsigned int i;
unsigned int num_attributes; unsigned int num_attributes;
GLboolean use_glx_1_3;
int found = 0; int found = 0;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
@ -296,11 +295,8 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
if (priv == NULL) if (priv == NULL)
return 0; return 0;
use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3));
*value = 0; *value = 0;
opcode = __glXSetupForCommand(dpy); opcode = __glXSetupForCommand(dpy);
if (!opcode) if (!opcode)
return 0; return 0;
@ -351,7 +347,7 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
LockDisplay(dpy); LockDisplay(dpy);
if (use_glx_1_3) { if (priv->minorVersion >= 3) {
xGLXGetDrawableAttributesReq *req; xGLXGetDrawableAttributesReq *req;
GetReq(GLXGetDrawableAttributes, req); GetReq(GLXGetDrawableAttributes, req);
@ -381,7 +377,7 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
length = reply.length; length = reply.length;
if (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)); data = malloc(length * sizeof(CARD32));
if (data == NULL) { if (data == NULL) {
/* Throw data on the floor */ /* Throw data on the floor */
@ -569,7 +565,7 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
LockDisplay(dpy); LockDisplay(dpy);
id = XAllocID(dpy); id = XAllocID(dpy);
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { if (priv->minorVersion >= 3) {
xGLXCreatePbufferReq *req; xGLXCreatePbufferReq *req;
unsigned int extra = (size_in_attribs) ? 0 : 2; unsigned int extra = (size_in_attribs) ? 0 : 2;
@ -658,7 +654,7 @@ DestroyPbuffer(Display * dpy, GLXDrawable drawable)
LockDisplay(dpy); LockDisplay(dpy);
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { if (priv->minorVersion >= 3) {
xGLXDestroyPbufferReq *req; xGLXDestroyPbufferReq *req;
GetReq(GLXDestroyPbuffer, req); GetReq(GLXDestroyPbuffer, req);

View File

@ -574,12 +574,13 @@ struct glx_display
int majorOpcode; 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;
/*@} */ /*@} */
/** /**

View File

@ -531,7 +531,7 @@ glXQueryVersion(Display * dpy, int *major, int *minor)
return False; return False;
if (major) if (major)
*major = priv->majorVersion; *major = GLX_MAJOR_VERSION;
if (minor) if (minor)
*minor = priv->minorVersion; *minor = priv->minorVersion;
return True; return True;
@ -1461,7 +1461,7 @@ glXImportContextEXT(Display *dpy, GLXContextID contextID)
/* Send the glXQueryContextInfoEXT request */ /* Send the glXQueryContextInfoEXT request */
LockDisplay(dpy); LockDisplay(dpy);
if (priv->majorVersion > 1 || priv->minorVersion >= 3) { if (priv->minorVersion >= 3) {
xGLXQueryContextReq *req; xGLXQueryContextReq *req;
GetReq(GLXQueryContext, req); GetReq(GLXQueryContext, req);

View File

@ -720,7 +720,7 @@ getVisualConfigs(struct glx_screen *psc,
} }
static GLboolean 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; xGLXGetFBConfigsReq *fb_req;
xGLXGetFBConfigsSGIXReq *sgi_req; xGLXGetFBConfigsSGIXReq *sgi_req;
@ -738,8 +738,7 @@ static GLboolean
LockDisplay(dpy); LockDisplay(dpy);
psc->configs = NULL; psc->configs = NULL;
if (priv->majorVersion > 1 || if (priv->minorVersion >= 3) {
(priv->majorVersion == 1 && priv->minorVersion >= 3)) {
GetReq(GLXGetFBConfigs, fb_req); GetReq(GLXGetFBConfigs, fb_req);
fb_req->reqType = priv->majorOpcode; fb_req->reqType = priv->majorOpcode;
fb_req->glxCode = X_GLXGetFBConfigs; fb_req->glxCode = X_GLXGetFBConfigs;
@ -874,7 +873,7 @@ __glXInitialize(Display * dpy)
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
Bool glx_direct, glx_accel; Bool glx_direct, glx_accel;
#endif #endif
int i; int i, majorVersion = 0;
_XLockMutex(_Xglobal_lock); _XLockMutex(_Xglobal_lock);
@ -903,12 +902,13 @@ __glXInitialize(Display * dpy)
dpyPriv->serverGLXvendor = 0x0; dpyPriv->serverGLXvendor = 0x0;
dpyPriv->serverGLXversion = 0x0; dpyPriv->serverGLXversion = 0x0;
/* See if the versions are compatible. This GLX implementation does not /* This GLX implementation requires X_GLXQueryExtensionsString
* work with servers that only support GLX 1.0. * and X_GLXQueryServerString, which are new in GLX 1.1.
*/ */
if (!QueryVersion(dpy, dpyPriv->majorOpcode, if (!QueryVersion(dpy, dpyPriv->majorOpcode,
&dpyPriv->majorVersion, &dpyPriv->minorVersion) &majorVersion, &dpyPriv->minorVersion)
|| (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion < 1)) { || (majorVersion != 1)
|| (majorVersion == 1 && dpyPriv->minorVersion < 1)) {
free(dpyPriv); free(dpyPriv);
return NULL; return NULL;
} }

View File

@ -90,7 +90,7 @@ SendMakeCurrentRequest(Display * dpy, GLXContextID gc_id,
* not the SGI extension. * not the SGI extension.
*/ */
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { if (priv->minorVersion >= 3) {
xGLXMakeContextCurrentReq *req; xGLXMakeContextCurrentReq *req;
GetReq(GLXMakeContextCurrent, req); GetReq(GLXMakeContextCurrent, req);

View File

@ -43,7 +43,6 @@ public:
this->next = 0; this->next = 0;
this->dpy = dpy; this->dpy = dpy;
this->majorOpcode = 0; this->majorOpcode = 0;
this->majorVersion = major;
this->minorVersion = minor; this->minorVersion = minor;
this->serverGLXvendor = 0; this->serverGLXvendor = 0;
this->serverGLXversion = 0; this->serverGLXversion = 0;