[Mesa-dev] [PATCH 01/14] glx: Move the driver extension-loading to a helper function.

Eric Anholt eric at anholt.net
Mon Sep 30 13:44:38 PDT 2013


I'm planning on doing driver extension parsing from 3 places, and making
the extension loading step a bit longer.
---
 src/glx/dri2_glx.c   |  6 ++----
 src/glx/dri_common.c | 14 ++++++++++++++
 src/glx/dri_common.h |  2 ++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 07138fb..123c87c 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -1183,11 +1183,9 @@ dri2CreateScreen(int screen, struct glx_display * priv)
       goto handle_error;
    }
 
-   extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
-   if (extensions == NULL) {
-      ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+   extensions = driGetDriverExtensions(psc->driver);
+   if (extensions == NULL)
       goto handle_error;
-   }
 
    for (i = 0; extensions[i]; i++) {
       if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 5f199e9..f1d1164 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -187,6 +187,20 @@ driOpenDriver(const char *driverName)
    return handle;
 }
 
+_X_HIDDEN const __DRIextension **
+driGetDriverExtensions(void *handle)
+{
+   const __DRIextension **extensions = NULL;
+
+   extensions = dlsym(handle, __DRI_DRIVER_EXTENSIONS);
+   if (extensions == NULL) {
+      ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+      return NULL;
+   }
+
+   return extensions;
+}
+
 static GLboolean
 __driGetMSCRate(__DRIdrawable *draw,
 		int32_t * numerator, int32_t * denominator,
diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h
index 2bbffa9..2ebcb81 100644
--- a/src/glx/dri_common.h
+++ b/src/glx/dri_common.h
@@ -69,6 +69,8 @@ extern void CriticalErrorMessageF(const char *f, ...);
 
 extern void *driOpenDriver(const char *driverName);
 
+extern const __DRIextension **driGetDriverExtensions(void *handle);
+
 extern bool
 dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
                          unsigned *major_ver, unsigned *minor_ver,
-- 
1.8.4.rc3



More information about the mesa-dev mailing list