[Mesa-dev] [PATCH 06/14] dri: Pass in the dlsym()ed driver extension to screen creation.

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


This will allow a megadrivers build to reference the actual driver being
loaded from the shared dri_util screen creation code.
---
 include/GL/internal/dri_interface.h    | 27 +++++++++++++++++++--
 src/egl/drivers/dri2/egl_dri2.c        | 27 +++++++++++++++++----
 src/egl/drivers/dri2/egl_dri2.h        |  1 +
 src/gbm/backends/dri/gbm_dri.c         | 15 ++++++++----
 src/gbm/backends/dri/gbm_driint.h      |  1 +
 src/glx/dri2_glx.c                     | 23 +++++++++++-------
 src/glx/drisw_glx.c                    | 13 +++++++---
 src/mesa/drivers/dri/common/dri_util.c | 44 +++++++++++++++++++++++++---------
 8 files changed, 117 insertions(+), 34 deletions(-)

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 93b6c0b..e07f669 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -713,7 +713,7 @@ struct __DRIlegacyExtensionRec {
  * conjunction with the core extension.
  */
 #define __DRI_SWRAST "DRI_SWRast"
-#define __DRI_SWRAST_VERSION 3
+#define __DRI_SWRAST_VERSION 4
 
 struct __DRIswrastExtensionRec {
     __DRIextension base;
@@ -749,6 +749,18 @@ struct __DRIswrastExtensionRec {
 					 const uint32_t *attribs,
 					 unsigned *error,
 					 void *loaderPrivate);
+
+   /**
+    * createNewScreen() with the driver extensions passed in.
+    *
+    * \since version 4
+    */
+   __DRIscreen *(*createNewScreen2)(int screen,
+                                    const __DRIextension **loader_extensions,
+                                    const __DRIextension **driver_extensions,
+                                    const __DRIconfig ***driver_configs,
+                                    void *loaderPrivate);
+
 };
 
 /**
@@ -831,7 +843,7 @@ struct __DRIdri2LoaderExtensionRec {
  * constructors for DRI2.
  */
 #define __DRI_DRI2 "DRI_DRI2"
-#define __DRI_DRI2_VERSION 3
+#define __DRI_DRI2_VERSION 4
 
 #define __DRI_API_OPENGL	0	/**< OpenGL compatibility profile */
 #define __DRI_API_GLES		1	/**< OpenGL ES 1.x */
@@ -939,6 +951,17 @@ struct __DRIdri2ExtensionRec {
 					 const uint32_t *attribs,
 					 unsigned *error,
 					 void *loaderPrivate);
+
+   /**
+    * createNewScreen with the driver's extension list passed in.
+    *
+    * \since version 4
+    */
+    __DRIscreen *(*createNewScreen2)(int screen, int fd,
+                                     const __DRIextension **loader_extensions,
+                                     const __DRIextension **driver_extensions,
+                                     const __DRIconfig ***driver_configs,
+                                     void *loaderPrivate);
 };
 
 
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 7c07fd6..fb2f028 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -460,6 +460,7 @@ dri2_load_driver(_EGLDisplay *disp)
       dlclose(dri2_dpy->driver);
       return EGL_FALSE;
    }
+   dri2_dpy->driver_extensions = extensions;
 
    return EGL_TRUE;
 }
@@ -480,6 +481,7 @@ dri2_load_driver_swrast(_EGLDisplay *disp)
       dlclose(dri2_dpy->driver);
       return EGL_FALSE;
    }
+   dri2_dpy->driver_extensions = extensions;
 
    return EGL_TRUE;
 }
