Blame SOURCES/0004-xwayland-implement-pixmap_from_buffers-for-the-eglst.patch

b6a310
From 6d1529b8d6b3e7c8bf758b670e2122a6af4d5346 Mon Sep 17 00:00:00 2001
b6a310
From: Erik Kurzinger <ekurzinger@nvidia.com>
b6a310
Date: Thu, 3 Dec 2020 14:57:51 -0800
b6a310
Subject: [PATCH xserver 04/27] xwayland: implement pixmap_from_buffers for the
b6a310
 eglstream backend
b6a310
MIME-Version: 1.0
b6a310
Content-Type: text/plain; charset=UTF-8
b6a310
Content-Transfer-Encoding: 8bit
b6a310
b6a310
Provides an implementation for the pixmap_from_buffers DRI3 function for
b6a310
xwayland's eglstream backend. This will be used by the NVIDIA GLX driver
b6a310
to pass buffers from client applications to the server. These can then
b6a310
be presented using the PRESENT extension.
b6a310
b6a310
To hopefully make this less error-prone, we also introduce a "type"
b6a310
field for this struct to distinguish between xwl_pixmaps for the new
b6a310
DRI3-created pixmaps and those for the existing glamor-created pixmaps.
b6a310
b6a310
Additionally, the patch enables wnmd present mode with the eglstream backend.
b6a310
This involves creating a wl_buffer for the provided dma-buf before importing it
b6a310
into EGL and passing this to the compositor so it can be scanned out directly
b6a310
if possible.
b6a310
b6a310
Since both backends now support this present mode, the HAS_PRESENT_FLIP flag is
b6a310
no longer needed, so it can be removed.
b6a310
b6a310
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
b6a310
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
b6a310
Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
b6a310
(cherry picked from commit 38e875904b039ec1889e7c81eb1d577a4f69b26d)
b6a310
---
b6a310
 hw/xwayland/xwayland-glamor-eglstream.c | 202 +++++++++++++++++++++++-
b6a310
 hw/xwayland/xwayland-glamor-gbm.c       |   3 +-
b6a310
 hw/xwayland/xwayland-glamor.c           |  12 --
b6a310
 hw/xwayland/xwayland-glamor.h           |   6 +-
b6a310
 hw/xwayland/xwayland-present.c          |   5 +-
b6a310
 5 files changed, 204 insertions(+), 24 deletions(-)
b6a310
b6a310
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
b6a310
index ccaa59cbe..2d8380e1f 100644
b6a310
--- a/hw/xwayland/xwayland-glamor-eglstream.c
b6a310
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
b6a310
@@ -37,6 +37,8 @@
b6a310
 #include <glamor_transfer.h>
b6a310
 
b6a310
 #include <xf86drm.h>
b6a310
+#include <dri3.h>
b6a310
+#include <drm_fourcc.h>
b6a310
 
b6a310
 #include <epoxy/egl.h>
b6a310
 
b6a310
@@ -47,6 +49,7 @@
b6a310
 
b6a310
 #include "wayland-eglstream-client-protocol.h"
b6a310
 #include "wayland-eglstream-controller-client-protocol.h"
b6a310
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
b6a310
 
b6a310
 struct xwl_eglstream_pending_stream {
b6a310
     PixmapPtr pixmap;
b6a310
@@ -80,12 +83,23 @@ struct xwl_eglstream_private {
b6a310
     GLuint blit_is_rgba_pos;
b6a310
 };
b6a310
 
b6a310
+enum xwl_pixmap_type {
b6a310
+    XWL_PIXMAP_EGLSTREAM, /* Pixmaps created by glamor. */
b6a310
+    XWL_PIXMAP_DMA_BUF, /* Pixmaps allocated through DRI3. */
b6a310
+};
b6a310
+
b6a310
 struct xwl_pixmap {
b6a310
-    struct wl_buffer *buffer;
b6a310
+    enum xwl_pixmap_type type;
b6a310
+    /* add any new <= 4-byte member here to avoid holes on 64-bit */
b6a310
     struct xwl_screen *xwl_screen;
b6a310
+    struct wl_buffer *buffer;
b6a310
 
b6a310
+    /* XWL_PIXMAP_EGLSTREAM. */
b6a310
     EGLStreamKHR stream;
b6a310
     EGLSurface surface;
b6a310
+
b6a310
+    /* XWL_PIXMAP_DMA_BUF. */
b6a310
+    EGLImage image;
b6a310
 };
b6a310
 
b6a310
 static DevPrivateKeyRec xwl_eglstream_private_key;
b6a310
@@ -289,12 +303,18 @@ xwl_eglstream_unref_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
b6a310
                        xwl_screen->egl_context);
