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

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