xserver: Branch 'master' - 8 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 4 09:41:58 UTC 2023


 hw/xwayland/xwayland-glamor-gbm.c     |   53 +++++++++--
 hw/xwayland/xwayland-glamor.c         |  152 +++++++++++++++++++++++++++++-----
 hw/xwayland/xwayland-glamor.h         |    4 
 hw/xwayland/xwayland-window-buffers.c |   17 ++-
 hw/xwayland/xwayland-window.h         |    2 
 5 files changed, 192 insertions(+), 36 deletions(-)

New commits:
commit 81458a86bf9320a6d40d5cba64f66840f15eb26c
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Thu Mar 23 14:31:04 2023 +0100

    xwayland: Recycle buffers when dmabuf feedback changes
    
    Whenever the linux-dmabuf v4 feedback changes, we need to recreate the
    existing buffers so they use the current linux-dmabuf v4 feedback.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index b714f9be0..792af6144 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -43,6 +43,7 @@
 #include "xwayland-glx.h"
 #include "xwayland-screen.h"
 #include "xwayland-window.h"
+#include "xwayland-window-buffers.h"
 
 #include <sys/mman.h>
 
@@ -757,6 +758,11 @@ xwl_window_dmabuf_feedback_done(void *data,
     DebugF("XWAYLAND: Window 0x%x can%s get implicit scanout support\n",
             xwl_window->window->drawable.id,
             xwl_window->has_implicit_scanout_support ? "" : "not");
+
+    /* If the linux-dmabuf v4 per-surface feedback changed, recycle the
+     * window buffers so that they get re-created with appropriate parameters.
+     */
+    xwl_window_buffers_recycle(xwl_window);
 }
 
 static void
commit 684580d06f9ea0724d4da9a4876509909b0fa791
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 28 18:01:06 2023 +0200

    xwayland: Try the Xwayland glamor hook to create pixmaps
    
    When creating the window buffer's backing pixmap, try the Xwayland
    glamor hook first and fallback to the regular CreatePixmap() code path
    otherwise.
    
    That allows to enable direct scanout if possible, either through the
    regular dmabuf v4 code path, or from the implicit fallback code path.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c
