? dri/DONE
? dri/Makefile
? dri/drm/DONE
? dri/drm/Makefile
? glx/DONE
? glx/Makefile
? glx/glxextensions.patch
? glx/glxextensions2.patch
Index: dri/dri_glx.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/dri/dri_glx.c,v
retrieving revision 1.29.4.1
diff -u -r1.29.4.1 dri_glx.c
--- dri/dri_glx.c	26 May 2003 17:41:59 -0000	1.29.4.1
+++ dri/dri_glx.c	9 Aug 2003 20:57:37 -0000
@@ -230,8 +230,6 @@
             dlclose(handle);
             continue;
          }
-         driver->registerExtensionsFunc = (RegisterExtensionsFunc)
-            dlsym(handle, "__driRegisterExtensions");
          driver->handle = handle;
          /* put at head of linked list */
          driver->next = Drivers;
@@ -435,7 +433,6 @@
      * driver's "__driCreateScreen" function pointer.  That's the bootstrap
      * entrypoint for all DRI drivers.
      */
-    __glXRegisterExtensions();
     for (scrn = 0; scrn < numScreens; scrn++) {
         __DRIdriver *driver = driGetDriver(dpy, scrn);
         if (driver) {
@@ -451,71 +448,5 @@
 
     return (void *)pdpyp;
 }
-
-
-
-/*
-** Here we'll query the DRI driver for each screen and let each
-** driver register its GL extension functions.  We only have to
-** do this once.
-**
-** In older versions of libGL (prior to October 2002) we _always_
-** called this function during libGL start-up.  Now, we only call
-** it from glXGetProcAddress() as a last resort.
-**
-** Two key things changed along the way:
-** 1. _glapi_get_proc_address() now generates new dispatch stub functions
-**    anytime it gets an unknown "gl*" function name.  I.e. we always return
-**    a valid function address and later patch it up to use the correct
-**    dispatch offset.
-** 2. The GL API dispatch table is a fixed size (with plenty of extra slots).
-**    This means we don't have to register all new functions before we create
-**    the first dispatch table.
-*/
-void
-__glXRegisterExtensions(void)
-{
-#ifndef BUILT_IN_DRI_DRIVER
-   static GLboolean alreadyCalled = GL_FALSE;
-   int displayNum, maxDisplays;
-
-   if (alreadyCalled)
-      return;
-   alreadyCalled = GL_TRUE;
-
-   if (getenv("LIBGL_MULTIHEAD")) {
-      /* we'd like to always take this path but doing so causes a second
-       * or more of delay while the XOpenDisplay() function times out.
-       */
-      maxDisplays = 10;  /* infinity, really */
-   }
-   else {
-      /* just open the :0 display */
-      maxDisplays = 1;
-   }
-
-   for (displayNum = 0; displayNum < maxDisplays; displayNum++) {
-      char displayName[200];
-      Display *dpy;
-      snprintf(displayName, 199, ":%d.0", displayNum);
-      dpy = XOpenDisplay(displayName);
-      if (dpy) {
-         const int numScreens = ScreenCount(dpy);
-         int screenNum;
-         for (screenNum = 0; screenNum < numScreens; screenNum++) {
-            __DRIdriver *driver = driGetDriver(dpy, screenNum);
-            if (driver && driver->registerExtensionsFunc) {
-               (*driver->registerExtensionsFunc)();
-            }
-         }
-         XCloseDisplay(dpy);
-      }
-      else {
-         break;
-      }
-   }
-#endif
-}
-
 
 #endif /* GLX_DIRECT_RENDERING */
Index: dri/dri_util.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/dri/dri_util.c,v
retrieving revision 1.13
diff -u -r1.13 dri_util.c
--- dri/dri_util.c	21 May 2003 17:32:04 -0000	1.13
+++ dri/dri_util.c	9 Aug 2003 20:57:51 -0000
@@ -1031,6 +1031,7 @@
     if (!psp) {
 	return NULL;
     }
+    psp->psc = psc;
     psp->fullscreen = NULL;
     psp->display = dpy;
     psp->myNum = scrn;
Index: dri/dri_util.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/dri/dri_util.h,v
retrieving revision 1.8
diff -u -r1.8 dri_util.h
--- dri/dri_util.h	21 May 2003 17:32:05 -0000	1.8
+++ dri/dri_util.h	9 Aug 2003 20:57:56 -0000
@@ -406,6 +406,11 @@
     */
     int numConfigs;
     __GLXvisualConfig *configs;
+
+    /*
+    ** Point back to the containing __DRIscreen
+    */
+    __DRIscreen *psc;
 };
 
 
