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

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