@@ -545,14 +547,29 @@ dri2_create_screen(_EGLDisplay *disp)
    dri2_dpy = disp->DriverData;
 
    if (dri2_dpy->dri2) {
+      if (dri2_dpy->dri2->base.version >= 4) {
       dri2_dpy->dri_screen =
-         dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions,
-				         &dri2_dpy->driver_configs, disp);
+         dri2_dpy->dri2->createNewScreen2(0, dri2_dpy->fd,
+                                          dri2_dpy->extensions,
+                                          dri2_dpy->driver_extensions,
+                                          &dri2_dpy->driver_configs, disp);
+      } else {
+         dri2_dpy->dri_screen =
+            dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd,
+                                            dri2_dpy->extensions,
+                                            &dri2_dpy->driver_configs, disp);
+      }
    } else {
       assert(dri2_dpy->swrast);
-      dri2_dpy->dri_screen =
-         dri2_dpy->swrast->createNewScreen(0, dri2_dpy->extensions,
-                                           &dri2_dpy->driver_configs, disp);
+      if (dri2_dpy->swrast->base.version >= 4) {
+         dri2_dpy->dri_screen =
+            dri2_dpy->swrast->createNewScreen2(0, dri2_dpy->extensions,
+                                               dri2_dpy->driver_extensions,
+                                               &dri2_dpy->driver_configs, disp);
+      } else {
+            dri2_dpy->swrast->createNewScreen(0, dri2_dpy->extensions,
+                                              &dri2_dpy->driver_configs, disp);
+      }
    }
 
    if (dri2_dpy->dri_screen == NULL) {
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index fba5f81..f5e6770 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -118,6 +118,7 @@ struct dri2_egl_display
    __DRIdri2LoaderExtension    dri2_loader_extension;
    __DRIswrastLoaderExtension  swrast_loader_extension;
    const __DRIextension     *extensions[4];
+   const __DRIextension    **driver_extensions;
 
 #ifdef HAVE_X11_PLATFORM
    xcb_connection_t         *conn;
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index f7da79c..90fb6c2 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -215,7 +215,7 @@ dri_load_driver(struct gbm_dri_device *dri)
       dlclose(dri->driver);
       return -1;
    }
-
+   dri->driver_extensions = extensions;
 
    if (dri_bind_extensions(dri, gbm_dri_device_extensions, extensions) < 0) {
       dlclose(dri->driver);
@@ -250,9 +250,16 @@ dri_screen_create(struct gbm_dri_device *dri)
    if (dri->dri2 == NULL)
       return -1;
 
-   dri->screen = dri->dri2->createNewScreen(0, dri->base.base.fd,
-                                            dri->extensions,
-                                            &dri->driver_configs, dri);
+   if (dri->dri2->base.version >= 4) {
+      dri->screen = dri->dri2->createNewScreen2(0, dri->base.base.fd,
+                                                dri->extensions,
+                                                dri->driver_extensions,
+                                                &dri->driver_configs, dri);
+   } else {
+      dri->screen = dri->dri2->createNewScreen(0, dri->base.base.fd,
+                                               dri->extensions,
+                                               &dri->driver_configs, dri);
+   }
    if (dri->screen == NULL)
       return -1;
 
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index 18fc3c0..6305b06 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -53,6 +53,7 @@ struct gbm_dri_device {
 
    const __DRIconfig   **driver_configs;
    const __DRIextension *extensions[4];
+   const __DRIextension **driver_extensions;
 
    __DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data);
    void *lookup_user_data;
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 7e22906..cfa5856 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -1223,15 +1223,20 @@ dri2CreateScreen(int screen, struct glx_display * priv)
       goto handle_error;
    }
 
-   
-   /* If the server does not support the protocol for
-    * DRI2GetBuffersWithFormat, don't supply that interface to the driver.
-    */
-   psc->driScreen =
-      psc->dri2->createNewScreen(screen, psc->fd,
-				 (const __DRIextension **)
-				 &pdp->loader_extensions[0],
-				 &driver_configs, psc);
+   if (psc->dri2->base.version >= 4) {
+      psc->driScreen =
+         psc->dri2->createNewScreen2(screen, psc->fd,
+                                     (const __DRIextension **)
+                                     &pdp->loader_extensions[0],
+                                     extensions,
+                                     &driver_configs, psc);
+   } else {
+      psc->driScreen =
+         psc->dri2->createNewScreen(screen, psc->fd,
+                                    (const __DRIextension **)
+                                    &pdp->loader_extensions[0],
+                                    &driver_configs, psc);
+   }
 
    if (psc->driScreen == NULL) {
       ErrorMessageF("failed to create dri screen\n");
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index a7d0843..cb1d650 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -680,9 +680,16 @@ driswCreateScreen(int screen, struct glx_display *priv)
       goto handle_error;
    }
 