b6a310
     }
b6a310
 
b6a310
-    if (xwl_pixmap->surface)
b6a310
+    if (xwl_pixmap->surface != EGL_NO_SURFACE)
b6a310
         eglDestroySurface(xwl_screen->egl_display, xwl_pixmap->surface);
b6a310
 
b6a310
-    eglDestroyStreamKHR(xwl_screen->egl_display, xwl_pixmap->stream);
b6a310
+    if (xwl_pixmap->stream != EGL_NO_STREAM_KHR)
b6a310
+        eglDestroyStreamKHR(xwl_screen->egl_display, xwl_pixmap->stream);
b6a310
+
b6a310
+    if (xwl_pixmap->buffer)
b6a310
+        wl_buffer_destroy(xwl_pixmap->buffer);
b6a310
+
b6a310
+    if (xwl_pixmap->image != EGL_NO_IMAGE_KHR)
b6a310
+        eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image);
b6a310
 
b6a310
-    wl_buffer_destroy(xwl_pixmap->buffer);
b6a310
     free(xwl_pixmap);
b6a310
 }
b6a310
 
b6a310
@@ -509,9 +529,13 @@ xwl_eglstream_create_pending_stream(struct xwl_screen *xwl_screen,
b6a310
         FatalError("Not enough memory to create pixmap\n");
b6a310
     xwl_pixmap_set_private(pixmap, xwl_pixmap);
b6a310
 
b6a310
+    xwl_pixmap->type = XWL_PIXMAP_EGLSTREAM;
b6a310
+    xwl_pixmap->image = EGL_NO_IMAGE;
b6a310
+
b6a310
     xwl_glamor_egl_make_current(xwl_screen);
b6a310
 
b6a310
     xwl_pixmap->xwl_screen = xwl_screen;
b6a310
+    xwl_pixmap->surface = EGL_NO_SURFACE;
b6a310
     xwl_pixmap->stream = eglCreateStreamKHR(xwl_screen->egl_display, NULL);
b6a310
     stream_fd = eglGetStreamFileDescriptorKHR(xwl_screen->egl_display,
b6a310
                                               xwl_pixmap->stream);
b6a310
@@ -552,6 +576,7 @@ xwl_glamor_eglstream_allow_commits(struct xwl_window *xwl_window)
b6a310
     struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
b6a310
 
b6a310
     if (xwl_pixmap) {
b6a310
+        assert(xwl_pixmap->type == XWL_PIXMAP_EGLSTREAM);
b6a310
         if (pending) {
b6a310
             /* Wait for the compositor to finish connecting the consumer for
b6a310
              * this eglstream */
b6a310
@@ -590,6 +615,8 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
b6a310
     };
b6a310
     GLint saved_vao;
b6a310
 
b6a310
+    assert(xwl_pixmap->type == XWL_PIXMAP_EGLSTREAM);
b6a310
+
b6a310
     /* Unbind the framebuffer BEFORE binding the EGLSurface, otherwise we
b6a310
      * won't actually draw to it
b6a310
      */
b6a310
@@ -636,7 +663,7 @@ xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
b6a310
 static Bool
b6a310
 xwl_glamor_eglstream_check_flip(PixmapPtr pixmap)
b6a310
 {
b6a310
-    return FALSE;
b6a310
+    return xwl_pixmap_get(pixmap)->type == XWL_PIXMAP_DMA_BUF;
b6a310
 }
b6a310
 
b6a310
 static void
b6a310
@@ -681,6 +708,9 @@ xwl_glamor_eglstream_init_wl_registry(struct xwl_screen *xwl_screen,
b6a310
         xwl_eglstream->controller = wl_registry_bind(
b6a310
             wl_registry, id, &wl_eglstream_controller_interface, version);
b6a310
         return TRUE;
b6a310
+    } else if (strcmp(name, "zwp_linux_dmabuf_v1") == 0) {
b6a310
+        xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
b6a310
+        return TRUE;
b6a310
     }
b6a310
 
b6a310
     /* no match */
b6a310
@@ -779,6 +809,163 @@ xwl_eglstream_init_shaders(struct xwl_screen *xwl_screen)
b6a310
         glGetUniformLocation(xwl_eglstream->blit_prog, "is_rgba");
b6a310
 }
b6a310
 
b6a310
+static int
b6a310
+xwl_dri3_open_client(ClientPtr client,
b6a310
+                     ScreenPtr screen,
b6a310
+                     RRProviderPtr provider,
b6a310
+                     int *pfd)
b6a310
+{
b6a310
+    /* Not supported with this backend. */
b6a310
+    return BadImplementation;
b6a310
+}
b6a310
+
b6a310
+static PixmapPtr
b6a310
+xwl_dri3_pixmap_from_fds(ScreenPtr screen,
b6a310
+                         CARD8 num_fds, const int *fds,
b6a310
+                         CARD16 width, CARD16 height,
b6a310
+                         const CARD32 *strides, const CARD32 *offsets,
b6a310
+                         CARD8 depth, CARD8 bpp,
b6a310
+                         uint64_t modifier)
b6a310
+{
b6a310
+    PixmapPtr pixmap;
b6a310
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
b6a310
+    struct xwl_pixmap *xwl_pixmap;
b6a310
+    unsigned int texture;
b6a310
+    EGLint image_attribs[48];
b6a310
+    uint32_t mod_hi = modifier >> 32, mod_lo = modifier & 0xffffffff, format;
b6a310
+    int attrib = 0, i;
b6a310
+    struct zwp_linux_buffer_params_v1 *params;
b6a310
+
b6a310
+    format = wl_drm_format_for_depth(depth);
b6a310
+    if (!xwl_glamor_is_modifier_supported(xwl_screen, format, modifier)) {
b6a310
+        ErrorF("glamor: unsupported format modifier\n");
b6a310
+        return NULL;
b6a310
+    }
b6a310
+
b6a310
+    xwl_pixmap = calloc(1, sizeof (*xwl_pixmap));
b6a310
+    if (!xwl_pixmap)
b6a310
+        return NULL;
b6a310
+    xwl_pixmap->type = XWL_PIXMAP_DMA_BUF;
b6a310
+    xwl_pixmap->xwl_screen = xwl_screen;
b6a310
+
b6a310
+    xwl_pixmap->buffer = NULL;
b6a310
+    xwl_pixmap->stream = EGL_NO_STREAM_KHR;
b6a310
+    xwl_pixmap->surface = EGL_NO_SURFACE;
b6a310
+
b6a310
+    params = zwp_linux_dmabuf_v1_create_params(xwl_screen->dmabuf);
b6a310
+    for (i = 0; i < num_fds; i++) {
b6a310
+        zwp_linux_buffer_params_v1_add(params, fds[i], i,
b6a310
+                                       offsets[i], strides[i],
b6a310
+                                       mod_hi, mod_lo);
b6a310
+    }
b6a310
+    xwl_pixmap->buffer =
b6a310
+        zwp_linux_buffer_params_v1_create_immed(params, width, height,
b6a310
+                                                format, 0);
b6a310
+    zwp_linux_buffer_params_v1_destroy(params);
b6a310
+
b6a310
+
b6a310
+    image_attribs[attrib++] = EGL_WIDTH;
b6a310
+    image_attribs[attrib++] = width;
b6a310
+    image_attribs[attrib++] = EGL_HEIGHT;
b6a310
+    image_attribs[attrib++] = height;
b6a310
+    image_attribs[attrib++] = EGL_LINUX_DRM_FOURCC_EXT;
b6a310
+    image_attribs[attrib++] = drm_format_for_depth(depth, bpp);
b6a310
+
b6a310
+    if (num_fds > 0) {
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_FD_EXT;
b6a310
+        image_attribs[attrib++] = fds[0];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
b6a310
+        image_attribs[attrib++] = offsets[0];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
b6a310
+        image_attribs[attrib++] = strides[0];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
b6a310
+        image_attribs[attrib++] = mod_hi;
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
b6a310
+        image_attribs[attrib++] = mod_lo;
b6a310
+    }
b6a310
+    if (num_fds > 1) {
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_FD_EXT;
b6a310
+        image_attribs[attrib++] = fds[1];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT;
b6a310
+        image_attribs[attrib++] = offsets[1];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
b6a310
+        image_attribs[attrib++] = strides[1];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
b6a310
+        image_attribs[attrib++] = mod_hi;
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
b6a310
+        image_attribs[attrib++] = mod_lo;
b6a310
+    }
b6a310
+    if (num_fds > 2) {
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_FD_EXT;
b6a310
+        image_attribs[attrib++] = fds[2];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_OFFSET_EXT;
b6a310
+        image_attribs[attrib++] = offsets[2];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
b6a310
+        image_attribs[attrib++] = strides[2];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT;
b6a310
+        image_attribs[attrib++] = mod_hi;
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT;
b6a310
+        image_attribs[attrib++] = mod_lo;
b6a310
+    }
b6a310
+    if (num_fds > 3) {
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_FD_EXT;
b6a310
+        image_attribs[attrib++] = fds[3];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
b6a310
+        image_attribs[attrib++] = offsets[3];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_PITCH_EXT;
b6a310
+        image_attribs[attrib++] = strides[3];
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
b6a310
+        image_attribs[attrib++] = mod_hi;
b6a310
+        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
b6a310
+        image_attribs[attrib++] = mod_lo;
b6a310
+    }
b6a310
+    image_attribs[attrib++] = EGL_NONE;
b6a310
+
b6a310
+    xwl_glamor_egl_make_current(xwl_screen);
b6a310
+
b6a310
+    /* eglCreateImageKHR will close fds */
b6a310
+    xwl_pixmap->image = eglCreateImageKHR(xwl_screen->egl_display,
b6a310
+                                          EGL_NO_CONTEXT,
b6a310
+                                          EGL_LINUX_DMA_BUF_EXT,
b6a310
+                                          NULL, image_attribs);
b6a310
+    if (xwl_pixmap->image == EGL_NO_IMAGE_KHR) {
b6a310
+        ErrorF("eglCreateImageKHR failed!\n");
b6a310
+        if (xwl_pixmap->buffer)
b6a310
+            wl_buffer_destroy(xwl_pixmap->buffer);
b6a310
+        free(xwl_pixmap);
b6a310
+        return NULL;
b6a310
+    }
b6a310
+
b6a310
+    glGenTextures(1, &texture);
b6a310
+    glBindTexture(GL_TEXTURE_2D, texture);
b6a310
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
b6a310
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
b6a310
+    glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image);
b6a310
+    glBindTexture(GL_TEXTURE_2D, 0);
b6a310
+
b6a310
+    pixmap = glamor_create_pixmap(screen, width, height, depth,
b6a310
+                                  GLAMOR_CREATE_PIXMAP_NO_TEXTURE);
b6a310
+    glamor_set_pixmap_texture(pixmap, texture);
b6a310
+    glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
b6a310
+    wl_buffer_add_listener(xwl_pixmap->buffer,
b6a310
+                           &xwl_eglstream_buffer_release_listener,
b6a310
+                           pixmap);
b6a310
+    xwl_pixmap_set_private(pixmap, xwl_pixmap);
b6a310
+
b6a310
+    return pixmap;
b6a310
+}
b6a310
+
b6a310
+static const dri3_screen_info_rec xwl_dri3_info = {
b6a310
+    .version = 2,
b6a310
+    .open = NULL,
b6a310
+    .pixmap_from_fds = xwl_dri3_pixmap_from_fds,
b6a310
+    .fds_from_pixmap = NULL,
b6a310
+    .open_client = xwl_dri3_open_client,
b6a310
+    .get_formats = xwl_glamor_get_formats,
b6a310
+    .get_modifiers = xwl_glamor_get_modifiers,
b6a310
+    .get_drawable_modifiers = glamor_get_drawable_modifiers,
b6a310
+};
b6a310
+
b6a310
 static Bool