Index: glx/glxclient.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/glx/glxclient.h,v
retrieving revision 1.28.2.1
diff -u -r1.28.2.1 glxclient.h
--- glx/glxclient.h	26 May 2003 17:41:59 -0000	1.28.2.1
+++ glx/glxclient.h	9 Aug 2003 20:58:04 -0000
@@ -167,6 +167,12 @@
     ** Added with internal API version "20030317".
     */
     int (*getMSC)( void *screenPrivate, int64_t *msc );
+
+    /*
+    ** Per screen dynamic client GLX extensions
+    */
+    unsigned char direct_support[8];
+    GLboolean ext_list_first_time; /* = GL_TRUE */
 };
 
 /*
@@ -292,8 +298,6 @@
 typedef void *(*CreateScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
                                   int numConfigs, __GLXvisualConfig *config);
 
-typedef void *(*RegisterExtensionsFunc)(void);
-
 /*
 ** We keep a linked list of these structures, one per DRI device driver.
 */
@@ -301,7 +305,6 @@
    const char *name;
    void *handle;
    CreateScreenFunc createScreenFunc;
-   RegisterExtensionsFunc registerExtensionsFunc;
    struct __DRIdriverRec *next;
 };
 
@@ -650,15 +653,6 @@
 
 /* Initialize the GLX extension for dpy */
 extern __GLXdisplayPrivate *__glXInitialize(Display*);
-
-/* Query drivers for dynamically registered extensions */
-extern void __glXRegisterExtensions(void);
-
-/* Functions for extending the GLX API: */
-extern void *__glXRegisterGLXFunction(const char *funcName, void *funcAddr);
-extern void __glXRegisterGLXExtensionString(const char *extName);
-typedef void * (* PFNGLXREGISTERGLXFUNCTIONPROC) ( const char * funcName,
-						   void * funcAdd );
 
 /************************************************************************/
 
Index: glx/glxcmds.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/glx/glxcmds.c,v
retrieving revision 1.41.2.1
diff -u -r1.41.2.1 glxcmds.c
--- glx/glxcmds.c	26 May 2003 17:41:59 -0000	1.41.2.1
+++ glx/glxcmds.c	9 Aug 2003 20:58:35 -0000
@@ -1330,7 +1330,11 @@
 					  	   screen, GLX_EXTENSIONS);
 	}
 
-	psc->effectiveGLXexts = (char *) __glXGetUsableExtensions(psc->serverGLXexts);
+#ifdef GLX_DIRECT_RENDERING
+	psc->effectiveGLXexts = (char *) __glXGetUsableExtensions(&psc->driScreen, psc->serverGLXexts);
+#else
+	psc->effectiveGLXexts = (char *) __glXGetUsableExtensions(NULL, psc->serverGLXexts);
+#endif
     }
 
     return psc->effectiveGLXexts;
@@ -2936,13 +2940,10 @@
    { "__glXInitialize", (GLvoid *) __glXInitialize, NULL },
    { "__glXFindDRIScreen", (GLvoid *) __glXFindDRIScreen, NULL },
    { "__glXGetInternalVersion", (GLvoid *) __glXGetInternalVersion, NULL },
-   { "__glXRegisterGLXExtensionString", (GLvoid *) __glXRegisterGLXExtensionString, NULL },
-   { "__glXRegisterGLXFunction", (GLvoid *) __glXRegisterGLXFunction, NULL },
    { "__glXWindowExists", (GLvoid *) __glXWindowExists, NULL },
 
