xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 19 10:17:42 UTC 2020


 hw/xwayland/xwayland-glamor-gbm.c |   36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

New commits:
commit d6558477d7a264c2132bc977b51d80fc0277d1e0
Author: Simon Ser <contact at emersion.fr>
Date:   Tue Jun 2 15:40:16 2020 +0200

    xwayland: allow using linux-dmabuf with DRM_FORMAT_MOD_INVALID
    
    When the linux-dmabuf protocol is available, prefer it over the old
    wl_drm protocol. Previously wl_drm was used when modifiers aren't
    supported, however linux-dmabuf supports formats without modifiers too.
    In this case, linux-dmabuf will send a DRM_FORMAT_MOD_INVALID modifier
    for each supported format [1].
    
    This allows compositors to better handle these buffers, getting a
    DMA-BUF and implementing features like direct scan-out.
    
    A similar logic has been implemented for EGL [2].
    
    DRM_FORMAT_MOD_INVALID is now stored in the xwl_screen->formats list.
    glamor_get_modifiers still returns FALSE with zero modifiers if the
    only advertised modifier is DRM_FORMAT_MOD_INVALID.
    
    [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/commit/fb9b2a87317c77e26283da5f6c9559d709f6fdcd
    [2]: https://gitlab.freedesktop.org/mesa/mesa/-/commit/c376865f5eeca535c4aa8e33bcf166052c1ce2f2
    
    Signed-off-by: Simon Ser <contact at emersion.fr>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 7336c97a7..c7731e2c8 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -668,7 +668,9 @@ glamor_get_modifiers(ScreenPtr screen, uint32_t format,
        }
     }
 
-    if (!xwl_format)
+    if (!xwl_format ||
+        (xwl_format->num_modifiers == 1 &&
+         xwl_format->modifiers[0] == DRM_FORMAT_MOD_INVALID))
         return FALSE;
 
     *modifiers = calloc(xwl_format->num_modifiers, sizeof(uint64_t));
@@ -832,10 +834,6 @@ xwl_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
     struct xwl_format *xwl_format = NULL;
     int i;
 
-    if (modifier_hi == (DRM_FORMAT_MOD_INVALID >> 32) &&
-        modifier_lo == (DRM_FORMAT_MOD_INVALID & 0xffffffff))
-        return;
-
     for (i = 0; i < xwl_screen->num_formats; i++) {
         if (xwl_screen->formats[i].format == format) {
             xwl_format = &xwl_screen->formats[i];
commit c0e13cbf5a56e1fdd1e4ce58ebdefb6d2904e4b3
Author: Simon Ser <contact at emersion.fr>
Date:   Tue Jun 2 15:28:38 2020 +0200

    xwayland: only use linux-dmabuf if format/modifier was advertised
    
    Previously, linux-dmabuf was used unconditionally if the buffer had a
    modifier. However creating a linux-dmabuf buffer with a format/modifier
    which hasn't been advertised will fail.
    
    Change xwl_glamor_gbm_get_wl_buffer_for_pixmap to use linux-dmabuf when
    the format/modifier has been advertised only.
    
    Signed-off-by: Simon Ser <contact at emersion.fr>
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1035
    Tested-by: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 379fe9c8c..7336c97a7 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -293,6 +293,9 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap,
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
     unsigned short width = pixmap->drawable.width;
     unsigned short height = pixmap->drawable.height;
+    uint32_t format;
+    struct xwl_format *xwl_format = NULL;
+    Bool modifier_supported = FALSE;
     int prime_fd;
     int num_planes;
     uint32_t strides[4];
@@ -317,6 +320,8 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap,
     if (!xwl_pixmap->bo)
        return NULL;
 
+    format = wl_drm_format_for_depth(pixmap->drawable.depth);
+
     prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
     if (prime_fd == -1)
         return NULL;
@@ -335,7 +340,23 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap,
     offsets[0] = 0;
 #endif
 
-    if (xwl_gbm->dmabuf && modifier != DRM_FORMAT_MOD_INVALID) {
+    for (i = 0; i < xwl_screen->num_formats; i++) {
+       if (xwl_screen->formats[i].format == format) {
+          xwl_format = &xwl_screen->formats[i];
+          break;
+       }
+    }
+
+    if (xwl_format) {
+        for (i = 0; i < xwl_format->num_modifiers; i++) {
+            if (xwl_format->modifiers[i] == modifier) {
+                modifier_supported = TRUE;
+                break;
+            }
+        }
+    }
+
+    if (xwl_gbm->dmabuf && modifier_supported) {
         struct zwp_linux_buffer_params_v1 *params;
 
         params = zwp_linux_dmabuf_v1_create_params(xwl_gbm->dmabuf);
@@ -347,13 +368,12 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap,
 
         xwl_pixmap->buffer =
            zwp_linux_buffer_params_v1_create_immed(params, width, height,
-                                                   wl_drm_format_for_depth(pixmap->drawable.depth),
-                                                   0);
+                                                   format, 0);
         zwp_linux_buffer_params_v1_destroy(params);
     } else if (num_planes == 1) {
         xwl_pixmap->buffer =
             wl_drm_create_prime_buffer(xwl_gbm->drm, prime_fd, width, height,
-                                       wl_drm_format_for_depth(pixmap->drawable.depth),
+                                       format,
                                        0, gbm_bo_get_stride(xwl_pixmap->bo),
                                        0, 0,
                                        0, 0);


More information about the xorg-commit mailing list