b6a310
 xwl_glamor_eglstream_init_egl(struct xwl_screen *xwl_screen)
b6a310
 {
b6a310
@@ -858,6 +1045,11 @@ xwl_glamor_eglstream_init_egl(struct xwl_screen *xwl_screen)
b6a310
 
b6a310
     xwl_eglstream_init_shaders(xwl_screen);
b6a310
 
b6a310
+    if (epoxy_has_gl_extension("GL_OES_EGL_image") &&
b6a310
+        !dri3_screen_init(xwl_screen->screen, &xwl_dri3_info)) {
b6a310
+        ErrorF("DRI3 initialization failed. Performance will be affected.\n");
b6a310
+    }
b6a310
+
b6a310
     return TRUE;
b6a310
 error:
b6a310
     xwl_eglstream_cleanup(xwl_screen);
b6a310
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
b6a310
index 1b1d517da..12d820e44 100644
b6a310
--- a/hw/xwayland/xwayland-glamor-gbm.c
b6a310
+++ b/hw/xwayland/xwayland-glamor-gbm.c
b6a310
@@ -969,7 +969,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
b6a310
     xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
b6a310
     xwl_screen->gbm_backend.check_flip = NULL;
b6a310
     xwl_screen->gbm_backend.is_available = TRUE;
b6a310
-    xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_HAS_PRESENT_FLIP |
b6a310
-                                            XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH |
b6a310
+    xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH |
b6a310
                                             XWL_EGL_BACKEND_NEEDS_N_BUFFERING;
b6a310
 }