-   { "__glXEnableExtension", (GLvoid *) __glXEnableExtension, NULL },
-   { "__glXDisableExtension", (GLvoid *) __glXDisableExtension, NULL },
-   { "__glXAddExtension", (GLvoid *) __glXAddExtension, NULL },
+   { "__glXScrEnableExtension", (GLvoid *) __glXScrEnableExtension, NULL },
+   { "__glXScrDisableExtension", (GLvoid *) __glXScrDisableExtension, NULL },
 
    { "__glXGetUST", (GLvoid *) __glXGetUST, NULL },
 
@@ -2950,85 +2951,11 @@
 };
 
 
-static struct name_address_pair *Dynamic_GLX_functions = NULL;
-
-
-/*
- * Drivers can call this function to append the name of a new GLX
- * extension string to __glXGLXClientExtensions.  Then, when the user
- * calls glXGetClientString() they'll see it listed.
- * This is a companion to __glXRegisterGLXFunction().
- */
-void
-__glXRegisterGLXExtensionString(const char *extName)
-{
-   __glXEnableExtension( extName, GL_TRUE );
-}
-
-
-/**
- * DRI drivers should call this function if they want to extend
- * the GLX API.  After registering a new GLX function, the user
- * can query and use it by calling \c glXGetProcAddress.
- * 
- * \param funcName name of new GLX function
- * \param funcAddr pointer to the function
- * \return Address of previously registered function with this name or NULL.
- * 
- * \sa __glXEnableExtension glXGetProcAddress
-  */
-void *
-__glXRegisterGLXFunction(const char *funcName, void *funcAddr)
-{
-   struct name_address_pair *ext;
-
-   assert(funcName);
-   assert(funcName[0] == 'g');
-   assert(funcName[1] == 'l');
-   assert(funcName[2] == 'X');
-
-   /* look if the function is already registered */
-   for (ext = Dynamic_GLX_functions; ext; ext = ext->Next) {
-      if (strcmp(ext->Name, funcName) == 0) {
-	 /* It's up the caller to use this return value if he wants
-	  * to chain-call or wrap the previously registered function.
-	  */
-         void *prevAddr = ext->Address;
-	 ext->Address = funcAddr;
-	 return prevAddr;
-      }
-   }
-
-   /* add new function */
-   ext = Xmalloc(sizeof(struct name_address_pair));
-   if (!ext)
-      return NULL;
-   ext->Name = __glXstrdup(funcName);
-   if (!ext->Name) {
-      Xfree(ext);
-      return NULL;
-   }
-   ext->Address = funcAddr;
-   ext->Next = Dynamic_GLX_functions;
-   Dynamic_GLX_functions = ext;
-   return NULL;
-}
-
-
 static const GLvoid *
 get_glx_proc_address(const char *funcName, GLboolean dynamic_only)
 {
-   const struct name_address_pair *ext;
    GLuint i;
 
-   /* try dynamic functions */
-   for (ext = Dynamic_GLX_functions; ext; ext = ext->Next) {
-      if (strcmp(ext->Name, funcName) == 0) {
-	 return ext->Address;
-      }
-   }
-
-   /* try static functions */
    if ( ! dynamic_only ) {	
       for (i = 0; GLX_functions[i].Name; i++) {
 	 if (strcmp(GLX_functions[i].Name, funcName) == 0)
@@ -3056,7 +2983,6 @@
        * dynamically added by a driver.  Call __glXRegisterExtensions()
        * to try to make that happen.
        */
-      __glXRegisterExtensions();
       f = (gl_function) get_glx_proc_address((const char *) procName, GL_TRUE);
       return f; /* may be NULL */
    }
Index: glx/glxext.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/glx/glxext.c,v
retrieving revision 1.28
diff -u -r1.28 glxext.c
--- glx/glxext.c	13 May 2003 13:48:21 -0000	1.28
+++ glx/glxext.c	9 Aug 2003 20:58:48 -0000
@@ -775,18 +775,15 @@
 	if (priv->driDisplay.private &&
 		priv->driDisplay.createScreen &&
 		priv->driDisplay.createScreen[i]) {
-	    /* register glx extensions */
-            __DRIdriver *driver = driGetDriver(dpy, i);
-	    if (driver && driver->registerExtensionsFunc)
-		(*driver->registerExtensionsFunc)();
 	    /* screen initialization (bootstrap the driver) */
-
 	    if ( (psc->old_configs == NULL)
 		 && !FillInVisuals(psc) ) {
 		FreeScreenConfigs(priv);
 		return GL_FALSE;
 	    }
 			
+	    /* Initialize per screen dynamic client GLX extension data */
+	    psc->driScreen.ext_list_first_time = GL_TRUE;
 	    psc->driScreen.private =
 		(*(priv->driDisplay.createScreen[i]))(dpy, i, &psc->driScreen,
 						 psc->numOldConfigs,
Index: glx/glxextensions.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/glx/glxextensions.c,v
retrieving revision 1.3
diff -u -r1.3 glxextensions.c
--- glx/glxextensions.c	3 May 2003 05:19:30 -0000	1.3
+++ glx/glxextensions.c	9 Aug 2003 20:58:53 -0000
@@ -116,18 +116,23 @@
    { NULL }
 };
 
+/* global list of available extensions */
 static struct glx_extension  ext_list;
 static GLboolean ext_list_first_time = GL_TRUE;
 static GLuint next_bit = 0;
 
+/* global bit-fields of available extensions and their characteristics */
 static unsigned char client_support[8];
-static unsigned char direct_support[8];
 static unsigned char client_only[8];
 static unsigned char direct_only[8];
+/* extensions enabled by default on all screens */
+static unsigned char direct_support[8];
 
+/* client extensions string */
 static const char * __glXGLXClientExtensions = NULL;
 
 static void __glXExtensionsCtr( void );
+static void __glXExtensionsCtrScreen( __DRIscreen *psc );
 static void __glXProcessServerString( const char * server_string,
     unsigned char * server_support );
 
@@ -209,39 +214,35 @@
 
 
 /**
- * Enable a named GLX extension.
+ * Enable a named GLX extension on a given screen.
  * 
  * \param name  Name of the extension to enable.
- * \param force_client  Enable client-side support also.  If this is set
- *                      to GL_TRUE, then the driver MUST supply function
- *                      entry-points via \c __glXRegisterGLXFunction.
- * \sa __glXRegisterGLXFunction, __glXDisableExtension
+ * \sa __glXDisableExtension
  */
 void
-__glXEnableExtension( const char * name, GLboolean force_client )
+__glXScrEnableExtension( __DRIscreen *psc, const char * name )
 {
    if ( __glXGLXClientExtensions == NULL ) {
       __glXExtensionsCtr();
-      set_glx_extension( name, strlen( name ), GL_TRUE, direct_support );
-      if ( force_client ) {
-	 set_glx_extension( name, strlen( name ), GL_TRUE, client_support );
-      }
+      __glXExtensionsCtrScreen(psc);
+      set_glx_extension( name, strlen( name ), GL_TRUE, psc->direct_support );
    }
 }
 
 
 /**
- * Disable a named GLX extension.
+ * Disable a named GLX extension on a given screen.
  * 
  * \param name  Name of the extension to disable.
  * \sa __glXEnableExtension
  */
 void
-__glXDisableExtension( const char * name )
+__glXScrDisableExtension( __DRIscreen *psc, const char * name )
 {
    if ( __glXGLXClientExtensions == NULL ) {
       __glXExtensionsCtr();
-      set_glx_extension( name, strlen( name ), GL_FALSE, direct_support );
+      __glXExtensionsCtrScreen(psc);
+      set_glx_extension( name, strlen( name ), GL_FALSE, psc->direct_support );
    }
 }
 
@@ -314,37 +315,6 @@
 
 
 
-/**
- * Add a new extension string to the set of possible strings.  This is
- * intended to be used by drivers to advertise support for unlisted,
- * proprietary extensions.
- * 
- * \param enabled      Is the extension enabled by default?
- * \param name         Name of the extension.
- * \param client_only  Is the extension client-side only?
- */
-void
-__glXAddExtension( GLboolean enabled, const char * name, 
-		   GLboolean client_only )
-{
-   if ( __glXGLXClientExtensions == NULL ) {
-      GLuint bit;
-
-      __glXExtensionsCtr();
-
-      bit = next_bit;
-      if ( next_bit < 255 ) {
-	 next_bit++;
-      }
-
-      add_extension( name, 0, 0, bit, enabled, enabled,
-		     client_only, GL_TRUE );
-   }
-}
-
-
-
-
 static void
 __glXExtensionsCtr( void )
 {
@@ -378,6 +348,15 @@
 }
 
 
+static void
+__glXExtensionsCtrScreen( __DRIscreen *psc )
+{
+    if (psc->ext_list_first_time) {
+	psc->ext_list_first_time = GL_FALSE;
+	(void) memcpy( psc->direct_support, direct_support, sizeof( direct_support ) );
+    }
+}
+
 
 
 GLboolean
@@ -451,13 +430,15 @@
  * \returns A pointer to the string.
  */
 char *
-__glXGetUsableExtensions( const char * server_string )
+__glXGetUsableExtensions( __DRIscreen *psc, const char * server_string )
 {
    unsigned char server_support[8];
    unsigned char usable[8];
    unsigned      i;
 
    __glXExtensionsCtr();
+   if ( psc )
+       __glXExtensionsCtrScreen( psc );
    __glXProcessServerString( server_string, server_support );
 
    /* An extension is supported if the client-side (i.e., libGL) supports
@@ -466,9 +447,11 @@
     * the direct rendering driver supports it.
     */
    for ( i = 0 ; i < 8 ; i++ ) {
-      usable[i] = (client_support[i] & client_only[i])
-	  | (client_support[i] & (direct_support[i] & server_support[i]))
-	  | (client_support[i] & (direct_support[i] & direct_only[i]));
+      if ( psc )
+	 usable[i] = client_support[i] & (client_only[i] 
+	    | (psc->direct_support[i] & (server_support[i] | direct_only[i])));
+      else
+	 usable[i] = client_support[i] & client_only[i];
    }
 
    return __glXGetStringFromTable( usable );
Index: glx/glxextensions.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/glx/glxextensions.h,v
retrieving revision 1.2
diff -u -r1.2 glxextensions.h
--- glx/glxextensions.h	30 Apr 2003 01:50:35 -0000	1.2
+++ glx/glxextensions.h	9 Aug 2003 20:58:53 -0000
@@ -71,13 +71,17 @@
 
 extern GLboolean __glXExtensionBitIsEnabled( unsigned bit );
 extern const char * __glXGetClientExtensions( void );
-extern char * __glXGetUsableExtensions( const char * server_string );
-extern void __glXAddExtension( GLboolean enabled, const char * name,
-    GLboolean client_side );
-extern void __glXEnableExtension( const char * name, GLboolean force_client );
-extern void __glXDisableExtension( const char * name );
+extern char * __glXGetUsableExtensions( __DRIscreen *psc, const char * server_string );
+/*extern void __glXAddExtension( GLboolean enabled, const char * name,
+    GLboolean client_side );*/
+extern void __glXScrEnableExtension( __DRIscreen *psc, const char * name );
+extern void __glXScrDisableExtension( __DRIscreen *psc, const char * name );
 
-typedef void (* PFNGLXADDEXTENSIONPROC) ( GLboolean enabled, const char * name );
+typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( __DRIscreen *psc, const char * name );
+typedef void (* PFNGLXSCRDISABLEEXTENSIONPROC) ( __DRIscreen *psc, const char * name );
+
+/* Source-level backwards compatibility with old drivers. They won't
+ * find the respective functions, though. */
 typedef void (* PFNGLXENABLEEXTENSIONPROC) ( const char * name,
     GLboolean force_client );
 typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name );
