[Mesa-dev] [PATCH 20/30] egl/dri2: rework dri2_egl_display::extensions storage

Emil Velikov emil.l.velikov at gmail.com
Thu Aug 25 16:18:42 UTC 2016


From: Emil Velikov <emil.velikov at collabora.com>

Remove the error prone fixed size array.
While we're here also rename to loader_extensions like in the GLX code.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
There's a single easter egg hidden within (functionality change)
which... I should keep separate, perhaps :-\

XXX:
- Any ideas why x11 + dri2/swrast loader does not expose use_invalidate?

- At the same time why does the dri3 one do so - the i965 claims that
...
So EGL still relies on viewport hacks to handle window resizing.
This should go away with DRI3000.
---
 src/egl/drivers/dri2/egl_dri2.c             | 10 ++++-----
 src/egl/drivers/dri2/egl_dri2.h             |  2 +-
 src/egl/drivers/dri2/platform_android.c     | 27 ++++++++++++++--------
 src/egl/drivers/dri2/platform_surfaceless.c | 12 ++++++----
 src/egl/drivers/dri2/platform_wayland.c     | 35 ++++++++++++++++++++---------
 src/egl/drivers/dri2/platform_x11.c         | 31 +++++++++++++++++--------
 6 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d53c9b9..1d38b24 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -676,7 +676,7 @@ dri2_create_screen(_EGLDisplay *disp)
    if (dri2_dpy->image_driver) {
       dri2_dpy->dri_screen =
          dri2_dpy->image_driver->createNewScreen2(0, dri2_dpy->fd,
-                                                  dri2_dpy->extensions,
+                                                  dri2_dpy->loader_extensions,
                                                   dri2_dpy->driver_extensions,
                                                   &dri2_dpy->driver_configs,
                                                   disp);
@@ -684,25 +684,25 @@ dri2_create_screen(_EGLDisplay *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->loader_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->loader_extensions,
                                             &dri2_dpy->driver_configs, disp);
       }
    } else {
       assert(dri2_dpy->swrast);
       if (dri2_dpy->swrast->base.version >= 4) {
          dri2_dpy->dri_screen =
-            dri2_dpy->swrast->createNewScreen2(0, dri2_dpy->extensions,
+            dri2_dpy->swrast->createNewScreen2(0, dri2_dpy->loader_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->swrast->createNewScreen(0, dri2_dpy->loader_extensions,
                                               &dri2_dpy->driver_configs, disp);
       }
    }
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index f902006..b5f3386 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -197,7 +197,7 @@ struct dri2_egl_display
    char                     *device_name;
    char                     *driver_name;
 
-   const __DRIextension     *extensions[5];
+   const __DRIextension    **loader_extensions;
    const __DRIextension    **driver_extensions;
 
 #ifdef HAVE_X11_PLATFORM
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 1ddc8e3..ba5c289 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -904,6 +904,20 @@ static const __DRIimageLoaderExtension droid_image_loader_extension = {
    .flushFrontBuffer    = droid_flush_front_buffer,
 };
 
+static const __DRIextension *droid_dri2_loader_extensions[] = {
+   &droid_dri2_loader_extension.base,
+   &image_lookup_extension.base,
+   &use_invalidate.base,
+   NULL,
+};
+
+static const __DRIextension *droid_image_loader_extensions[] = {
+   &droid_image_loader_extension.base,
+   &image_lookup_extension.base,
+   &use_invalidate.base,
+   NULL,
+};
+
 EGLBoolean
 dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
 {
@@ -941,15 +955,10 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
 
    /* render nodes cannot use Gem names, and thus do not support
     * the __DRI_DRI2_LOADER extension */
-   if (!dri2_dpy->is_render_node) {
-      dri2_dpy->extensions[0] = &droid_dri2_loader_extension.base;
-   } else {
-      dri2_dpy->extensions[0] = &droid_image_loader_extension.base;
-   }
-   dri2_dpy->extensions[1] = &use_invalidate.base;
-   dri2_dpy->extensions[2] = &image_lookup_extension.base;
-   dri2_dpy->extensions[3] = NULL;
-
+   if (!dri2_dpy->is_render_node)
+      dri2_dpy->loader_extensions = droid_dri2_loader_extensions;
+   else
+      dri2_dpy->loader_extensions = droid_image_loader_extensions;
 
    if (!dri2_create_screen(dpy)) {
       err = "DRI2: failed to create screen";
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index f613c03..386aa7a 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -236,6 +236,13 @@ static const __DRIimageLoaderExtension image_loader_extension = {
 
 #define DRM_RENDER_DEV_NAME  "%s/renderD%d"
 
+static const __DRIextension *image_loader_extensions[] = {
+   &image_loader_extension.base,
+   &image_lookup_extension.base,
+   &use_invalidate.base,
+   NULL,
+};
+
 EGLBoolean
 dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -281,10 +288,7 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
       goto cleanup_display;
    }
 
-   dri2_dpy->extensions[0] = &image_loader_extension.base;
-   dri2_dpy->extensions[1] = &image_lookup_extension.base;
-   dri2_dpy->extensions[2] = &use_invalidate.base;
-   dri2_dpy->extensions[3] = NULL;
+   dri2_dpy->loader_extensions = image_loader_extensions;
 
    if (!dri2_create_screen(disp)) {
       err = "DRI2: failed to create screen";
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 0447255..005d2f3 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1068,6 +1068,20 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
    .get_dri_drawable = dri2_surface_get_dri_drawable,
 };
 
+static const __DRIextension *dri2_loader_extensions[] = {
+   &dri2_loader_extension.base,
+   &image_lookup_extension.base,
+   &use_invalidate.base,
+   NULL,
+};
+
+static const __DRIextension *image_loader_extensions[] = {
+   &image_loader_extension.base,
+   &image_lookup_extension.base,
+   &use_invalidate.base,
+   NULL,
+};
+
 static EGLBoolean
 dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -1142,17 +1156,12 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
    if (!dri2_load_driver(disp))
       goto cleanup_driver_name;
 
-   dri2_dpy->extensions[0] = &image_loader_extension.base;
-   dri2_dpy->extensions[1] = &image_lookup_extension.base;
-   dri2_dpy->extensions[2] = &use_invalidate.base;
-
    /* render nodes cannot use Gem names, and thus do not support
     * the __DRI_DRI2_LOADER extension */
-   if (!dri2_dpy->is_render_node) {
-      dri2_dpy->extensions[3] = &dri2_loader_extension.base;
-      dri2_dpy->extensions[4] = NULL;
-   } else
-      dri2_dpy->extensions[3] = NULL;
+   if (!dri2_dpy->is_render_node)
+      dri2_dpy->loader_extensions = dri2_loader_extensions;
+   else
+      dri2_dpy->loader_extensions = image_loader_extensions;
 
    if (!dri2_create_screen(disp))
       goto cleanup_driver;
@@ -1798,6 +1807,11 @@ static const __DRIswrastLoaderExtension swrast_loader_extension = {
    .putImage2       = dri2_wl_swrast_put_image2,
 };
 
+static const __DRIextension *swrast_loader_extensions[] = {
+   &swrast_loader_extension.base,
+   NULL,
+};
+
 static EGLBoolean
 dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -1848,8 +1862,7 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
    if (!dri2_load_driver_swrast(disp))
       goto cleanup_shm;
 
-   dri2_dpy->extensions[0] = &swrast_loader_extension.base;
-   dri2_dpy->extensions[1] = NULL;
+   dri2_dpy->loader_extensions = swrast_loader_extensions;
 
    if (!dri2_create_screen(disp))
       goto cleanup_driver;
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index e96ea52..2a5fc0b 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1168,6 +1168,11 @@ static const __DRIswrastLoaderExtension swrast_loader_extension = {
    .getImage        = swrastGetImage,
 };
 
+static const __DRIextension *swrast_loader_extensions[] = {
+   &swrast_loader_extension.base,
+   NULL,
+};
+
 static EGLBoolean
 dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -1202,8 +1207,7 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp)
    if (!dri2_load_driver_swrast(disp))
       goto cleanup_conn;
 
-   dri2_dpy->extensions[0] = &swrast_loader_extension.base;
-   dri2_dpy->extensions[1] = NULL;
+   dri2_dpy->loader_extensions = swrast_loader_extensions;
 
    if (!dri2_create_screen(disp))
       goto cleanup_driver;
@@ -1281,6 +1285,14 @@ dri2_x11_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
 }
 
 #ifdef HAVE_DRI3
+
+static const __DRIextension *dri3_image_loader_extensions[] = {
+   &dri3_image_loader_extension.base,
+   &image_lookup_extension.base,
+   &use_invalidate.base,
+   NULL,
+};
+
 static EGLBoolean
 dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -1314,10 +1326,7 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp)
    if (!dri2_load_driver_dri3(disp))
       goto cleanup_conn;
 
-   dri2_dpy->extensions[0] = &dri3_image_loader_extension.base;
-   dri2_dpy->extensions[1] = &use_invalidate.base;
-   dri2_dpy->extensions[2] = &image_lookup_extension.base;
-   dri2_dpy->extensions[3] = NULL;
+   dri2_dpy->loader_extensions = dri3_image_loader_extensions;
 
    dri2_dpy->swap_available = true;
    dri2_dpy->invalidate_available = true;
@@ -1383,6 +1392,12 @@ static const __DRIdri2LoaderExtension dri2_loader_extension = {
    .getBuffersWithFormat = dri2_x11_get_buffers_with_format,
 };
 
+static const __DRIextension *dri2_loader_extensions[] = {
+   &dri2_loader_extension.base,
+   &image_lookup_extension.base,
+   NULL,
+};
+
 static EGLBoolean
 dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
 {
@@ -1414,9 +1429,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
    if (!dri2_load_driver(disp))
       goto cleanup_fd;
 
-   dri2_dpy->extensions[0] = &dri2_loader_extension.base;
-   dri2_dpy->extensions[1] = &image_lookup_extension.base;
-   dri2_dpy->extensions[2] = NULL;
+   dri2_dpy->loader_extensions = dri2_loader_extensions;
 
    dri2_dpy->swap_available = (dri2_dpy->dri2_minor >= 2);
    dri2_dpy->invalidate_available = (dri2_dpy->dri2_minor >= 3);
-- 
2.9.0



More information about the mesa-dev mailing list