b6a310
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
b6a310
index 060471f01..9e44d5106 100644
b6a310
--- a/hw/xwayland/xwayland-glamor.c
b6a310
+++ b/hw/xwayland/xwayland-glamor.c
b6a310
@@ -362,16 +362,6 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
b6a310
     return 0;
b6a310
 }
b6a310
 
b6a310
-Bool
b6a310
-xwl_glamor_has_present_flip(struct xwl_screen *xwl_screen)
b6a310
-{
b6a310
-    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
b6a310
-        return FALSE;
b6a310
-
b6a310
-    return (xwl_screen->egl_backend->backend_flags &
b6a310
-                XWL_EGL_BACKEND_HAS_PRESENT_FLIP);
b6a310
-}
b6a310
-
b6a310
 Bool
b6a310
 xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen)
b6a310
 {
b6a310
@@ -430,8 +420,6 @@ xwl_glamor_select_eglstream_backend(struct xwl_screen *xwl_screen)
b6a310
 #ifdef XWL_HAS_EGLSTREAM
b6a310
     if (xwl_screen->eglstream_backend.is_available &&
b6a310
         xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->eglstream_backend)) {
b6a310
-        ErrorF("glamor: Using nvidia's EGLStream interface, direct rendering impossible.\n");
b6a310
-        ErrorF("glamor: Performance may be affected. Ask your vendor to support GBM!\n");
b6a310
         xwl_screen->egl_backend = &xwl_screen->eglstream_backend;
b6a310
         return TRUE;
b6a310
     }
