[PATCH] GLX: further improve GLX protocol version handling.

Luc Verhaegen libv at skynet.be
Fri Oct 2 07:27:13 PDT 2009


* The SERVER_GLX_*_VERSION defines now set the initial
  GLXScreen->GLXMajor/Minor values directly.
* The GLXScreen->GLXMajor/Minor versions of the different providers now
  are where glxMajor/MinorVersion get their values from.
* Keep the SERVER_GLX_*_VERSION defines where they belong to keep
  natural segmentation intact.

Warning: this patch was not even build tested.

Signed-off-by: Luc Verhaegen <libv at skynet.be>
---
 glx/glxext.c                |   45 ++++++++++++++++++++++--------------------
 glx/glxscreens.c            |    7 +----
 glx/glxserver.h             |    9 ++++++++
 include/protocol-versions.h |    4 ---
 4 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/glx/glxext.c b/glx/glxext.c
index 9f9c0ed..79de229 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -333,15 +333,19 @@ void GlxPushProvider(__GLXprovider *provider)
 }
 
 /*
+ * Track the lowest version of the GLX protocol that the different screens
+ * support so that it can be advertised in GLXQueryVersion.
+ */
+unsigned glxMajorVersion = 0;
+unsigned glxMinorVersion = 0;
+
+/*
 ** Initialize the GLX extension.
 */
 void GlxExtensionInit(void)
 {
     ExtensionEntry *extEntry;
-    ScreenPtr pScreen;
     int i;
-    __GLXprovider *p;
-    Bool glx_provided = False;
 
     __glXContextRes = CreateNewResourceType((DeleteType)ContextGone);
     __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
@@ -357,32 +361,31 @@ void GlxExtensionInit(void)
 	return;
 
     for (i = 0; i < screenInfo.numScreens; i++) {
-	pScreen = screenInfo.screens[i];
-
-	for (p = __glXProviderStack; p != NULL; p = p->next) {
-	    __GLXscreen *glxScreen;
-
-	    glxScreen = p->screenProbe(pScreen);
-	    if (glxScreen != NULL) {
-	        if (glxScreen->GLXminor < glxMinorVersion)
-		    glxMinorVersion = glxScreen->GLXminor;
-		LogMessage(X_INFO,
-			   "GLX: Initialized %s GL provider for screen %d\n",
-			   p->name, i);
+	__GLXscreen *glxScreen = NULL;
+	__GLXprovider *p;
+
+	for (p = __glXProviderStack; p != NULL; p = p->next)
+	    if ((glxScreen = p->screenProbe(screenInfo.screens[i])))
 		break;
-	    }
 
-	}
+	if (glxScreen) {
+	    /* Warning: we are not handling different major versions here! */
+	    if (!glxMajorVersion && !glxMinorVersion) {
+		glxMajorVersion = glxScreen->GLXmajor;
+		glxMinorVersion = glxScreen->GLXminor;
+	    } else if (glxScreen->GLXminor < glxMinorVersion)
+		glxMinorVersion = glxScreen->GLXminor;
 
-	if (!p)
+	    LogMessage(X_INFO,
+		       "GLX: Initialized %s GL provider for screen %d\n",
+		       p->name, i);
+	} else
 	    LogMessage(X_INFO,
 		       "GLX: no usable GL providers found for screen %d\n", i);
-	else
-	    glx_provided = True;
     }
 
     /* don't register extension if GL is not provided on any screen */
-    if (!glx_provided)
+    if (!glxMajorVersion && !glxMinorVersion)
 	return;
 
     /*
diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 674e2c6..7dad458 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -42,7 +42,6 @@
 #include "glxserver.h"
 #include "glxutil.h"
 #include "glxext.h"
-#include "protocol-versions.h"
 
 static int glxScreenPrivateKeyIndex;
 static DevPrivateKey glxScreenPrivateKey = &glxScreenPrivateKeyIndex;
@@ -163,8 +162,6 @@ static const char GLServerExtensions[] =
 ** supported across all screens in a multi-screen system.
 */
 static char GLXServerVendorName[] = "SGI";
-unsigned glxMajorVersion = SERVER_GLX_MAJOR_VERSION;
-unsigned glxMinorVersion = SERVER_GLX_MINOR_VERSION;
 static char GLXServerExtensions[] =
 			"GLX_ARB_multisample "
 			"GLX_EXT_visual_info "
@@ -388,8 +385,8 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
      * most providers, the screen-probe routine is the caller of this
      * function.
      */
-    pGlxScreen->GLXmajor      = 1;
-    pGlxScreen->GLXminor      = 2;
+    pGlxScreen->GLXmajor      = SERVER_GLX_MAJOR_VERSION;
+    pGlxScreen->GLXminor      = SERVER_GLX_MINOR_VERSION;
 
     pGlxScreen->CloseScreen = pScreen->CloseScreen;
     pScreen->CloseScreen = glxCloseScreen;
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 80f1b28..3df37f2 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -248,6 +248,15 @@ extern int __glXImageSize(GLenum format, GLenum type,
     GLint imageHeight, GLint rowLength, GLint skipImages, GLint skipRows,
     GLint alignment);
 
+/* All GLX providers must support all of the functionality required for at
+ * least GLX 1.2.  If the provider supports a higher version, the GLXminor
+ * version can be changed in the provider's screen-probe routine.  For
+ * most providers, the screen-probe routine is the caller of this
+ * function.
+ */
+#define SERVER_GLX_MAJOR_VERSION		1
+#define SERVER_GLX_MINOR_VERSION		2
+
 extern unsigned glxMajorVersion;
 extern unsigned glxMinorVersion;
 
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index d688c66..e97a84c 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -59,10 +59,6 @@
 #define SERVER_GE_MAJOR_VERSION                 1
 #define SERVER_GE_MINOR_VERSION                 0
 
-/* GLX */
-#define SERVER_GLX_MAJOR_VERSION		1
-#define SERVER_GLX_MINOR_VERSION		4
-
 /* Xinerama */
 #define SERVER_PANORAMIX_MAJOR_VERSION          1
 #define SERVER_PANORAMIX_MINOR_VERSION		1
-- 
1.6.0.2


--J2SCkAp4GZ/dPZZf--


More information about the xorg-devel mailing list