bring in changes from 6.4 branch
[mesa.git] / src / glx / x11 / dri_glx.c
index 7ac80eb74d7e882f761a899e7dedf606bc1794bb..516ca508c5d47cd19e365fabb805b29d86e8c768 100644 (file)
@@ -38,7 +38,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <unistd.h>
 #include <X11/Xlibint.h>
 #include <X11/extensions/Xext.h>
-#include "extutil.h"
+#include <X11/extensions/extutil.h>
 #include "glxclient.h"
 #include "xf86dri.h"
 #include "sarea.h"
@@ -55,14 +55,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define RTLD_GLOBAL 0
 #endif
 
-#ifdef BUILT_IN_DRI_DRIVER
-
-extern void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
-                               int numConfigs, __GLXvisualConfig *config);
-
-
-#else /* BUILT_IN_DRI_DRIVER */
-
 
 #ifndef DEFAULT_DRIVER_DIR
 /* this is normally defined in the Imakefile */
@@ -102,23 +94,6 @@ static void ErrorMessageF(const char *f, ...)
 }
 
 
-/*
- * We'll save a pointer to this function when we couldn't find a
- * direct rendering driver for a given screen.
- */
-static void *DummyCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
-                               int numConfigs, __GLXvisualConfig *config)
-{
-    (void) dpy;
-    (void) scrn;
-    (void) psc;
-    (void) numConfigs;
-    (void) config;
-    return NULL;
-}
-
-
-
 /**
  * Extract the ith directory path out of a colon-separated list of paths.  No
  * more than \c dirLen characters, including the terminating \c NUL, will be
@@ -181,6 +156,19 @@ ExtractDir(int index, const char *paths, int dirLen, char *dir)
 }
 
 
+/**
+ * Versioned name of the expected \c __driCreateNewScreen function.
+ * 
+ * The version of the last incompatible loader/driver inteface change is
+ * appended to the name of the \c __driCreateNewScreen function.  This
+ * prevents loaders from trying to load drivers that are too old.
+ * 
+ * \todo
+ * Create a macro or something so that this is automatically updated.
+ */
+static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
+
+
 /**
  * Try to \c dlopen the named driver.
  *
@@ -249,18 +237,16 @@ static __DRIdriver *OpenDriver(const char *driverName)
             return NULL; /* out of memory! */
          }
 
-         driver->createScreenFunc = (CreateScreenFunc)
-            dlsym(handle, "__driCreateScreen");
-         driver->createNewScreenFunc = (CreateNewScreenFunc)
-            dlsym(handle, "__driCreateNewScreen");
+         driver->createNewScreenFunc = (PFNCREATENEWSCREENFUNC)
+            dlsym(handle, createNewScreenName);
 
-         if ( (driver->createScreenFunc == NULL) 
-             && (driver->createNewScreenFunc == NULL) ) {
+         if ( driver->createNewScreenFunc == NULL ) {
             /* If the driver doesn't have this symbol then something's
              * really, really wrong.
              */
-            ErrorMessageF("Neither __driCreateScreen or __driCreateNewScreen "
-                         "are defined in %s_dri.so!\n", driverName);
+            ErrorMessageF("%s not defined in %s_dri.so!\n"
+                         "Your driver may be too old for this libGL.\n",
+                         createNewScreenName, driverName);
             Xfree(driver);
             dlclose(handle);
             continue;
@@ -379,9 +365,6 @@ const char *glXGetDriverConfig (const char *driverName) {
 }
 
 
-#endif /* BUILT_IN_DRI_DRIVER */
-
-
 /* This function isn't currently used.
  */
 static void driDestroyDisplay(Display *dpy, void *private)
@@ -420,7 +403,6 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
      */
     pdisp->private = NULL;
     pdisp->destroyDisplay = NULL;
-    pdisp->createScreen = NULL;
 
     if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
        return NULL;
@@ -441,17 +423,10 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
 
     pdisp->destroyDisplay = driDestroyDisplay;
 
-    /* allocate array of pointers to createScreen funcs */
-    pdisp->createScreen = (CreateScreenFunc *) Xmalloc(numScreens * sizeof(void *));
-    if (!pdisp->createScreen) {
-       Xfree(pdpyp);
-       return NULL;
-    }
-
-    /* allocate array of pointers to createScreen funcs */
-    pdisp->createNewScreen = (CreateNewScreenFunc *) Xmalloc(numScreens * sizeof(void *));
+    /* allocate array of pointers to createNewScreen funcs */
+    pdisp->createNewScreen = (PFNCREATENEWSCREENFUNC *)
+      Xmalloc(numScreens * sizeof(void *));
     if (!pdisp->createNewScreen) {
-       Xfree(pdisp->createScreen);
        Xfree(pdpyp);
        return NULL;
     }
@@ -460,20 +435,10 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
     pdpyp->libraryHandles = (void **) Xmalloc(numScreens * sizeof(void*));
     if (!pdpyp->libraryHandles) {
        Xfree(pdisp->createNewScreen);
-       Xfree(pdisp->createScreen);
        Xfree(pdpyp);
        return NULL;
     }
 
-#ifdef BUILT_IN_DRI_DRIVER
-    /* we'll statically bind to the built-in __driCreateScreen function */
-    for (scrn = 0; scrn < numScreens; scrn++) {
-       pdisp->createScreen[scrn] = __driCreateScreen;
-       pdisp->createNewScreen[scrn] = NULL;
-       pdpyp->libraryHandles[scrn] = NULL;
-    }
-
-#else
     /* dynamically discover DRI drivers for all screens, saving each
      * driver's "__driCreateScreen" function pointer.  That's the bootstrap
      * entrypoint for all DRI drivers.
@@ -481,17 +446,14 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
     for (scrn = 0; scrn < numScreens; scrn++) {
         __DRIdriver *driver = driGetDriver(dpy, scrn);
         if (driver) {
-           pdisp->createScreen[scrn] = driver->createScreenFunc;
            pdisp->createNewScreen[scrn] = driver->createNewScreenFunc;
            pdpyp->libraryHandles[scrn] = driver->handle;
         }
         else {
-           pdisp->createScreen[scrn] = DummyCreateScreen;
            pdisp->createNewScreen[scrn] = NULL;
            pdpyp->libraryHandles[scrn] = NULL;
         }
     }
-#endif
 
     return (void *)pdpyp;
 }