index f04c79a8a..f7bb571bb 100644
--- a/hw/xwayland/xwayland-window-buffers.c
+++ b/hw/xwayland/xwayland-window-buffers.c
@@ -328,12 +328,19 @@ xwl_window_buffers_get_pixmap(struct xwl_window *xwl_window,
             pBox++;
         }
     } else {
+#ifdef XWL_HAS_GLAMOR
+        /* Try the xwayland/glamor direct hook first */
         xwl_window_buffer->pixmap =
-            (*xwl_screen->screen->CreatePixmap) (window_pixmap->drawable.pScreen,
-                                                 window_pixmap->drawable.width,
-                                                 window_pixmap->drawable.height,
-                                                 window_pixmap->drawable.depth,
-                                                 CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+            xwl_glamor_create_pixmap_for_window(xwl_window);
+#endif /* XWL_HAS_GLAMOR */
+        if (!xwl_window_buffer->pixmap) {
+            xwl_window_buffer->pixmap =
+                (*xwl_screen->screen->CreatePixmap) (window_pixmap->drawable.pScreen,
+                                                     window_pixmap->drawable.width,
+                                                     window_pixmap->drawable.height,
+                                                     window_pixmap->drawable.depth,
+                                                     CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+        }
 
         if (!xwl_window_buffer->pixmap)
             return window_pixmap;
commit 111d318fc2262c03c289be172696264622e50156
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Mar 22 10:37:52 2023 +0100

    xwayland: Create scanout capable BO with the fallback path
    
    Before linux_dmabuf v4 support was added, the BO were created using
    gbm_bo_create_with_modifiers() which incidentally creates scanout
    capable buffers.
    
    We now need to replicate that explicitly when using the fallback path,
    with buffers window, otherwise direct scanout will not be possible in
    that case.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1535
    Suggested-by: Michel Dänzer <mdaenzer at redhat.com>
    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 1474eb15d..83318fe62 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -278,7 +278,8 @@ static PixmapPtr
 xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
                                       DrawablePtr drawable,
                                       int width, int height, int depth,
-                                      unsigned int hint)
+                                      unsigned int hint,
+                                      Bool implicit_scanout)
 {
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
     struct gbm_bo *bo = NULL;
@@ -313,9 +314,11 @@ xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
         }
 #endif
         if (bo == NULL) {
+            uint32_t usage = GBM_BO_USE_RENDERING;
             implicit = TRUE;
-            bo = gbm_bo_create(xwl_gbm->gbm, width, height, format,
-                               GBM_BO_USE_RENDERING);
+            if (implicit_scanout)
+                usage |= GBM_BO_USE_SCANOUT;
+            bo = gbm_bo_create(xwl_gbm->gbm, width, height, format, usage);
         }
 
         if (bo) {
@@ -342,21 +345,19 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
                              unsigned int hint)
 {
     return xwl_glamor_gbm_create_pixmap_internal(xwl_screen_get(screen), NULL,
-                                                 width, height, depth, hint);
+                                                 width, height, depth, hint, FALSE);
 }
 
 static PixmapPtr
 xwl_glamor_gbm_create_pixmap_for_window(struct xwl_window *xwl_window)
 {
-   if (xwl_window->window == NullWindow)
-        return NullPixmap;
-
     return xwl_glamor_gbm_create_pixmap_internal(xwl_window->xwl_screen,
                                                  &xwl_window->window->drawable,
                                                  xwl_window->window->drawable.width,
                                                  xwl_window->window->drawable.height,
                                                  xwl_window->window->drawable.depth,
-                                                 CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+                                                 CREATE_PIXMAP_USAGE_BACKING_PIXMAP,
+                                                 xwl_window->has_implicit_scanout_support);
 }
 
 static Bool
commit 9730fb64ea05c620c90a23eb9999128e43752ec1
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 28 17:57:31 2023 +0200

    xwayland: Add create_pixmap_for_window() to GBM backend
    
    Add the implementation for create_pixmap_for_window() in the GBM glamor
    backend.
    
    To do so, we just rename the existing xwl_glamor_gbm_create_pixmap() as
    internal and add an optional drawable parameter, so that it can be used
    either from the regular CreatePixmap code path, or from the new direct
    Xwayland glamor's hook.
    
    v2: Fallback to xwl_glamor_get_modifiers() if
        xwl_glamor_get_drawable_modifiers() returned 0 modifiers. (Michel)
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    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 04cb5bc23..1474eb15d 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -275,11 +275,11 @@ error:
 }
 
 static PixmapPtr
-xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
-                             int width, int height, int depth,
-                             unsigned int hint)
+xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen,
+                                      DrawablePtr drawable,
+                                      int width, int height, int depth,
+                                      unsigned int hint)
 {
-    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
     struct gbm_bo *bo = NULL;
     PixmapPtr pixmap = NULL;
@@ -293,10 +293,18 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
 
 #ifdef GBM_BO_WITH_MODIFIERS
         if (xwl_gbm->dmabuf_capable) {
-            uint32_t num_modifiers;
+            uint32_t num_modifiers = 0;
             uint64_t *modifiers = NULL;
 
-            xwl_glamor_get_modifiers(screen, format, &num_modifiers, &modifiers);
+            if (drawable) {
+                xwl_glamor_get_drawable_modifiers(drawable, format,
+                                                  &num_modifiers, &modifiers);
+            }
+
+            if (num_modifiers == 0) {
+                xwl_glamor_get_modifiers(xwl_screen->screen, format,
+                                         &num_modifiers, &modifiers);
+            }
 
             if (num_modifiers > 0)
                 bo = gbm_bo_create_with_modifiers(xwl_gbm->gbm, width, height,
@@ -311,7 +319,7 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
         }
 
         if (bo) {
-            pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth, implicit);
+            pixmap = xwl_glamor_gbm_create_pixmap_for_bo(xwl_screen->screen, bo, depth, implicit);
 
             if (!pixmap) {
                 gbm_bo_destroy(bo);
@@ -323,11 +331,34 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
     }
 
     if (!pixmap)
-        pixmap = glamor_create_pixmap(screen, width, height, depth, hint);
+        pixmap = glamor_create_pixmap(xwl_screen->screen, width, height, depth, hint);
 
     return pixmap;
 }
 
+static PixmapPtr
+xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
+                             int width, int height, int depth,
+                             unsigned int hint)
+{
+    return xwl_glamor_gbm_create_pixmap_internal(xwl_screen_get(screen), NULL,
+                                                 width, height, depth, hint);
+}
+
+static PixmapPtr
+xwl_glamor_gbm_create_pixmap_for_window(struct xwl_window *xwl_window)
+{
+   if (xwl_window->window == NullWindow)
+        return NullPixmap;
+
+    return xwl_glamor_gbm_create_pixmap_internal(xwl_window->xwl_screen,
+                                                 &xwl_window->window->drawable,
+                                                 xwl_window->window->drawable.width,
+                                                 xwl_window->window->drawable.height,
+                                                 xwl_window->window->drawable.depth,
+                                                 CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+}
+
 static Bool
 xwl_glamor_gbm_destroy_pixmap(PixmapPtr pixmap)
 {
@@ -1205,4 +1236,5 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     xwl_screen->gbm_backend.is_available = TRUE;
     xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH |
                                             XWL_EGL_BACKEND_NEEDS_N_BUFFERING;
+    xwl_screen->gbm_backend.create_pixmap_for_window = xwl_glamor_gbm_create_pixmap_for_window;
 }
commit 1ac3dd77d5adbcc0eb4365b2ff08460826ec1be1
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 28 17:54:46 2023 +0200

    xwayland: Add a direct hook to create pixmaps with glamor
    
    With linux dmabuf v4 support, for direct scanout support, we need more
    context that just what CreatePixmap() provides, as we need the actual
    drawable to invoke xwl_glamor_get_drawable_modifiers().
    
    Add a specific hook in Xwayland's glamor implementation that we can use
    for that purpose.
    
    This is preparation work for the direct scanout fixes.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index af227bb03..b714f9be0 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -919,6 +919,20 @@ xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen)
                 XWL_EGL_BACKEND_NEEDS_N_BUFFERING);
 }
 
