--- dri/dri_glx.c.~1.29.4.1.~	2003-05-23 15:51:11.000000000 +0200
+++ dri/dri_glx.c	2003-08-08 21:13:10.000000000 +0200
@@ -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) {
@@ -452,70 +449,4 @@
     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 */
--- glx/glxclient.h.~1.28.2.1.~	2003-05-23 15:52:50.000000000 +0200
+++ glx/glxclient.h	2003-08-08 21:12:40.000000000 +0200
@@ -292,8 +292,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 +299,6 @@
    const char *name;
    void *handle;
    CreateScreenFunc createScreenFunc;
-   RegisterExtensionsFunc registerExtensionsFunc;
    struct __DRIdriverRec *next;
 };
 
@@ -592,6 +589,11 @@
 
 #ifdef GLX_DIRECT_RENDERING
     /*
+    ** Per screen dynamic client GLX extensions
+    */
+    unsigned char direct_support[8];
+    GLboolean ext_list_first_time; /* = GL_TRUE */
+    /*
     ** Per screen direct rendering interface functions and data.
     */
     __DRIscreen driScreen;
@@ -641,6 +643,8 @@
 #endif
 };
 
+extern __GLXscreenConfigs *__glXFindScreenConfigs(Display *dpy, int scrn);
+
 void __glXFreeContext(__GLXcontext*);
 
 extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
@@ -651,15 +655,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 );
-
 /************************************************************************/
 
 extern int __glXDebug;
--- glx/glxcmds.c.~1.41.2.1.~	2003-05-23 15:55:37.000000000 +0200
+++ glx/glxcmds.c	2003-08-08 21:07:38.000000000 +0200
@@ -1330,7 +1330,7 @@
 					  	   screen, GLX_EXTENSIONS);
 	}
 
-	psc->effectiveGLXexts = (char *) __glXGetUsableExtensions(psc->serverGLXexts);
+	psc->effectiveGLXexts = (char *) __glXGetUsableExtensions(psc, psc->serverGLXexts);
     }
 
     return psc->effectiveGLXexts;
@@ -2936,13 +2936,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 +2947,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 +2979,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 */
    }
--- glx/glxext.c.~1.28.~	2003-05-23 12:18:31.000000000 +0200
+++ glx/glxext.c	2003-08-08 21:12:19.000000000 +0200
@@ -771,16 +771,14 @@
 	UnlockDisplay(dpy);
 
 #ifdef GLX_DIRECT_RENDERING
+        /* Initialize per screen dynamic client GLX extension data */
+	psc->ext_list_first_time = GL_TRUE;
+
 	/* Initialize the direct rendering per screen data and functions */
 	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);
@@ -1064,11 +1062,10 @@
 
 /************************************************************************/
 
-#ifdef GLX_DIRECT_RENDERING
-/* Return the DRI per screen structure */
-__DRIscreen *__glXFindDRIScreen(Display *dpy, int scrn)
+/* Return the GLX per screen structure */
+__GLXscreenConfigs *__glXFindScreenConfigs(Display *dpy, int scrn)
 {
-    __DRIscreen *pDRIScreen = NULL;
+    __GLXscreenConfigs *pGLXscreenConfigs = NULL;
     XExtDisplayInfo *info = __glXFindDisplay(dpy);
     XExtData **privList, *found;
     __GLXdisplayPrivate *dpyPriv;
@@ -1082,10 +1079,18 @@
 
     if (found) {
 	dpyPriv = (__GLXdisplayPrivate *)found->private_data;
-	pDRIScreen = &dpyPriv->screenConfigs[scrn].driScreen;
+	pGLXscreenConfigs = &dpyPriv->screenConfigs[scrn];
     }
 
-    return pDRIScreen;
+    return pGLXscreenConfigs;
+}
+
+#ifdef GLX_DIRECT_RENDERING
+/* Return the DRI per screen structure */
+__DRIscreen *__glXFindDRIScreen(Display *dpy, int scrn)
+{
+    __GLXscreenConfigs *pGLXscreenConfigs = __glXFindScreenConfigs(dpy, scrn);
+    return pGLXscreenConfigs ? &pGLXscreenConfigs->driScreen : NULL;
 }
 #endif
 
--- glx/glxextensions.c.~1.3.~	2003-05-03 07:19:30.000000000 +0200
+++ glx/glxextensions.c	2003-08-08 21:29:44.000000000 +0200
@@ -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( __GLXscreenConfigs *psc );
 static void __glXProcessServerString( const char * server_string,
     unsigned char * server_support );
 
@@ -209,39 +214,37 @@
 
 
 /**
- * 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( Display *dpy, int screen, const char * name )
 {
    if ( __glXGLXClientExtensions == NULL ) {
+      __GLXscreenConfigs *psc = __glXFindScreenConfigs (dpy, screen);
       __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( Display *dpy, int screen, const char * name )
 {
    if ( __glXGLXClientExtensions == NULL ) {
+      __GLXscreenConfigs *psc = __glXFindScreenConfigs (dpy, screen);
       __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 +317,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 +350,15 @@
 }
 
 
+static void
+__glXExtensionsCtrScreen( __GLXscreenConfigs *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 +432,14 @@
  * \returns A pointer to the string.
  */
 char *
-__glXGetUsableExtensions( const char * server_string )
+__glXGetUsableExtensions( __GLXscreenConfigs *psc, const char * server_string )
 {
    unsigned char server_support[8];
    unsigned char usable[8];
    unsigned      i;
 
    __glXExtensionsCtr();
+   __glXExtensionsCtrScreen(psc);
    __glXProcessServerString( server_string, server_support );
 
    /* An extension is supported if the client-side (i.e., libGL) supports
@@ -466,9 +448,8 @@
     * 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]));
+      usable[i] = client_support[i] & (client_only[i] 
+	  | (psc->direct_support[i] & (server_support[i] | direct_only[i])));
    }
 
    return __glXGetStringFromTable( usable );
--- glx/glxextensions.h.~1.2.~	2003-04-30 03:50:35.000000000 +0200
+++ glx/glxextensions.h	2003-08-08 21:26:01.000000000 +0200
@@ -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( __GLXscreenConfigs *psc, const char * server_string );
+/*extern void __glXAddExtension( GLboolean enabled, const char * name,
+    GLboolean client_side );*/
+extern void __glXScrEnableExtension( Display *dpy, int screen, const char * name );
+extern void __glXScrDisableExtension( Display *dpy, int screen, const char * name );
 
-typedef void (* PFNGLXADDEXTENSIONPROC) ( GLboolean enabled, const char * name );
+typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( Display *dpy, int screen, const char * name );
+typedef void (* PFNGLXSCRDISABLEEXTENSIONPROC) ( Display *dpy, int screen, 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 );
