<div dir="ltr">Hi<div><br></div><div>I'm currently getting a build failure with this patch in an out of tree build</div><div><br></div><div><span style="font-family:monospace">Making all in egl
<br>make[3]: Entering directory '/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999-abi_x86_32.x86/src/egl'
<br>/usr/bin/wayland-scanner code < /usr/share/wayland-protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml > drivers/dri2/linux-dmabuf-unstable-v1-protocol.c
<br>/usr/bin/wayland-scanner client-header < /usr/share/wayland-protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml > drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h
<br>/usr/bin/python2.7  /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/gen_egl_dispatch.py source \
<br>        /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/eglFunctionList.py \
<br>        /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/egl.xml \
<br>        /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/egl_other.xml > g_egldispatchstubs.c
<br>/usr/bin/python2.7  /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/gen_egl_dispatch.py header \
<br>        /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/eglFunctionList.py \
<br>        /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/egl.xml \
<br>        /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/egl/generate/egl_other.xml > g_egldispatchstubs.h
<br>/bin/sh: drivers/dri2/linux-dmabuf-unstable-v1-protocol.c: No such file or directory
<br>make[3]: *** [Makefile:1609: drivers/dri2/linux-dmabuf-unstable-v1-protocol.c] Error 1
<br>make[3]: *** Waiting for unfinished jobs....
<br>/bin/sh: drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h: No such file or directory
<br>make[3]: *** [Makefile:1613: drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h] Error 1</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">I've checked and </span><span style="font-family:monospace">/usr/share/wayland-protocols/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml does exist on my system</span><br></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Cheers</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Mike</span></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 14 Jul 2017 at 14:36 Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When available, use the zwp_linux_dambuf_v1 interface to create buffers,<br>
which allows multiple planes and buffer modifiers to be used.<br>
<br>
Reviewed-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com" target="_blank">emil.velikov@collabora.com</a>><br>
Signed-off-by: Daniel Stone <<a href="mailto:daniels@collabora.com" target="_blank">daniels@collabora.com</a>><br>
---<br>
 <a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a>                            |   5 +-<br>
 src/egl/Makefile.am                     |  23 +++-<br>
 src/egl/drivers/dri2/.gitignore         |   2 +<br>
 src/egl/drivers/dri2/egl_dri2.c         |   7 ++<br>
 src/egl/drivers/dri2/egl_dri2.h         |  10 ++<br>
 src/egl/drivers/dri2/platform_wayland.c | 195 +++++++++++++++++++++++++++++---<br>
 6 files changed, 221 insertions(+), 21 deletions(-)<br>
 create mode 100644 src/egl/drivers/dri2/.gitignore<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 46fcd8f3fe..c5803e0f6e 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -88,6 +88,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0<br>
 LIBVA_REQUIRED=0.38.0<br>
 VDPAU_REQUIRED=1.1<br>
 WAYLAND_REQUIRED=1.11<br>
+WAYLAND_PROTOCOLS_REQUIRED=1.8<br>
 XCB_REQUIRED=1.9.3<br>
 XCBDRI2_REQUIRED=1.8<br>
 XCBGLX_REQUIRED=1.8.1<br>
@@ -1686,7 +1687,9 @@ for plat in $platforms; do<br>
        case "$plat" in<br>
        wayland)<br>
