[RFC PATCHv2 4/5] glx: Search for DRI drivers in colon-delimited list of paths.

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Tue Mar 8 16:17:29 PST 2011


This matches the behaviour of mesa libGL.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
---
Upon investigating more closely what mesa libGL does to find DRI drivers,
the extra work handling drivers where driCreateScreen fails isn't needed.

 configure.ac       |    8 +++++-
 glx/glxdricommon.c |   75 ++++++++++++++++++++++++++++-----------------------
 2 files changed, 48 insertions(+), 35 deletions(-)

diff --git a/configure.ac b/configure.ac
index 681f9d9..58e1ba0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1243,7 +1243,13 @@ AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path]
 AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
 dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
-AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+drisearchdirs=`$PKG_CONFIG --variable=drisearchdirs dri`
+if test -n "$drisearchdirs" ; then
+	AC_DEFINE_DIR(DRI_DRIVER_PATH, drisearchdirs,
+		      [Default DRI search paths])
+else
+	AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default DRI driver path])
+fi
 AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
 AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
 AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 16f6588..0b250e1 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -217,47 +217,54 @@ glxProbeDriver(const char *driverName,
     void *driver;
     char filename[PATH_MAX];
     const __DRIextension **extensions;
+    char *driDriverPath;
+    const char *pathStart = dri_driver_path;
+    const char *pathEnd = strchr(pathStart, ':');
 
-    snprintf(filename, sizeof filename, "%s/%s_dri.so",
-             dri_driver_path, driverName);
+    for (; *pathStart; pathEnd = strchr(pathStart, ':')) {
+	driDriverPath = strndup(pathStart,
+				pathEnd ? pathEnd - pathStart : sizeof filename);
+	snprintf(filename, sizeof filename, "%s/%s_dri.so",
+		 driDriverPath, driverName);
+	free(driDriverPath);
+	pathStart = pathEnd ? pathEnd + 1 : pathStart + strlen(pathStart);
 
-    driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
-    if (driver == NULL) {
-	LogMessage(X_ERROR, "AIGLX error: dlopen of %s failed (%s)\n",
-		   filename, dlerror());
-	goto cleanup_failure;
-    }
+	driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+	if (driver == NULL) {
+	    LogMessage(X_INFO, "AIGLX: dlopen of %s failed (%s)\n",
+		       filename, dlerror());
+	    continue;
+	}
 
-    extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
-    if (extensions == NULL) {
-	LogMessage(X_ERROR, "AIGLX error: %s exports no extensions (%s)\n",
-		   driverName, dlerror());
-	goto cleanup_failure;
-    }
-    
-    for (i = 0; extensions[i]; i++) {
-	if (strcmp(extensions[i]->name, coreName) == 0 &&
-	    extensions[i]->version >= coreVersion) {
-		*coreExt = extensions[i];
+	extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
+	if (extensions == NULL) {
+	    LogMessage(X_INFO, "AIGLX: %s exports no extensions (%s)\n",
+		       driverName, dlerror());
+	    dlclose(driver);
+	    continue;
 	}
+    
+	for (i = 0; extensions[i]; i++) {
+	    if (strcmp(extensions[i]->name, coreName) == 0 &&
+		extensions[i]->version >= coreVersion) {
+		    *coreExt = (void *)extensions[i];
+	    }
 
-	if (strcmp(extensions[i]->name, renderName) == 0 &&
-	    extensions[i]->version >= renderVersion) {
-		*renderExt = extensions[i];
+	    if (strcmp(extensions[i]->name, renderName) == 0 &&
+		extensions[i]->version >= renderVersion) {
+		    *renderExt = (void *)extensions[i];
+	    }
 	}
-    }
 
-    if (*coreExt == NULL || *renderExt == NULL) {
-	LogMessage(X_ERROR,
-		   "AIGLX error: %s does not export required DRI extension\n",
-		   driverName);
-	goto cleanup_failure;
+	if (*coreExt == NULL || *renderExt == NULL) {
+	    LogMessage(X_INFO,
+		       "AIGLX: %s does not export required DRI extension\n",
+		       driverName);
+	    *coreExt = *renderExt = NULL;
+	    dlclose(driver);
+	    continue;
+	}
+	return driver;
     }
-    return driver;
-
-cleanup_failure:
-    if (driver)
-	dlclose(driver);
-    *coreExt = *renderExt = NULL;
     return NULL;
 }
-- 
1.7.4.1



More information about the xorg-devel mailing list