Blame SOURCES/0003-xwayland-Add-check_flip-glamor-backend-function.patch

d05f4b
From c42d3e8edc85856f95c971d5fbc5d59011c23cdc Mon Sep 17 00:00:00 2001
d05f4b
From: Erik Kurzinger <ekurzinger@nvidia.com>
d05f4b
Date: Wed, 3 Mar 2021 11:56:41 +0100
d05f4b
Subject: [PATCH xserver 03/27] xwayland: Add check_flip() glamor backend
d05f4b
 function
d05f4b
MIME-Version: 1.0
d05f4b
Content-Type: text/plain; charset=UTF-8
d05f4b
Content-Transfer-Encoding: 8bit
d05f4b
d05f4b
This is preliminary work for hardware accelerated rendering with the
d05f4b
NVIDIA driver.
d05f4b
d05f4b
This exposes a new glamor backend function, check_flip, which can be
d05f4b
used to control whether flipping is supported for the given pixmap.
d05f4b
d05f4b
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
d05f4b
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
d05f4b
Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
d05f4b
(cherry picked from commit bc99dd2127f12f1aae55971c09a2792eeaa98444)
d05f4b
---
d05f4b
 hw/xwayland/xwayland-glamor-eglstream.c |  7 +++++++
d05f4b
 hw/xwayland/xwayland-glamor-gbm.c       |  1 +
d05f4b
 hw/xwayland/xwayland-glamor.c           | 11 +++++++++++
d05f4b
 hw/xwayland/xwayland-glamor.h           |  6 ++++++
d05f4b
 4 files changed, 25 insertions(+)
d05f4b
d05f4b
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
d05f4b
index 9b2c2c43f..ccaa59cbe 100644
d05f4b
--- a/hw/xwayland/xwayland-glamor-eglstream.c
d05f4b
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
d05f4b
@@ -633,6 +633,12 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
d05f4b
     pixmap->refcnt++;
d05f4b
 }
d05f4b
 
d05f4b
+static Bool
d05f4b
+xwl_glamor_eglstream_check_flip(PixmapPtr pixmap)
d05f4b
+{
d05f4b
+    return FALSE;
d05f4b
+}
d05f4b
+
d05f4b
 static void
d05f4b
 xwl_eglstream_display_handle_caps(void *data,
d05f4b
                                   struct wl_eglstream_display *disp,
d05f4b
@@ -942,6 +948,7 @@ xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
d05f4b
     xwl_screen->eglstream_backend.get_wl_buffer_for_pixmap = xwl_glamor_eglstream_get_wl_buffer_for_pixmap;
d05f4b
     xwl_screen->eglstream_backend.post_damage = xwl_glamor_eglstream_post_damage;
d05f4b
     xwl_screen->eglstream_backend.allow_commits = xwl_glamor_eglstream_allow_commits;
d05f4b
+    xwl_screen->eglstream_backend.check_flip = xwl_glamor_eglstream_check_flip;
d05f4b
     xwl_screen->eglstream_backend.is_available = TRUE;
d05f4b
     xwl_screen->eglstream_backend.backend_flags = XWL_EGL_BACKEND_NO_FLAG;
d05f4b
 }
d05f4b
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
d05f4b
index 455b755ca..1b1d517da 100644
d05f4b
--- a/hw/xwayland/xwayland-glamor-gbm.c
d05f4b
+++ b/hw/xwayland/xwayland-glamor-gbm.c
d05f4b
@@ -967,6 +967,7 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
d05f4b
     xwl_screen->gbm_backend.init_egl = xwl_glamor_gbm_init_egl;
d05f4b
     xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
d05f4b
     xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
d05f4b
+    xwl_screen->gbm_backend.check_flip = NULL;
d05f4b
     xwl_screen->gbm_backend.is_available = TRUE;
d05f4b
     xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_HAS_PRESENT_FLIP |
d05f4b
                                             XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH |
d05f4b
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
d05f4b
index d8bf1bd5d..060471f01 100644
d05f4b
--- a/hw/xwayland/xwayland-glamor.c
d05f4b
+++ b/hw/xwayland/xwayland-glamor.c
d05f4b
@@ -79,6 +79,17 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
d05f4b
     xwl_screen->glamor_ctx = glamor_ctx;
d05f4b
 }
d05f4b
 
d05f4b
+Bool
d05f4b
+xwl_glamor_check_flip(PixmapPtr pixmap)
d05f4b
+{
d05f4b
+    struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
d05f4b
+
d05f4b
+    if (xwl_screen->egl_backend->check_flip)
d05f4b
+        return xwl_screen->egl_backend->check_flip(pixmap);
d05f4b
+
d05f4b
+    return TRUE;
d05f4b
+}
d05f4b
+
d05f4b
 Bool
d05f4b
 xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
d05f4b
                                  uint32_t format, uint64_t modifier)
d05f4b
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
d05f4b
index 1637a0733..a86b30b40 100644
d05f4b
--- a/hw/xwayland/xwayland-glamor.h
d05f4b
+++ b/hw/xwayland/xwayland-glamor.h
d05f4b
@@ -92,6 +92,11 @@ struct xwl_egl_backend {
d05f4b
      * callback is optional.
d05f4b
      */
d05f4b
     Bool (*allow_commits)(struct xwl_window *xwl_window);
d05f4b
+
d05f4b
+    /* Called by Xwayland to check whether the given pixmap can be
d05f4b
+     * presented by xwl_present_flip. If not implemented, assumed TRUE.
d05f4b
+     */
d05f4b
+    Bool (*check_flip)(PixmapPtr pixmap);
d05f4b
 };
d05f4b
 
d05f4b
 #ifdef XWL_HAS_GLAMOR
d05f4b
@@ -127,6 +132,7 @@ Bool xwl_glamor_get_formats(ScreenPtr screen,
d05f4b
                             CARD32 *num_formats, CARD32 **formats);
d05f4b
 Bool xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
d05f4b
                               uint32_t *num_modifiers, uint64_t **modifiers);
d05f4b
+Bool xwl_glamor_check_flip(PixmapPtr pixmap);
d05f4b
 
d05f4b
 #ifdef XV
d05f4b
 /* glamor Xv Adaptor */
d05f4b
-- 
d05f4b
2.31.1
d05f4b