+PixmapPtr
+xwl_glamor_create_pixmap_for_window(struct xwl_window *xwl_window)
+{
+    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
+        return NullPixmap;
+
+    if (xwl_screen->egl_backend->create_pixmap_for_window)
+        return xwl_screen->egl_backend->create_pixmap_for_window(xwl_window);
+    else
+        return NullPixmap;
+}
+
 void
 xwl_glamor_init_backends(struct xwl_screen *xwl_screen, Bool use_eglstream)
 {
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 0ecd25b38..c2eed95e9 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -104,6 +104,9 @@ struct xwl_egl_backend {
      * is set up on.
      */
     drmDevice *(*get_main_device)(struct xwl_screen *xwl_screen);
+
+    /* Direct hook to create the backing pixmap for a window */
+    PixmapPtr (*create_pixmap_for_window)(struct xwl_window *xwl_window);
 };
 
 #ifdef XWL_HAS_GLAMOR
@@ -142,6 +145,7 @@ Bool xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
 Bool xwl_glamor_get_drawable_modifiers(DrawablePtr drawable, uint32_t format,
                                        uint32_t *num_modifiers, uint64_t **modifiers);
 Bool xwl_glamor_check_flip(PixmapPtr pixmap);
+PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
 
 #ifdef XV
 /* glamor Xv Adaptor */
commit a4c700231dfbd20a7d48b64ff64e8cc40a6c22bc
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 28 14:12:53 2023 +0200

    xwayland: Check for implicit scanout availability
    
    With implicit modifiers, DRM_FORMAT_MOD_INVALID is an allowed modifier,
    to indicate that the server can support the format.
    
    When looking for a scanout capable tranche with implicit modifiers, we
    ought to check for the availability of a tranche with an invalid
    modifier for the given format.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index db1434ffb..af227bb03 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -747,8 +747,16 @@ xwl_window_dmabuf_feedback_done(void *data,
                                 struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
 {
     struct xwl_window *xwl_window = data;
+    uint32_t format = wl_drm_format_for_depth(xwl_window->window->drawable.depth);
 
     xwl_dmabuf_feedback_done(&xwl_window->feedback, dmabuf_feedback);
+
+    xwl_window->has_implicit_scanout_support =
+        xwl_feedback_is_modifier_supported(&xwl_window->feedback, format,
+                                           DRM_FORMAT_MOD_INVALID, TRUE);
+    DebugF("XWAYLAND: Window 0x%x can%s get implicit scanout support\n",
+            xwl_window->window->drawable.id,
+            xwl_window->has_implicit_scanout_support ? "" : "not");
 }
 
 static void
diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h
index 65dfb69ff..92c700e41 100644
--- a/hw/xwayland/xwayland-window.h
+++ b/hw/xwayland/xwayland-window.h
@@ -119,6 +119,8 @@ struct xwl_window {
 #endif
     struct xwayland_surface_v1 *xwayland_surface;
     struct xwl_dmabuf_feedback feedback;
+    /* If TRUE, the window buffer format supports scanout with implicit modifier */
+    Bool has_implicit_scanout_support;
 };
 
 struct xwl_window *xwl_window_get(WindowPtr window);
commit 79ab129fdf28c4ef3468f078e46e920120c878b4
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 28 14:18:36 2023 +0200

    xwayland: Check for scanout support in tranches
    
    The helper function xwl_feedback_is_modifier_supported() walks all the
    formats of a feeedback tranche and checks for format/modifier support
    availability.
    
    Add scanout support to that so that a caller can easily restrict the
    tranches to those which support scanout.
    
    This is preparation work for the implicit scanout support, no functional
    change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 1552834a7..db1434ffb 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -124,11 +124,15 @@ xwl_glamor_is_modifier_supported_in_formats(struct xwl_format *formats, int num_
 
 static Bool
 xwl_feedback_is_modifier_supported(struct xwl_dmabuf_feedback *xwl_feedback,
-                                   uint32_t format, uint64_t modifier)
+                                   uint32_t format, uint64_t modifier,
+                                   int supports_scanout)
 {
     for (int i = 0; i < xwl_feedback->dev_formats_len; i++) {
         struct xwl_device_formats *dev_formats = &xwl_feedback->dev_formats[i];
 
+        if (supports_scanout && !dev_formats->supports_scanout)
+            continue;
+
         if (xwl_glamor_is_modifier_supported_in_formats(dev_formats->formats,
                                                         dev_formats->num_formats,
                                                         format, modifier))
@@ -157,11 +161,11 @@ xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
                                                            format, modifier);
     }
 
-    if (xwl_feedback_is_modifier_supported(&xwl_screen->default_feedback, format, modifier))
+    if (xwl_feedback_is_modifier_supported(&xwl_screen->default_feedback, format, modifier, FALSE))
         return TRUE;
 
     xorg_list_for_each_entry(xwl_window, &xwl_screen->window_list, link_window) {
-        if (xwl_feedback_is_modifier_supported(&xwl_window->feedback, format, modifier))
+        if (xwl_feedback_is_modifier_supported(&xwl_window->feedback, format, modifier, FALSE))
             return TRUE;
     }
 
commit 1a0cc25d488dee3c5972d9f0828d5eadfcdbe713
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Mar 27 11:20:12 2023 +0200

    xwayland: Use a dedicated feedback callback for windows
    
    Separate the callbacks for the default's feedback from the one for
    regular windows.
    
    This is preparation work to recreate the window buffer of feedback
    updates, no functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index edb028978..1552834a7 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -659,24 +659,6 @@ static const struct zwp_linux_dmabuf_feedback_v1_listener xwl_dmabuf_feedback_li
     .tranche_flags = xwl_dmabuf_feedback_tranche_flags,
 };
 
-Bool
-xwl_dmabuf_setup_feedback_for_window(struct xwl_window *xwl_window)
-{
-    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-
-    xwl_window->feedback.dmabuf_feedback =
-        zwp_linux_dmabuf_v1_get_surface_feedback(xwl_screen->dmabuf, xwl_window->surface);
-
-    if (!xwl_window->feedback.dmabuf_feedback)
-        return FALSE;
-
-    zwp_linux_dmabuf_feedback_v1_add_listener(xwl_window->feedback.dmabuf_feedback,
-                                              &xwl_dmabuf_feedback_listener,
-                                              &xwl_window->feedback);
-
-    return TRUE;
-}
-
 Bool
 xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
                                 uint32_t id, uint32_t version)
