Module: Mesa
Branch: master
Commit: b65d6dafd602813c56ccc59a5d8ddb473fddfd74
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b65d6dafd602813c56ccc59a5d8ddb473fddfd74

Author: Daniel Stone <dani...@collabora.com>
Date:   Mon Oct  2 16:40:53 2017 +0100

egl/wayland: Don't use dmabuf with no modifiers

The dmabuf interface requires a valid modifier to be sent. If we don't
explicitly get a modifier from the driver, we can't know what to send;
it must be inferred from legacy side-channels (or assumed to linear, if
none exists).

If we have no modifier, then we can only have a single-plane format
anyway, so fall back to the old wl_drm buffer import path.

Fixes: a65db0ad1c ("st/dri: don't expose modifiers in EGL if the driver doesn't 
implement them")
Fixes: 02cc359372 ("egl/wayland: Use linux-dmabuf interface for buffers")
Signed-off-by: Daniel Stone <dani...@collabora.com>
Reviewed-by: Emil Velikov <emil.veli...@collabora.com>
Reported-by: Andy Furniss <adf.li...@gmail.com>
Cc: Marek Olšák <marek.ol...@amd.com>

---

 src/egl/drivers/dri2/platform_wayland.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 04c04cc304..14db55ca74 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -680,6 +680,7 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
    struct wl_buffer *ret;
    EGLBoolean query;
    int width, height, fourcc, num_planes;
+   uint64_t modifier = DRM_FORMAT_MOD_INVALID;
 
    query = dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, 
&width);
    query &= dri2_dpy->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT,
@@ -694,10 +695,8 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
    if (!query)
       num_planes = 1;
 
-   if (dri2_dpy->wl_dmabuf && dri2_dpy->image->base.version >= 15) {
-      struct zwp_linux_buffer_params_v1 *params;
+   if (dri2_dpy->image->base.version >= 15) {
       int mod_hi, mod_lo;
-      int i;
 
       query = dri2_dpy->image->queryImage(image,
                                           __DRI_IMAGE_ATTRIB_MODIFIER_UPPER,
@@ -705,10 +704,15 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
       query &= dri2_dpy->image->queryImage(image,
                                            __DRI_IMAGE_ATTRIB_MODIFIER_LOWER,
                                            &mod_lo);
-      if (!query) {
-         mod_hi = DRM_FORMAT_MOD_INVALID >> 32;
-         mod_lo = DRM_FORMAT_MOD_INVALID & 0xffffffff;
+      if (query) {
+         modifier = (uint64_t) mod_hi << 32;
+         modifier |= (uint64_t) (mod_lo & 0xffffffff);
       }
+   }
+
+   if (dri2_dpy->wl_dmabuf && modifier != DRM_FORMAT_MOD_INVALID) {
+      struct zwp_linux_buffer_params_v1 *params;
+      int i;
 
       /* We don't need a wrapper for wl_dmabuf objects, because we have to
        * create the intermediate params object; we can set the queue on this,
@@ -751,7 +755,7 @@ create_wl_buffer(struct dri2_egl_display *dri2_dpy,
          }
 
          zwp_linux_buffer_params_v1_add(params, fd, i, offset, stride,
-                                        mod_hi, mod_lo);
+                                        modifier >> 32, modifier & 0xffffffff);
          close(fd);
       }
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to