b6a310
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
b6a310
index a86b30b40..26ab78f04 100644
b6a310
--- a/hw/xwayland/xwayland-glamor.h
b6a310
+++ b/hw/xwayland/xwayland-glamor.h
b6a310
@@ -34,9 +34,8 @@
b6a310
 
b6a310
 typedef enum _xwl_egl_backend_flags {
b6a310
     XWL_EGL_BACKEND_NO_FLAG = 0,
b6a310
-    XWL_EGL_BACKEND_HAS_PRESENT_FLIP = (1 << 0),
b6a310
-    XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH = (1 << 1),
b6a310
-    XWL_EGL_BACKEND_NEEDS_N_BUFFERING = (1 << 2),
b6a310
+    XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH = (1 << 0),
b6a310
+    XWL_EGL_BACKEND_NEEDS_N_BUFFERING = (1 << 1),
b6a310
 } xwl_egl_backend_flags;
b6a310
 
b6a310
 struct xwl_egl_backend {
b6a310
@@ -122,7 +121,6 @@ void xwl_glamor_post_damage(struct xwl_window *xwl_window,
b6a310
                             PixmapPtr pixmap, RegionPtr region);
b6a310
 Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
b6a310
 void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
b6a310
-Bool xwl_glamor_has_present_flip(struct xwl_screen *xwl_screen);
b6a310
 Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
b6a310
 Bool xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen);
b6a310
 Bool xwl_glamor_is_modifier_supported(struct xwl_screen *xwl_screen,
b6a310
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
b6a310
index 666ea15e7..7ba7efc11 100644
b6a310
--- a/hw/xwayland/xwayland-present.c
b6a310
+++ b/hw/xwayland/xwayland-present.c
b6a310
@@ -404,6 +404,9 @@ xwl_present_check_flip2(RRCrtcPtr crtc,
b6a310
     if (!xwl_window)
b6a310
         return FALSE;
b6a310
 
b6a310
+    if (!xwl_glamor_check_flip(pixmap))
b6a310
+        return FALSE;
b6a310
+
b6a310
     /* Can't flip if the window pixmap doesn't match the xwl_window parent
b6a310
      * window's, e.g. because a client redirected this window or one of its
b6a310
      * parents.
b6a310
@@ -540,7 +543,7 @@ xwl_present_init(ScreenPtr screen)
b6a310
 {
b6a310
     struct xwl_screen *xwl_screen = xwl_screen_get(screen);
b6a310
 
b6a310
-    if (!xwl_glamor_has_present_flip(xwl_screen))
b6a310
+    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
b6a310
         return FALSE;
b6a310
 
b6a310
     if (!dixRegisterPrivateKey(&xwl_present_window_private_key, PRIVATE_WINDOW, 0))
b6a310
-- 
b6a310
2.31.1
b6a310