@@ -707,6 +689,102 @@ xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
     return TRUE;
 }
 
+static void
+xwl_window_dmabuf_feedback_main_device(void *data,
+                                       struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+                                       struct wl_array *dev)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_main_device(&xwl_window->feedback, dmabuf_feedback, dev);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_target_device(void *data,
+                                                 struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+                                                 struct wl_array *dev)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_tranche_target_device(&xwl_window->feedback, dmabuf_feedback, dev);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_flags(void *data,
+                                         struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+                                         uint32_t flags)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_tranche_flags(&xwl_window->feedback, dmabuf_feedback, flags);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_formats(void *data,
+                                           struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+                                           struct wl_array *indices)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_tranche_formats(&xwl_window->feedback, dmabuf_feedback, indices);
+}
+
+static void
+xwl_window_dmabuf_feedback_tranche_done(void *data,
+                                        struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_tranche_done(&xwl_window->feedback, dmabuf_feedback);
+}
+
+static void
+xwl_window_dmabuf_feedback_done(void *data,
+                                struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_done(&xwl_window->feedback, dmabuf_feedback);
+}
+
+static void
+xwl_window_dmabuf_feedback_format_table(void *data,
+                                        struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback,
+                                        int32_t fd, uint32_t size)
+{
+    struct xwl_window *xwl_window = data;
+
+    xwl_dmabuf_feedback_format_table(&xwl_window->feedback, dmabuf_feedback, fd, size);
+}
+
+static const struct zwp_linux_dmabuf_feedback_v1_listener xwl_window_dmabuf_feedback_listener = {
+    .done = xwl_window_dmabuf_feedback_done,
+    .format_table = xwl_window_dmabuf_feedback_format_table,
+    .main_device = xwl_window_dmabuf_feedback_main_device,
+    .tranche_done = xwl_window_dmabuf_feedback_tranche_done,
+    .tranche_target_device = xwl_window_dmabuf_feedback_tranche_target_device,
+    .tranche_formats = xwl_window_dmabuf_feedback_tranche_formats,
+    .tranche_flags = xwl_window_dmabuf_feedback_tranche_flags,
+};
+
+Bool
+xwl_dmabuf_setup_feedback_for_window(struct xwl_window *xwl_window)
+{
+    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+
+    xwl_window->feedback.dmabuf_feedback =
+        zwp_linux_dmabuf_v1_get_surface_feedback(xwl_screen->dmabuf, xwl_window->surface);
+
+    if (!xwl_window->feedback.dmabuf_feedback)
+        return FALSE;
+
+    zwp_linux_dmabuf_feedback_v1_add_listener(xwl_window->feedback.dmabuf_feedback,
+                                              &xwl_window_dmabuf_feedback_listener,
+                                              xwl_window);
+
+    return TRUE;
+}
+
 void
 xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                             struct wl_registry *registry,


More information about the xorg-commit mailing list