dri: Pass in the dlsym()ed driver extension to screen creation.
authorEric Anholt <eric@anholt.net>
Fri, 27 Sep 2013 18:39:25 +0000 (11:39 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 24 Oct 2013 21:04:20 +0000 (14:04 -0700)
This will allow a megadrivers build to reference the actual driver being
loaded from the shared dri_util screen creation code.

v2: Fix indentation, fallback case in EGL (review by Emil).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
include/GL/internal/dri_interface.h
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/gbm/backends/dri/gbm_dri.c
src/gbm/backends/dri/gbm_driint.h
src/glx/dri2_glx.c
src/glx/drisw_glx.c
src/mesa/drivers/dri/common/dri_util.c

index 2122ae9ed48eec0e49ed55ee3300cc2f5a17736a..a7afa22466450b347a2ac8e3c2467e571cbb4bf6 100644 (file)
@@ -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);
 };
 
 
index c257684638018065a287e6adcbbacf4023a4b25a..a64f4e8e9c290361e439bef9a70254137c37fcc0 100644 (file)
@@ -449,6 +449,7 @@ dri2_load_driver(_EGLDisplay *disp)
       dlclose(dri2_dpy->driver);
       return EGL_FALSE;
    }
+   dri2_dpy->driver_extensions = extensions;
 
    return EGL_TRUE;
 }
@@ -469,6 +470,7 @@ dri2_load_driver_swrast(_EGLDisplay *disp)
       dlclose(dri2_dpy->driver);
       return EGL_FALSE;
    }
+   dri2_dpy->driver_extensions = extensions;
 
    return EGL_TRUE;
 }
@@ -534,14 +536,30 @@ dri2_create_screen(_EGLDisplay *disp)
    dri2_dpy = disp->DriverData;
 
    if (dri2_dpy->dri2) {
-      dri2_dpy->dri_screen =
-         dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions,
-                                        &dri2_dpy->driver_configs, disp);
+      if (dri2_dpy->dri2->base.version >= 4) {
+         dri2_dpy->dri_screen =
+            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->dri_screen =
+            dri2_dpy->swrast->createNewScreen(0, dri2_dpy->extensions,
+                                              &dri2_dpy->driver_configs, disp);
+      }
    }
 
    if (dri2_dpy->dri_screen == NULL) {
index 4a39efbde095e9f4c9a01a3397bf98fc3cf9932b..c7d64846c7e5b60dc0a10f73641f41543440c02b 100644 (file)
@@ -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;
index ee05ed8725661a7395b1ddc7c34f7a47bb58c4cb..e95fcc7b23cffad463a11809f655ee3a14d684e6 100644 (file)
@@ -228,7 +228,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);
@@ -263,9 +263,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;
 
index 90d764fb44f1dd37b78e082c84d1be42900c5bdf..cb4e477abf4733867843e8c1b18a869737620727 100644 (file)
@@ -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;
index 7e22906318df49913c84bb4711277d8dba003e71..cfa5856484f6e46eb1279bc8fcdf83db873cf596 100644 (file)
@@ -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");
index a7d084348772e742fcd16a111b591bc1a184efeb..cb1d650b5c19eb757a318ed1b94a7b395bcbf64f 100644 (file)
@@ -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;
index db44eede651168185ee04a53f4557631aa508c37..8a413daf043d5a0733e3744992b9a016e839b5c7 100644 (file)
@@ -89,9 +89,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;
@@ -154,12 +155,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);
 }
 
 /**
@@ -688,7 +708,7 @@ const __DRIcoreExtension driCoreExtension = {
 
 /** DRI2 interface */
 const __DRIdri2Extension driDRI2Extension = {
-    .base = { __DRI_DRI2, 3 },
+    .base = { __DRI_DRI2, 4 },
 
     .createNewScreen            = dri2CreateNewScreen,
     .createNewDrawable          = dri2CreateNewDrawable,
@@ -697,15 +717,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 = {