-   psc->driScreen =
-      psc->swrast->createNewScreen(screen, loader_extensions,
-				   &driver_configs, psc);
+   if (psc->swrast->base.version >= 4) {
+      psc->driScreen =
+         psc->swrast->createNewScreen2(screen, loader_extensions,
+                                       extensions,
+                                       &driver_configs, psc);
+   } else {
+      psc->driScreen =
+         psc->swrast->createNewScreen(screen, loader_extensions,
+                                      &driver_configs, psc);
+   }
    if (psc->driScreen == NULL) {
       ErrorMessageF("failed to create dri screen\n");
       goto handle_error;
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 9e2d565..283e158 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -88,9 +88,10 @@ setupLoaderExtensions(__DRIscreen *psp,
  * Display.
  */
 static __DRIscreen *
-dri2CreateNewScreen(int scrn, int fd,
-		    const __DRIextension **extensions,
-		    const __DRIconfig ***driver_configs, void *data)
+dri2CreateNewScreen2(int scrn, int fd,
+                     const __DRIextension **extensions,
+                     const __DRIextension **driver_extensions,
+                     const __DRIconfig ***driver_configs, void *data)
 {
     static const __DRIextension *emptyExtensionList[] = { NULL };
     __DRIscreen *psp;
@@ -153,12 +154,31 @@ dri2CreateNewScreen(int scrn, int fd,
     return psp;
 }
 
+static __DRIscreen *
+dri2CreateNewScreen(int scrn, int fd,
+		    const __DRIextension **extensions,
+		    const __DRIconfig ***driver_configs, void *data)
+{
+   return dri2CreateNewScreen2(scrn, fd, extensions, NULL,
+                               driver_configs, data);
+}
+
 /** swrast driver createNewScreen entrypoint. */
 static __DRIscreen *
-driCreateNewScreen(int scrn, const __DRIextension **extensions,
-		   const __DRIconfig ***driver_configs, void *data)
+driSWRastCreateNewScreen(int scrn, const __DRIextension **extensions,
+                         const __DRIconfig ***driver_configs, void *data)
+{
+   return dri2CreateNewScreen2(scrn, -1, extensions, NULL,
+                               driver_configs, data);
+}
+
+static __DRIscreen *
+driSWRastCreateNewScreen2(int scrn, const __DRIextension **extensions,
+                          const __DRIextension **driver_extensions,
+                          const __DRIconfig ***driver_configs, void *data)
 {
-   return dri2CreateNewScreen(scrn, -1, extensions, driver_configs, data);
+   return dri2CreateNewScreen2(scrn, -1, extensions, driver_extensions,
+                               driver_configs, data);
 }
 
 /**
@@ -679,7 +699,7 @@ const __DRIcoreExtension driCoreExtension = {
 
 /** DRI2 interface */
 const __DRIdri2Extension driDRI2Extension = {
-    .base = { __DRI_DRI2, 3 },
+    .base = { __DRI_DRI2, 4 },
 
     .createNewScreen            = dri2CreateNewScreen,
     .createNewDrawable          = dri2CreateNewDrawable,
@@ -688,15 +708,17 @@ const __DRIdri2Extension driDRI2Extension = {
     .createNewContextForAPI     = dri2CreateNewContextForAPI,
     .allocateBuffer             = dri2AllocateBuffer,
     .releaseBuffer              = dri2ReleaseBuffer,
-    .createContextAttribs       = dri2CreateContextAttribs
+    .createContextAttribs       = dri2CreateContextAttribs,
+    .createNewScreen2           = dri2CreateNewScreen2,
 };
 
 const __DRIswrastExtension driSWRastExtension = {
-    { __DRI_SWRAST, __DRI_SWRAST_VERSION },
-    driCreateNewScreen,
+    { __DRI_SWRAST, 4 },
+    driSWRastCreateNewScreen,
     dri2CreateNewDrawable,
     dri2CreateNewContextForAPI,
-    dri2CreateContextAttribs
+    dri2CreateContextAttribs,
+    driSWRastCreateNewScreen2,
 };
 
 const __DRI2configQueryExtension dri2ConfigQueryExtension = {
-- 
1.8.4.rc3



More information about the mesa-dev mailing list