<br>
-               PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED wayland-server >= $WAYLAND_REQUIRED])<br>
+               PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED wayland-server >= $WAYLAND_REQUIRED wayland-protocols >= $WAYLAND_PROTOCOLS_REQUIRED])<br>
+                ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir wayland-protocols`<br>
+                AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)<br>
<br>
                if test "x$WAYLAND_SCANNER" = "x:"; then<br>
                        AC_MSG_ERROR([wayland-scanner is needed to compile the wayland platform])<br>
diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am<br>
index 81090387b5..19295de3ed 100644<br>
--- a/src/egl/Makefile.am<br>
+++ b/src/egl/Makefile.am<br>
@@ -21,6 +21,8 @@<br>
<br>
 include Makefile.sources<br>
<br>
+BUILT_SOURCES =<br>
+<br>
 AM_CFLAGS = \<br>
        -I$(top_srcdir)/include \<br>
        -I$(top_srcdir)/src/egl/main \<br>
@@ -61,11 +63,27 @@ endif<br>
 endif<br>
<br>
 if HAVE_PLATFORM_WAYLAND<br>
+WL_DMABUF_XML = $(WAYLAND_PROTOCOLS_DATADIR)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml<br>
+<br>
+drivers/dri2/linux-dmabuf-unstable-v1-protocol.c: $(WL_DMABUF_XML)<br>
+       $(MKDIR_GEN)<br>
+       $(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@<br>
+<br>
+drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h: $(WL_DMABUF_XML)<br>
+       $(MKDIR_GEN)<br>
+       $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@<br>
+<br>
+BUILT_SOURCES += \<br>
+       drivers/dri2/linux-dmabuf-unstable-v1-protocol.c \<br>
+       drivers/dri2/linux-dmabuf-unstable-v1-client-protocol.h<br>
+<br>
 AM_CFLAGS += $(WAYLAND_CFLAGS)<br>
 libEGL_common_la_LIBADD += $(WAYLAND_LIBS)<br>
 libEGL_common_la_LIBADD += $(LIBDRM_LIBS)<br>
 libEGL_common_la_LIBADD += $(top_builddir)/src/egl/wayland/wayland-drm/<a href="http://libwayland-drm.la" rel="noreferrer" target="_blank">libwayland-drm.la</a><br>
-dri2_backend_FILES += drivers/dri2/platform_wayland.c<br>
+libEGL_common_la_LIBADD += $(top_builddir)/src/util/<a href="http://libmesautil.la" rel="noreferrer" target="_blank">libmesautil.la</a><br>
+dri2_backend_FILES += drivers/dri2/platform_wayland.c  \<br>
+       drivers/dri2/linux-dmabuf-unstable-v1-protocol.c<br>
 endif<br>
<br>
 if HAVE_PLATFORM_DRM<br>
@@ -85,6 +103,7 @@ endif<br>
<br>
 AM_CFLAGS += \<br>
        -I$(top_srcdir)/src/loader \<br>
+       -I$(top_builddir)/src/egl/drivers/dri2 \<br>
        -I$(top_srcdir)/src/egl/drivers/dri2 \<br>
        -I$(top_srcdir)/src/gbm/backends/dri \<br>
        -I$(top_srcdir)/src/egl/wayland/wayland-egl \<br>
@@ -118,7 +137,7 @@ g_egldispatchstubs.h: $(GLVND_GEN_DEPS)<br>
                $(top_srcdir)/src/egl/generate/egl.xml \<br>
                $(top_srcdir)/src/egl/generate/egl_other.xml > $@<br>
<br>
-BUILT_SOURCES = g_egldispatchstubs.c g_egldispatchstubs.h<br>
+BUILT_SOURCES += g_egldispatchstubs.c g_egldispatchstubs.h<br>
 CLEANFILES = $(BUILT_SOURCES)<br>
<br>
 if USE_LIBGLVND<br>
diff --git a/src/egl/drivers/dri2/.gitignore b/src/egl/drivers/dri2/.gitignore<br>
new file mode 100644<br>
index 0000000000..e96becbb54<br>
--- /dev/null<br>
+++ b/src/egl/drivers/dri2/.gitignore<br>
@@ -0,0 +1,2 @@<br>
+linux-dmabuf-unstable-v1-client-protocol.h<br>
+linux-dmabuf-unstable-v1-protocol.c<br>
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c<br>
index 5bf36bf309..e16aefff3c 100644<br>
--- a/src/egl/drivers/dri2/egl_dri2.c<br>
+++ b/src/egl/drivers/dri2/egl_dri2.c<br>
@@ -53,6 +53,7 @@<br>
 #ifdef HAVE_WAYLAND_PLATFORM<br>
 #include "wayland-drm.h"<br>
 #include "wayland-drm-client-protocol.h"<br>
+#include "linux-dmabuf-unstable-v1-client-protocol.h"<br>
 #endif<br>
<br>
 #ifdef HAVE_X11_PLATFORM<br>
@@ -62,6 +63,7 @@<br>
 #include "egl_dri2.h"<br>
 #include "loader/loader.h"<br>
 #include "util/u_atomic.h"<br>
+#include "util/u_vector.h"<br>
<br>
 /* The kernel header drm_fourcc.h defines the DRM formats below.  We duplicate<br>
  * some of the definitions here so that building Mesa won't bleeding-edge<br>
@@ -934,11 +936,16 @@ dri2_display_destroy(_EGLDisplay *disp)<br>
    case _EGL_PLATFORM_WAYLAND:<br>
       if (dri2_dpy->wl_drm)<br>
           wl_drm_destroy(dri2_dpy->wl_drm);<br>
+      if (dri2_dpy->wl_dmabuf)<br>
+          zwp_linux_dmabuf_v1_destroy(dri2_dpy->wl_dmabuf);<br>
       if (dri2_dpy->wl_shm)<br>
           wl_shm_destroy(dri2_dpy->wl_shm);<br>
       wl_registry_destroy(dri2_dpy->wl_registry);<br>
       wl_event_queue_destroy(dri2_dpy->wl_queue);<br>
       wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper);<br>
+      u_vector_finish(&dri2_dpy->wl_modifiers.argb8888);<br>
+      u_vector_finish(&dri2_dpy->wl_modifiers.xrgb8888);<br>
+      u_vector_finish(&dri2_dpy->wl_modifiers.rgb565);<br>
       if (dri2_dpy->own_device) {<br>
          wl_display_disconnect(dri2_dpy->wl_dpy);<br>
       }<br>
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h<br>
index 4a5cf8e4ef..db19bb7809 100644<br>
--- a/src/egl/drivers/dri2/egl_dri2.h<br>
+++ b/src/egl/drivers/dri2/egl_dri2.h<br>
@@ -45,6 +45,8 @@<br>
 #ifdef HAVE_WAYLAND_PLATFORM<br>
 #include <wayland-client.h><br>
 #include "wayland-egl-priv.h"<br>
+/* forward declarations of protocol elements */<br>
+struct zwp_linux_dmabuf_v1;<br>
 #endif<br>
<br>
 #include <GL/gl.h><br>
@@ -73,6 +75,8 @@<br>
 #include "eglimage.h"<br>
 #include "eglsync.h"<br>
<br>
+#include "util/u_vector.h"<br>
+<br>
 struct wl_buffer;<br>
<br>
 struct dri2_egl_driver<br>
@@ -211,6 +215,12 @@ struct dri2_egl_display<br>
    struct wl_drm            *wl_drm;<br>
    struct wl_shm            *wl_shm;<br>
    struct wl_event_queue    *wl_queue;<br>
+   struct zwp_linux_dmabuf_v1 *wl_dmabuf;<br>
+   struct {<br>
+      struct u_vector        xrgb8888;<br>
+      struct u_vector        argb8888;<br>
+      struct u_vector        rgb565;<br>
+   } wl_modifiers;<br>
    bool                      authenticated;<br>
    int                       formats;<br>
    uint32_t                  capabilities;<br>
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c<br>
index 4f941a16aa..211036f45f 100644<br>
--- a/src/egl/drivers/dri2/platform_wayland.c<br>
+++ b/src/egl/drivers/dri2/platform_wayland.c<br>
@@ -36,14 +36,25 @@<br>
 #include <unistd.h><br>
 #include <fcntl.h><br>
 #include <xf86drm.h><br>
+#include <drm_fourcc.h><br>
 #include <sys/mman.h><br>
<br>
 #include "egl_dri2.h"<br>
 #include "egl_dri2_fallbacks.h"<br>
 #include "loader.h"<br>
+#include "util/u_vector.h"<br>
<br>
 #include <wayland-client.h><br>
 #include "wayland-drm-client-protocol.h"<br>
+#include "linux-dmabuf-unstable-v1-client-protocol.h"<br>
+<br>
+#ifndef DRM_FORMAT_MOD_INVALID<br>
+#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)<br>
+#endif<br>
+<br>
+#ifndef DRM_FORMAT_MOD_LINEAR<br>
+#define DRM_FORMAT_MOD_LINEAR 0<br>
+#endif<br>
<br>
 enum wl_drm_format_flags {<br>
    HAS_ARGB8888 = 1,<br>
@@ -331,6 +342,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)<br>
       dri2_egl_display(dri2_surf->base.Resource.Display);<br>
    int use_flags;<br>
    unsigned int dri_image_format;<br>
+   uint64_t *modifiers;<br>
+   int num_modifiers;<br>
<br>
    /* currently supports three WL DRM formats,<br>
     * WL_DRM_FORMAT_ARGB8888, WL_DRM_FORMAT_XRGB8888,<br>
@@ -339,12 +352,18 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)<br>
    switch (dri2_surf->format) {<br>
    case WL_DRM_FORMAT_ARGB8888:<br>
       dri_image_format = __DRI_IMAGE_FORMAT_ARGB8888;<br>
+      modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.argb8888);<br>
+      num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.argb8888);<br>
       break;<br>
    case WL_DRM_FORMAT_XRGB8888:<br>
       dri_image_format = __DRI_IMAGE_FORMAT_XRGB8888;<br>
+      modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.xrgb8888);<br>
+      num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.xrgb8888);<br>
       break;<br>
    case WL_DRM_FORMAT_RGB565:<br>
       dri_image_format = __DRI_IMAGE_FORMAT_RGB565;<br>
+      modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.rgb565);<br>
+      num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.rgb565);<br>
       break;<br>
    default:<br>
       /* format is not supported */<br>
@@ -382,27 +401,60 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)<br>
<br>
    if (dri2_dpy->is_different_gpu &&<br>
        dri2_surf->back->linear_copy == NULL) {<br>
-       dri2_surf->back->linear_copy =<br>
-          dri2_dpy->image->createImage(dri2_dpy->dri_screen,<br>
-                                      dri2_surf->base.Width,<br>
-                                      dri2_surf->base.Height,<br>
-                                      dri_image_format,<br>
-                                      use_flags |<br>
-                                      __DRI_IMAGE_USE_LINEAR,<br>
-                                      NULL);<br>
+      /* The LINEAR modifier should be a perfect alias of the LINEAR use<br>
+       * flag; try the new interface first before the old, then fall back. */<br>
+      if (dri2_dpy->image->base.version >= 15 &&<br>
+           dri2_dpy->image->createImageWithModifiers) {<br>
+         uint64_t linear_mod = DRM_FORMAT_MOD_LINEAR;<br>
+<br>
+         dri2_surf->back->linear_copy =<br>
+            dri2_dpy->image->createImageWithModifiers(dri2_dpy->dri_screen,<br>
+                                                      dri2_surf->base.Width,<br>
+                                                      dri2_surf->base.Height,<br>
+                                                      dri_image_format,<br>
+                                                      &linear_mod,<br>
+                                                      1,<br>
+                                                      NULL);<br>
+      } else {<br>
+         dri2_surf->back->linear_copy =<br>
+            dri2_dpy->image->createImage(dri2_dpy->dri_screen,<br>
+                                         dri2_surf->base.Width,<br>
+                                         dri2_surf->base.Height,<br>
+                                         dri_image_format,<br>
+                                         use_flags |<br>
+                                         __DRI_IMAGE_USE_LINEAR,<br>
+                                         NULL);<br>
+      }<br>
       if (dri2_surf->back->linear_copy == NULL)<br>
           return -1;<br>
    }<br>
<br>
    if (dri2_surf->back->dri_image == NULL) {<br>
-      dri2_surf->back->dri_image =<br>
-         dri2_dpy->image->createImage(dri2_dpy->dri_screen,<br>
-                                      dri2_surf->base.Width,<br>
-                                      dri2_surf->base.Height,<br>
-                                      dri_image_format,<br>
-                                      dri2_dpy->is_different_gpu ?<br>
-                                         0 : use_flags,<br>
-                                      NULL);<br>
+      /* If our DRIImage implementation does not support<br>
+       * createImageWithModifiers, then fall back to the old createImage,<br>
+       * and hope it allocates an image which is acceptable to the winsys.<br>
+        */<br>
+      if (num_modifiers && dri2_dpy->image->base.version >= 15 &&<br>
+          dri2_dpy->image->createImageWithModifiers) {<br>
+         dri2_surf->back->dri_image =<br>
+           dri2_dpy->image->createImageWithModifiers(dri2_dpy->dri_screen,<br>
+                                                     dri2_surf->base.Width,<br>
+                                                     dri2_surf->base.Height,<br>
+                                                     dri_image_format,<br>
+                                                     modifiers,<br>
+                                                     num_modifiers,<br>
+                                                     NULL);<br>
+      } else {<br>
+         dri2_surf->back->dri_image =<br>
+            dri2_dpy->image->createImage(dri2_dpy->dri_screen,<br>
+                                         dri2_surf->base.Width,<br>
+                                         dri2_surf->base.Height,<br>
+                                         dri_image_format,<br>
+                                         dri2_dpy->is_different_gpu ?<br>
+                                              0 : use_flags,<br>
+                                         NULL);<br>
+      }<br>
+<br>
       dri2_surf->back->age = 0;<br>
    }<br>
    if (dri2_surf->back->dri_image == NULL)<br>
@@ -643,17 +695,68 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,<br>
                  __DRIimage *image)<br>
 {<br>
    struct wl_buffer *ret;<br>
-   int width, height, fourcc;<br>
+   int width, height, fourcc, num_planes;<br>
<br>
    dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, &width);<br>
    dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT, &height);<br>
    dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FOURCC, &fourcc);<br>
+   dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_NUM_PLANES,<br>
+                               &num_planes);<br>
+<br>
+   if (dri2_dpy->wl_dmabuf && dri2_dpy->image->base.version >= 15) {<br>
+      struct zwp_linux_buffer_params_v1 *params;<br>
+      int mod_hi, mod_lo;<br>
+      int i;<br>
+<br>
+      dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_UPPER,<br>
+                                  &mod_hi);<br>
+      dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_MODIFIER_LOWER,<br>
+                                  &mod_lo);<br>
+<br>
+      /* We don't need a wrapper for wl_dmabuf objects, because we have to<br>
+       * create the intermediate params object; we can set the queue on this,<br>
+       * and the wl_buffer inherits it race-free. */<br>
+      params = zwp_linux_dmabuf_v1_create_params(dri2_dpy->wl_dmabuf);<br>
+      if (dri2_surf)<br>
+         wl_proxy_set_queue((struct wl_proxy *) params, dri2_surf->wl_queue);<br>
+<br>
+      for (i = 0; i < num_planes; i++) {<br>
+         __DRIimage *p_image;<br>
+         int stride, offset, fd;<br>
+<br>
+         if (i == 0)<br>
+            p_image = image;<br>
+         else<br>
+            p_image = dri2_dpy->image->fromPlanar(image, i, NULL);<br>
+         if (!p_image) {<br>
+            zwp_linux_buffer_params_v1_destroy(params);<br>
+            return NULL;<br>
+         }<br>
<br>
-   if (dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME) {<br>
+         dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_FD, &fd);<br>
+         dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_STRIDE,<br>
+                                     &stride);<br>
+         dri2_dpy->image->queryImage(p_image, __DRI_IMAGE_ATTRIB_OFFSET,<br>
+                                     &offset);<br>
+         if (image != p_image)<br>
+            dri2_dpy->image->destroyImage(p_image);<br>
+<br>
+         zwp_linux_buffer_params_v1_add(params, fd, i, offset, stride,<br>
+                                        mod_hi, mod_lo);<br>
+         close(fd);<br>
+      }<br>
+<br>
+      ret = zwp_linux_buffer_params_v1_create_immed(params, width, height,<br>
+                                                    fourcc, 0);<br>
+      zwp_linux_buffer_params_v1_destroy(params);<br>
+   } else if (dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME) {<br>
       struct wl_drm *wl_drm =<br>
          dri2_surf ? dri2_surf->wl_drm_wrapper : dri2_dpy->wl_drm;<br>
       int fd, stride;<br>
<br>
+      if (num_planes > 1)<br>
+         return NULL;<br>
+<br>
       dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_FD, &fd);<br>
       dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);<br>
       ret = wl_drm_create_prime_buffer(wl_drm, fd, width, height, fourcc, 0,<br>
@@ -664,6 +767,9 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,<br>
          dri2_surf ? dri2_surf->wl_drm_wrapper : dri2_dpy->wl_drm;<br>
       int name, stride;<br>
<br>
+      if (num_planes > 1)<br>
+         return NULL;<br>
+<br>
       dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_NAME, &name);<br>
       dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);<br>
       ret = wl_drm_create_buffer(wl_drm, name, width, height, stride, fourcc);<br>
@@ -949,6 +1055,47 @@ static const struct wl_drm_listener drm_listener = {<br>
 };<br>
<br>
 static void<br>
+dmabuf_ignore_format(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,<br>
+                     uint32_t format)<br>
+{<br>
+   /* formats are implicitly advertised by the 'modifier' event, so ignore */<br>
+}<br>
+<br>
+static void<br>
+dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,<br>
+                       uint32_t format, uint32_t modifier_hi,<br>
+                       uint32_t modifier_lo)<br>
+{<br>
+   struct dri2_egl_display *dri2_dpy = data;<br>
+   uint64_t *mod = NULL;<br>
+<br>
+   switch (format) {<br>
+   case WL_DRM_FORMAT_ARGB8888:<br>
+      mod = u_vector_add(&dri2_dpy->wl_modifiers.argb8888);<br>
+      break;<br>
+   case WL_DRM_FORMAT_XRGB8888:<br>
+      mod = u_vector_add(&dri2_dpy->wl_modifiers.xrgb8888);<br>
+      break;<br>
+   case WL_DRM_FORMAT_RGB565:<br>
+      mod = u_vector_add(&dri2_dpy->wl_modifiers.rgb565);<br>
+      break;<br>
+   default:<br>
+      break;<br>
+   }<br>
+<br>
+   if (!mod)<br>
+      return;<br>
+<br>
+   *mod = (uint64_t) modifier_hi << 32;<br>
+   *mod |= (uint64_t) (modifier_lo & 0xffffffff);<br>
+}<br>
+<br>
+static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = {<br>
+   .format = dmabuf_ignore_format,<br>
+   .modifier = dmabuf_handle_modifier,<br>
+};<br>
+<br>
+static void<br>
 registry_handle_global_drm(void *data, struct wl_registry *registry,<br>
                            uint32_t name, const char *interface,<br>
                            uint32_t version)<br>
@@ -959,6 +1106,12 @@ registry_handle_global_drm(void *data, struct wl_registry *registry,<br>
       dri2_dpy->wl_drm =<br>
          wl_registry_bind(registry, name, &wl_drm_interface, MIN2(version, 2));<br>
       wl_drm_add_listener(dri2_dpy->wl_drm, &drm_listener, dri2_dpy);<br>
+   } else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0 && version >= 3) {<br>
+      dri2_dpy->wl_dmabuf =<br>
+         wl_registry_bind(registry, name, &zwp_linux_dmabuf_v1_interface,<br>
+                          MIN2(version, 3));<br>
+      zwp_linux_dmabuf_v1_add_listener(dri2_dpy->wl_dmabuf, &dmabuf_listener,<br>
+                                       dri2_dpy);<br>
    }<br>
 }<br>
<br>
@@ -1127,6 +1280,12 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)<br>
       dri2_dpy->wl_dpy = disp->PlatformDisplay;<br>
    }<br>
<br>
+   if (!u_vector_init(&dri2_dpy->wl_modifiers.xrgb8888, sizeof(uint64_t), 32) ||<br>
+       !u_vector_init(&dri2_dpy->wl_modifiers.argb8888, sizeof(uint64_t), 32) ||<br>
+       !u_vector_init(&dri2_dpy->wl_modifiers.rgb565, sizeof(uint64_t), 32)) {<br>
+      goto cleanup;<br>
+   }<br>
+<br>
    dri2_dpy->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy);<br>
<br>
    dri2_dpy->wl_dpy_wrapper = wl_proxy_create_wrapper(dri2_dpy->wl_dpy);<br>
--<br>
2.13.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>