[Mesa-dev] [PATCH v2 1/4] egl: android: disable __DRI_DRI2_LOADER support on render nodes

Rob Herring robh at kernel.org
Thu Apr 28 20:37:28 UTC 2016


Use of __DRI_DRI2_LOADER extension is only supported for card nodes. In
order to support dmabufs, Android will be moving to using render nodes and
we need to disable the DRI2 loader extension.

This is based on the Wayland EGL code.

Cc: Rob Clark <robdclark at gmail.com>
Cc: Emil Velikov <emil.velikov at collabora.com>
Signed-off-by: Rob Herring <robh at kernel.org>
---
 src/egl/drivers/dri2/egl_dri2.h         |  3 ++-
 src/egl/drivers/dri2/platform_android.c | 31 ++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index ef79939..82b912e 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -212,9 +212,9 @@ struct dri2_egl_display
    int			     authenticated;
    int			     formats;
    uint32_t                  capabilities;
-   int			     is_render_node;
 #endif
 
+   int              is_render_node;
    int			     is_different_gpu;
 };
 
@@ -285,6 +285,7 @@ struct dri2_egl_surface
 #ifdef HAVE_ANDROID_PLATFORM
    struct ANativeWindow *window;
    struct ANativeWindowBuffer *buffer;
+   __DRIimage *dri_image;
 
    /* EGL-owned buffers */
    __DRIbuffer           *local_buffers[__DRI_BUFFER_COUNT];
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index c00b2c2..02122e3 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -29,6 +29,7 @@
 
 #include <errno.h>
 #include <dlfcn.h>
+#include <xf86drm.h>
 
 #if ANDROID_VERSION >= 0x402
 #include <sync/sync.h>
@@ -694,17 +695,25 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
       goto cleanup_driver_name;
    }
 
-   dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
-   dri2_dpy->dri2_loader_extension.base.version = 3;
-   dri2_dpy->dri2_loader_extension.getBuffers = NULL;
-   dri2_dpy->dri2_loader_extension.flushFrontBuffer = droid_flush_front_buffer;
-   dri2_dpy->dri2_loader_extension.getBuffersWithFormat =
-      droid_get_buffers_with_format;
-
-   dri2_dpy->extensions[0] = &dri2_dpy->dri2_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->is_render_node = drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER;
+
+   dri2_dpy->extensions[0] = &image_lookup_extension.base;
+   dri2_dpy->extensions[1] = &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->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
+      dri2_dpy->dri2_loader_extension.base.version = 3;
+      dri2_dpy->dri2_loader_extension.getBuffers = NULL;
+      dri2_dpy->dri2_loader_extension.flushFrontBuffer = droid_flush_front_buffer;
+      dri2_dpy->dri2_loader_extension.getBuffersWithFormat =
+        droid_get_buffers_with_format;
+      dri2_dpy->extensions[2] = &dri2_dpy->dri2_loader_extension.base;
+      dri2_dpy->extensions[3] = NULL;
+   } else
+      dri2_dpy->extensions[2] = NULL;
+
 
    if (!dri2_create_screen(dpy)) {
       err = "DRI2: failed to create screen";
-- 
2.7.4



More information about the mesa-dev mailing list