xserver: Branch 'master' - 24 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 18 16:10:15 UTC 2024


 hw/xwayland/man/Xwayland.man            |    7 
 hw/xwayland/meson.build                 |   23 
 hw/xwayland/xwayland-dmabuf.c           |   20 
 hw/xwayland/xwayland-glamor-eglstream.c | 1129 --------------------------------
 hw/xwayland/xwayland-glamor-gbm.c       |   82 --
 hw/xwayland/xwayland-glamor-gbm.h       |   45 +
 hw/xwayland/xwayland-glamor.c           |  173 ----
 hw/xwayland/xwayland-glamor.h           |  102 --
 hw/xwayland/xwayland-screen.c           |   33 
 hw/xwayland/xwayland-screen.h           |    5 
 hw/xwayland/xwayland-types.h            |    1 
 hw/xwayland/xwayland-window-buffers.c   |   13 
 hw/xwayland/xwayland-window-buffers.h   |    1 
 hw/xwayland/xwayland-window.c           |   11 
 hw/xwayland/xwayland.c                  |    6 
 include/meson.build                     |    3 
 include/xwayland-config.h.meson.in      |    3 
 meson.build                             |   15 
 meson_options.txt                       |    2 
 19 files changed, 110 insertions(+), 1564 deletions(-)

New commits:
commit 54a2dfc229ed076ed733ac161ec0afbb22931448
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 16:48:59 2024 +0100

    xwayland: Drop xwl_window_buffers_get_pixmap()
    
    This just calls into xwl_window_swap_pixmap() so we can just use that
    instead (Michel).
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c
index 5e9a1a99c..ced9d9567 100644
--- a/hw/xwayland/xwayland-window-buffers.c
+++ b/hw/xwayland/xwayland-window-buffers.c
@@ -396,9 +396,3 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window)
 
     return xwl_window_buffer->pixmap;
 }
-
-PixmapPtr
-xwl_window_buffers_get_pixmap(struct xwl_window *xwl_window)
-{
-    return xwl_window_swap_pixmap(xwl_window);
-}
diff --git a/hw/xwayland/xwayland-window-buffers.h b/hw/xwayland/xwayland-window-buffers.h
index ac4c9aa6e..8b463e671 100644
--- a/hw/xwayland/xwayland-window-buffers.h
+++ b/hw/xwayland/xwayland-window-buffers.h
@@ -38,6 +38,5 @@ void xwl_window_buffers_init(struct xwl_window *xwl_window);
 void xwl_window_buffers_dispose(struct xwl_window *xwl_window);
 void xwl_window_realloc_pixmap(struct xwl_window *xwl_window);
 PixmapPtr xwl_window_swap_pixmap(struct xwl_window *xwl_window);
-PixmapPtr xwl_window_buffers_get_pixmap(struct xwl_window *xwl_window);
 
 #endif /* XWAYLAND_WINDOW_BUFFERS_H */
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 43293cadf..6774ba096 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -1349,7 +1349,7 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window)
     PixmapPtr pixmap;
     int i;
 
-    pixmap = xwl_window_buffers_get_pixmap(xwl_window);
+    pixmap = xwl_window_swap_pixmap(xwl_window);
     buffer = xwl_pixmap_get_wl_buffer(pixmap);
 
     if (!buffer) {
commit 656d2efd4bdd10f672f74aeda009dc8dab2e37f2
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 16:33:06 2024 +0100

    xwayland/glamor: Drop xwl_glamor_needs_n_buffering()
    
    This function always return TRUE now that EGLSTream is gone, so we can
    remove it.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index a946c5264..d2b7739e1 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -269,12 +269,6 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
     return 0;
 }
 
-Bool
-xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen)
-{
-    return TRUE;
-}
-
 Bool
 xwl_glamor_init(struct xwl_screen *xwl_screen)
 {
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 6c07ea8ef..297ae1786 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -55,7 +55,6 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  uint32_t id, const char *interface,
                                  uint32_t version);
 void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
-Bool xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap);
 PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
 
diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c
index 47f27126d..5e9a1a99c 100644
--- a/hw/xwayland/xwayland-window-buffers.c
+++ b/hw/xwayland/xwayland-window-buffers.c
@@ -400,12 +400,5 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window)
 PixmapPtr
 xwl_window_buffers_get_pixmap(struct xwl_window *xwl_window)
 {
-#ifdef XWL_HAS_GLAMOR
-    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-
-    if (!xwl_glamor_needs_n_buffering(xwl_screen))
-        return xwl_screen->screen->GetWindowPixmap(xwl_window->window);
-#endif /* XWL_HAS_GLAMOR */
-
     return xwl_window_swap_pixmap(xwl_window);
 }
commit d422b409262bd2c15d64920859a5d6a29a14a8b3
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 16:30:13 2024 +0100

    xwayland/glamor: Drop xwl_glamor_needs_buffer_flush()
    
    GLAMOR needs that, and the function returns TRUE unless GLAMOR is not
    used.
    
    Drop the function xwl_glamor_needs_buffer_flush() and call
    glamor_block_handler() when glamor is used.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index f8540d8ed..a946c5264 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -269,15 +269,6 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
     return 0;
 }
 
-Bool
-xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen)
-{
-    if (!xwl_screen->glamor)
-        return FALSE;
-
-    return TRUE;
-}
-
 Bool
 xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen)
 {
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 40ddb430c..6c07ea8ef 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -55,7 +55,6 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  uint32_t id, const char *interface,
                                  uint32_t version);
 void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
-Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap);
 PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index a268d9378..b1fce53ae 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -416,7 +416,7 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
         return;
 
 #ifdef XWL_HAS_GLAMOR
-    if (xwl_glamor_needs_buffer_flush(xwl_screen))
+    if (xwl_screen->glamor)
         glamor_block_handler(xwl_screen->screen);
 #endif
 
commit 6466c1ee81c5e82a1e5add13fcb07bb2ef6141c2
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 16:26:42 2024 +0100

    xwayland/glamor: Drop xwl_screen_get_main_dev()
    
    This is made redundant with xwl_gbm_get_main_device(), and this is not
    really an xwl_screen function either.
    
    Let's remove it.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c
index 7133922dc..4897c2708 100644
--- a/hw/xwayland/xwayland-dmabuf.c
+++ b/hw/xwayland/xwayland-dmabuf.c
@@ -169,12 +169,6 @@ wl_drm_format_for_depth(int depth)
     }
 }
 
-static drmDevice *
-xwl_screen_get_main_dev(struct xwl_screen *xwl_screen)
-{
-    return xwl_gbm_get_main_device(xwl_screen);
-}
-
 static Bool
 xwl_dmabuf_get_formats(struct xwl_format *format_array, int format_array_len,
                        CARD32 *num_formats, CARD32 **formats)
@@ -248,7 +242,7 @@ xwl_glamor_get_formats(ScreenPtr screen,
         return FALSE;
 
     if (xwl_screen->dmabuf_protocol_version >= 4) {
-        drmDevice *main_dev = xwl_screen_get_main_dev(xwl_screen);
+        drmDevice *main_dev = xwl_gbm_get_main_device(xwl_screen);
 
         return xwl_dmabuf_get_formats_for_device(&xwl_screen->default_feedback, main_dev,
                                           num_formats, formats);
@@ -334,7 +328,7 @@ xwl_glamor_get_modifiers(ScreenPtr screen, uint32_t format,
         return FALSE;
 
     if (xwl_screen->dmabuf_protocol_version >= 4) {
-        main_dev = xwl_screen_get_main_dev(xwl_screen);
+        main_dev = xwl_gbm_get_main_device(xwl_screen);
 
         return xwl_dmabuf_get_modifiers_for_device(&xwl_screen->default_feedback, main_dev,
                                                    format, num_modifiers, modifiers, NULL);
@@ -373,7 +367,7 @@ xwl_glamor_get_drawable_modifiers_and_scanout(DrawablePtr drawable,
     if (!xwl_window)
         return FALSE;
 
-    main_dev = xwl_screen_get_main_dev(xwl_screen);
+    main_dev = xwl_gbm_get_main_device(xwl_screen);
 
     return xwl_dmabuf_get_modifiers_for_device(&xwl_window->feedback, main_dev,
                                                format, num_modifiers, modifiers,
commit ef29e05200abac83bae607cd19ca2f5bbd714f4f
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 15:08:32 2024 +0100

    xwayland/glamor: Drop the backend_flags definition
    
    Nobody uses that anymore.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index caef7b125..40ddb430c 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -36,12 +36,6 @@
 #include "xwayland-types.h"
 #include "xwayland-glamor-gbm.h"
 
-typedef enum _xwl_egl_backend_flags {
-    XWL_EGL_BACKEND_NO_FLAG = 0,
-    XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH = (1 << 0),
-    XWL_EGL_BACKEND_NEEDS_N_BUFFERING = (1 << 1),
-} xwl_egl_backend_flags;
-
 typedef enum _xwl_glamor_mode_flags{
     XWL_GLAMOR_NONE = 0,
     XWL_GLAMOR_GL = (1 << 0),
commit 888e3e7a94af1aaf95a22e88147519138995f05c
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 15:09:06 2024 +0100

    xwayland/glamor: Remove the xwl_egl_backend structure
    
    No more backend structure, one GBM backend to rule them all!
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 58ed3bcc0..caef7b125 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -49,74 +49,6 @@ typedef enum _xwl_glamor_mode_flags{
     XWL_GLAMOR_DEFAULT = XWL_GLAMOR_GL | XWL_GLAMOR_GLES,
 } xwl_glamor_mode_flags;
 
-struct xwl_egl_backend {
-    /* Set by the backend if available */
-    Bool is_available;
-
-    /* Features and requirements set by the backend */
-    xwl_egl_backend_flags backend_flags;
-
-    /* Called once for each interface in the global registry. Backends
-     * should use this to bind to any wayland interfaces they need.
-     */
-    Bool (*init_wl_registry)(struct xwl_screen *xwl_screen,
-                             struct wl_registry *wl_registry,
-                             uint32_t id, const char *name,
-                             uint32_t version);
-
-    /* Check that the required Wayland interfaces are available.
-     */
-    Bool (*has_wl_interfaces)(struct xwl_screen *xwl_screen);
-
-    /* Called before glamor has been initialized. Backends should setup a
-     * valid, glamor compatible EGL context in this hook.
-     */
-    Bool (*init_egl)(struct xwl_screen *xwl_screen);
-
-    /* Called after glamor has been initialized, and after all of the
-     * common Xwayland DDX hooks have been connected. Backends should use
-     * this to setup any required wraps around X server callbacks like
-     * CreatePixmap.
-     */
-    Bool (*init_screen)(struct xwl_screen *xwl_screen);
-
-    /* Called by Xwayland to retrieve a pointer to a valid wl_buffer for
-     * the given window/pixmap combo so that damage to the pixmap may be
-     * displayed on-screen. Backends should use this to create a new
-     * wl_buffer for a currently buffer-less pixmap, or simply return the
-     * pixmap they've prepared beforehand.
-     */
-    struct wl_buffer *(*get_wl_buffer_for_pixmap)(PixmapPtr pixmap);
-
-    /* Called by Xwayland to perform any pre-wl_surface damage routines
-     * that are required by the backend. If your backend is poorly
-     * designed and lacks the ability to render directly to a surface,
-     * you should implement blitting from the glamor pixmap to the wayland
-     * pixmap here. Otherwise, this callback is optional.
-     */
-    Bool (*post_damage)(struct xwl_window *xwl_window,
-                        PixmapPtr pixmap, RegionPtr region);
-
-    /* Called by Xwayland to confirm with the egl backend that the given
-     * pixmap is completely setup and ready for display on-screen. This
-     * callback is optional.
-     */
-    Bool (*allow_commits)(struct xwl_window *xwl_window);
-
-    /* Called by Xwayland to check whether the given pixmap can be
-     * presented by xwl_present_flip. If not implemented, assumed TRUE.
-     */
-    Bool (*check_flip)(PixmapPtr pixmap);
-
-    /* Called to get the DRM device of the primary GPU that this 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
 
 Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
diff --git a/hw/xwayland/xwayland-types.h b/hw/xwayland/xwayland-types.h
index 927a07168..73a674633 100644
--- a/hw/xwayland/xwayland-types.h
+++ b/hw/xwayland/xwayland-types.h
@@ -29,7 +29,6 @@
 struct xwl_pixmap;
 struct xwl_window;
 struct xwl_screen;
-struct xwl_egl_backend;
 struct xwl_drm_lease;
 struct xwl_output;
 
commit 8c0267b60f4443260fd57d790d3eac5d00ac9ccb
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 15:03:31 2024 +0100

    xwayland/glamor: Drop init_backend() and select_backend()
    
    Now that we have only one backend, there is no need to initialize or
    select between different backends.
    
    Drop the corresponding functions.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 51a56ccbf..f8540d8ed 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -284,37 +284,6 @@ xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen)
     return TRUE;
 }
 
-void
-xwl_glamor_init_backends(struct xwl_screen *xwl_screen)
-{
-#ifdef GLAMOR_HAS_GBM
-    if (!xwl_glamor_init_gbm(xwl_screen))
-        ErrorF("Xwayland glamor: GBM backend is not available\n");
-#endif
-}
-
-static Bool
-xwl_glamor_select_gbm_backend(struct xwl_screen *xwl_screen)
-{
-#ifdef GLAMOR_HAS_GBM
-    if (xwl_glamor_has_wl_interfaces(xwl_screen)) {
-        LogMessageVerb(X_INFO, 3, "glamor: Using GBM backend\n");
-        return TRUE;
-    }
-    else
-        LogMessageVerb(X_INFO, 3,
-                       "Missing Wayland requirements for glamor GBM backend\n");
-#endif
-
-    return FALSE;
-}
-
-void
-xwl_glamor_select_backend(struct xwl_screen *xwl_screen)
-{
-    xwl_glamor_select_gbm_backend(xwl_screen);
-}
-
 Bool
 xwl_glamor_init(struct xwl_screen *xwl_screen)
 {
@@ -327,6 +296,11 @@ xwl_glamor_init(struct xwl_screen *xwl_screen)
         return FALSE;
     }
 
+    if (!xwl_glamor_has_wl_interfaces(xwl_screen)) {
+        ErrorF("Xwayland glamor: GBM Wayland interfaces not available\n");
+        return FALSE;
+    }
+
     if (!xwl_glamor_gbm_init_egl(xwl_screen)) {
         ErrorF("EGL setup failed, disabling glamor\n");
         return FALSE;
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index d9a168447..58ed3bcc0 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -119,8 +119,6 @@ struct xwl_egl_backend {
 
 #ifdef XWL_HAS_GLAMOR
 
-void xwl_glamor_init_backends(struct xwl_screen *xwl_screen);
-void xwl_glamor_select_backend(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
 
 Bool xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index 2ffc5f9a9..a268d9378 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -869,8 +869,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     }
 
 #ifdef XWL_HAS_GLAMOR
-    if (xwl_screen->glamor)
-        xwl_glamor_init_backends(xwl_screen);
+    if (xwl_screen->glamor && !xwl_glamor_init_gbm(xwl_screen)) {
+        ErrorF("xwayland glamor: failed to setup GBM backend, falling back to sw accel\n");
+        xwl_screen->glamor = 0;
+    }
 #endif
 
     /* In rootless mode, we don't have any screen storage, and the only
@@ -992,13 +994,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
         return FALSE;
 
 #ifdef XWL_HAS_GLAMOR
-    if (xwl_screen->glamor) {
-        xwl_glamor_select_backend(xwl_screen);
-
-        if (!xwl_glamor_init(xwl_screen)) {
-           ErrorF("Failed to initialize glamor, falling back to sw\n");
-           xwl_screen->glamor = XWL_GLAMOR_NONE;
-        }
+    if (xwl_screen->glamor && !xwl_glamor_init(xwl_screen)) {
+       ErrorF("Failed to initialize glamor, falling back to sw\n");
+       xwl_screen->glamor = XWL_GLAMOR_NONE;
     }
 #endif
 
commit bceaca28d3f4d91e5ff8b298468abc48259bbe7e
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 14:57:52 2024 +0100

    xwayland/glamor: Remove the backend pointers
    
    We have only one backend now.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 92cb15c18..7cd4a6806 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -409,7 +409,7 @@ xwl_glamor_create_pixmap_for_window(struct xwl_window *xwl_window)
     WindowPtr window = xwl_window->window;
     unsigned border_width = 2 * window->borderWidth;
 
-    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
+    if (!xwl_screen->glamor)
         return NullPixmap;
 
     return xwl_glamor_gbm_create_pixmap_internal(xwl_screen,
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 23dc429c8..51a56ccbf 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -114,8 +114,7 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
 }
 
 static Bool
-xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
-                            struct xwl_egl_backend *xwl_egl_backend)
+xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen)
 {
     if (!xwl_glamor_has_wl_drm(xwl_screen) &&
         xwl_screen->dmabuf_protocol_version < 4) {
@@ -273,7 +272,7 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
 Bool
 xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen)
 {
-    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
+    if (!xwl_screen->glamor)
         return FALSE;
 
     return TRUE;
@@ -298,8 +297,7 @@ static Bool
 xwl_glamor_select_gbm_backend(struct xwl_screen *xwl_screen)
 {
 #ifdef GLAMOR_HAS_GBM
-    if (xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->gbm_backend)) {
-        xwl_screen->egl_backend = &xwl_screen->gbm_backend;
+    if (xwl_glamor_has_wl_interfaces(xwl_screen)) {
         LogMessageVerb(X_INFO, 3, "glamor: Using GBM backend\n");
         return TRUE;
     }
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index e62923643..2ffc5f9a9 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -995,7 +995,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     if (xwl_screen->glamor) {
         xwl_glamor_select_backend(xwl_screen);
 
-        if (xwl_screen->egl_backend == NULL || !xwl_glamor_init(xwl_screen)) {
+        if (!xwl_glamor_init(xwl_screen)) {
            ErrorF("Failed to initialize glamor, falling back to sw\n");
            xwl_screen->glamor = XWL_GLAMOR_NONE;
         }
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index ad627585b..2f0922a21 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -127,10 +127,6 @@ struct xwl_screen {
     struct xwl_format *formats;
     void *egl_display, *egl_context;
 
-    struct xwl_egl_backend gbm_backend;
-    /* pointer to the current backend for creating pixmaps on wayland */
-    struct xwl_egl_backend *egl_backend;
-
     struct glamor_context *glamor_ctx;
 
     Atom allow_commits_prop;
commit 863ee2da4d846b4856577c64b800890e3f955378
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 14:53:01 2024 +0100

    xwayland/glamor: Make xwl_glamor_has_wl_interfaces() private
    
    It's not used outside of Xwayland GLAMOR code itself, no need to keep it
    public.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 95e65af64..23dc429c8 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -113,7 +113,7 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
         xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
 }
 
-Bool
+static Bool
 xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
                             struct xwl_egl_backend *xwl_egl_backend)
 {
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index cf6e332eb..d9a168447 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -130,8 +130,6 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  struct wl_registry *registry,
                                  uint32_t id, const char *interface,
                                  uint32_t version);
-Bool xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
-                                 struct xwl_egl_backend *xwl_egl_backend);
 void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen);
commit 4eb8684f5248e461be05f379afd7e59a2db9c4bd
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 14:48:34 2024 +0100

    xwayland/glamor: Drop the allow_commit() hook
    
    That was used only by the EGLStream backend, we can remove it.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index dca556734..95e65af64 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -126,17 +126,6 @@ xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
     return TRUE;
 }
 
-Bool
-xwl_glamor_allow_commits(struct xwl_window *xwl_window)
-{
-    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-
-    if (xwl_screen->egl_backend->allow_commits)
-        return xwl_screen->egl_backend->allow_commits(xwl_window);
-    else
-        return TRUE;
-}
-
 static void
 xwl_avoid_implicit_redirect(WindowPtr window)
 {
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 70d3a8416..cf6e332eb 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -132,7 +132,6 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  uint32_t version);
 Bool xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
                                  struct xwl_egl_backend *xwl_egl_backend);
-Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
 void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen);
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index 9dcc5d937..e62923643 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -407,11 +407,6 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
         if (!xwl_window->allow_commits)
             continue;
 
-#ifdef XWL_HAS_GLAMOR
-        if (xwl_screen->glamor && !xwl_glamor_allow_commits(xwl_window))
-            continue;
-#endif
-
         xwl_window_post_damage(xwl_window);
         xorg_list_del(&xwl_window->link_damage);
         xorg_list_append(&xwl_window->link_damage, &commit_window_list);
commit 6fd77acd91f342b8441b3c21abb7d85739ebf2f0
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 14:45:46 2024 +0100

    xwayland/glamor: Drop the post_damage() hook
    
    That was used only with the EGLStream backend, we can remove it.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 69d0e0a4d..dca556734 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -126,19 +126,6 @@ xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
     return TRUE;
 }
 
-Bool
-xwl_glamor_post_damage(struct xwl_window *xwl_window,
-                       PixmapPtr pixmap)
-{
-    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-    RegionPtr region = xwl_window_get_damage_region(xwl_window);
-
-    if (xwl_screen->egl_backend->post_damage)
-        return xwl_screen->egl_backend->post_damage(xwl_window, pixmap, region);
-
-    return TRUE;
-}
-
 Bool
 xwl_glamor_allow_commits(struct xwl_window *xwl_window)
 {
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 9f7b19c35..70d3a8416 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -132,8 +132,6 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                  uint32_t version);
 Bool xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
                                  struct xwl_egl_backend *xwl_egl_backend);
-Bool xwl_glamor_post_damage(struct xwl_window *xwl_window,
-                            PixmapPtr pixmap);
 Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
 void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index fda98fa18..43293cadf 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -1357,15 +1357,6 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window)
         return FALSE;
     }
 
-#ifdef XWL_HAS_GLAMOR
-    if (xwl_screen->glamor) {
-        if (!xwl_glamor_post_damage(xwl_window, pixmap)) {
-            ErrorF("glamor: Failed to post damage\n");
-            return FALSE;
-        }
-    }
-#endif
-
     wl_surface_attach(xwl_window->surface, buffer, 0, 0);
 
     /* Arbitrary limit to try to avoid flooding the Wayland
commit 5fd0c92b0e9d1770bb647aebe8b0b35b08e2f4c4
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 14:38:21 2024 +0100

    xwayland/glamor: Remove the flag "is_available"
    
    Now that we have only one GBM backend, either it is available and
    usable, or we cannot use GLAMOR.
    
    Therefore we can drop the flag "is_available".
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c
index e5432217b..7133922dc 100644
--- a/hw/xwayland/xwayland-dmabuf.c
+++ b/hw/xwayland/xwayland-dmabuf.c
@@ -172,14 +172,7 @@ wl_drm_format_for_depth(int depth)
 static drmDevice *
 xwl_screen_get_main_dev(struct xwl_screen *xwl_screen)
 {
-    /*
-     * If we have gbm then get our main device from it. Otherwise use what
-     * the compositor told us.
-     */
-    if (xwl_screen->gbm_backend.is_available)
-        return xwl_gbm_get_main_device(xwl_screen);
-    else
-        return xwl_screen->default_feedback.main_dev;
+    return xwl_gbm_get_main_device(xwl_screen);
 }
 
 static Bool
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 5020551d3..69d0e0a4d 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -313,8 +313,7 @@ void
 xwl_glamor_init_backends(struct xwl_screen *xwl_screen)
 {
 #ifdef GLAMOR_HAS_GBM
-    xwl_glamor_init_gbm(xwl_screen);
-    if (!xwl_screen->gbm_backend.is_available)
+    if (!xwl_glamor_init_gbm(xwl_screen))
         ErrorF("Xwayland glamor: GBM backend is not available\n");
 #endif
 }
@@ -323,8 +322,7 @@ static Bool
 xwl_glamor_select_gbm_backend(struct xwl_screen *xwl_screen)
 {
 #ifdef GLAMOR_HAS_GBM
-    if (xwl_screen->gbm_backend.is_available &&
-        xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->gbm_backend)) {
+    if (xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->gbm_backend)) {
         xwl_screen->egl_backend = &xwl_screen->gbm_backend;
         LogMessageVerb(X_INFO, 3, "glamor: Using GBM backend\n");
         return TRUE;
commit 5df6a1e969dd29e3d7e4d5138225d22ac282a85e
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 14:14:55 2024 +0100

    xwayland/glamor: Make xwl_glamor_init_gbm() return its status
    
    This is a preliminary step to remove the backend's field "is_available".
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index a62412b7b..92cb15c18 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1283,27 +1283,25 @@ drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen)
     return xwl_gbm->device;
 }
 
-void
+Bool
 xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
 {
     struct xwl_gbm_private *xwl_gbm;
 
-    xwl_screen->gbm_backend.is_available = FALSE;
-
     if (!xwl_glamor_gbm_has_egl_extension())
-        return;
+        return FALSE;
 
     if (!dixRegisterPrivateKey(&xwl_gbm_private_key, PRIVATE_SCREEN, 0))
-        return;
+        return FALSE;
 
     xwl_gbm = calloc(sizeof(*xwl_gbm), 1);
     if (!xwl_gbm) {
         ErrorF("glamor: Not enough memory to setup GBM, disabling\n");
-        return;
+        return FALSE;
     }
 
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.is_available = TRUE;
+    return TRUE;
 }
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
index 34fcb3541..9083f2578 100644
--- a/hw/xwayland/xwayland-glamor-gbm.h
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -36,7 +36,7 @@
 
 #include "xwayland-types.h"
 
-void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen);
commit 63e2f98f0ab810095ee2d48843d08bd7772f1711
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:54:51 2024 +0100

    xwayland/glamor: Drop the backend_flags
    
    We do not need these anymore, since we only have the GBM backend left.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index e3c5bb581..a62412b7b 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1306,6 +1306,4 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
                   xwl_gbm);
 
     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;
 }
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 16f862896..5020551d3 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -300,19 +300,13 @@ xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen)
     if (!xwl_screen->glamor || !xwl_screen->egl_backend)
         return FALSE;
 
-    return (xwl_screen->egl_backend->backend_flags &
-                XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH);
+    return TRUE;
 }
 
 Bool
 xwl_glamor_needs_n_buffering(struct xwl_screen *xwl_screen)
 {
-    /* wl_shm benefits from n-buffering */
-    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
-        return TRUE;
-
-    return (xwl_screen->egl_backend->backend_flags &
-                XWL_EGL_BACKEND_NEEDS_N_BUFFERING);
+    return TRUE;
 }
 
 void
commit 925a218b4bfa70446a861ff22a39609e9334acd5
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:45:44 2024 +0100

    xwayland/glamor: Drop the create_pixmap_for_window() hook
    
    And rename the function xwl_glamor_gbm_create_pixmap_for_window() as
    xwl_glamor_create_pixmap_for_window().
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 37499d3f0..e3c5bb581 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -402,13 +402,17 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen,
                                                  width, height, depth, hint, FALSE);
 }
 
-static PixmapPtr
-xwl_glamor_gbm_create_pixmap_for_window(struct xwl_window *xwl_window)
+PixmapPtr
+xwl_glamor_create_pixmap_for_window(struct xwl_window *xwl_window)
 {
+    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
     WindowPtr window = xwl_window->window;
     unsigned border_width = 2 * window->borderWidth;
 
-    return xwl_glamor_gbm_create_pixmap_internal(xwl_window->xwl_screen,
+    if (!xwl_screen->glamor || !xwl_screen->egl_backend)
+        return NullPixmap;
+
+    return xwl_glamor_gbm_create_pixmap_internal(xwl_screen,
                                                  &window->drawable,
                                                  window->drawable.width + border_width,
                                                  window->drawable.height + border_width,
@@ -1304,5 +1308,4 @@ 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;
 }
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index a4ddaf9bd..16f862896 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -315,20 +315,6 @@ 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)
 {
commit 439c0ee5e4656296b79c8bb225ef0476c995c2c2
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:36:41 2024 +0100

    xwayland/glamor: Drop the get_main_device() hook
    
    Call xwl_gbm_get_main_device() directly from xwl_screen_get_main_dev().
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-dmabuf.c b/hw/xwayland/xwayland-dmabuf.c
index 7617a0e5f..e5432217b 100644
--- a/hw/xwayland/xwayland-dmabuf.c
+++ b/hw/xwayland/xwayland-dmabuf.c
@@ -31,6 +31,7 @@
 #include <wayland-util.h>
 
 #include "xwayland-dmabuf.h"
+#include "xwayland-glamor-gbm.h"
 #include "xwayland-screen.h"
 #include "xwayland-types.h"
 #include "xwayland-window-buffers.h"
@@ -176,7 +177,7 @@ xwl_screen_get_main_dev(struct xwl_screen *xwl_screen)
      * the compositor told us.
      */
     if (xwl_screen->gbm_backend.is_available)
-        return xwl_screen->gbm_backend.get_main_device(xwl_screen);
+        return xwl_gbm_get_main_device(xwl_screen);
     else
         return xwl_screen->default_feedback.main_dev;
 }
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index bab5b39a6..37499d3f0 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1272,7 +1272,7 @@ error:
     return FALSE;
 }
 
-static drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen)
+drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen)
 {
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
 
@@ -1301,7 +1301,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.get_main_device = xwl_gbm_get_main_device;
     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;
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
index a13d89c11..34fcb3541 100644
--- a/hw/xwayland/xwayland-glamor-gbm.h
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -32,11 +32,14 @@
 
 #include <sys/types.h>
 
+#include <xf86drm.h>
+
 #include "xwayland-types.h"
 
 void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen);
+drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen);
 
 #endif /* XWAYLAND_GLAMOR_GBM_H */
commit e8d974a8d36e0a6f2ff99619c7e76cadfb0ba626
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:24:19 2024 +0100

    xwayland/glamor: Drop the check_flip() hook
    
    The GBM backend never had a use for it.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index c07926ce5..bab5b39a6 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1301,7 +1301,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.check_flip = NULL;
     xwl_screen->gbm_backend.get_main_device = xwl_gbm_get_main_device;
     xwl_screen->gbm_backend.is_available = TRUE;
     xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH |
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index dc4f93993..a4ddaf9bd 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -93,15 +93,11 @@ Bool
 xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap)
 {
     ScreenPtr screen = pixmap->drawable.pScreen;
-    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
     PixmapPtr backing_pixmap = screen->GetWindowPixmap(present_window);
 
     if (pixmap->drawable.depth != backing_pixmap->drawable.depth)
         return FALSE;
 
-    if (xwl_screen->egl_backend->check_flip)
-        return xwl_screen->egl_backend->check_flip(pixmap);
-
     return TRUE;
 }
 
commit 76ae669327039a93f0728392d2f07a4c17f5e410
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:21:57 2024 +0100

    xwayland/glamor: Drop the get_wl_buffer_for_pixmap() hook
    
    And rename the GLAMOR GBM xwl_glamor_gbm_get_wl_buffer_for_pixmap()
    function as xwl_glamor_pixmap_get_wl_buffer().
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 69c8ff97a..c07926ce5 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -511,8 +511,8 @@ init_buffer_params_fallback(struct xwl_pixmap *xwl_pixmap,
     return TRUE;
 }
 
-static struct wl_buffer *
-xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
+struct wl_buffer *
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
 {
     struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
     struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
@@ -1301,7 +1301,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
     xwl_screen->gbm_backend.check_flip = NULL;
     xwl_screen->gbm_backend.get_main_device = xwl_gbm_get_main_device;
     xwl_screen->gbm_backend.is_available = TRUE;
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index c77a0c7f8..dc4f93993 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -130,17 +130,6 @@ xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
     return TRUE;
 }
 
-struct wl_buffer *
-xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
-{
-    struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
-
-    if (xwl_screen->egl_backend->get_wl_buffer_for_pixmap)
-        return xwl_screen->egl_backend->get_wl_buffer_for_pixmap(pixmap);
-
-    return NULL;
-}
-
 Bool
 xwl_glamor_post_damage(struct xwl_window *xwl_window,
                        PixmapPtr pixmap)
commit e60e00ff40a3d7fc76a8c523ce5da143c72cc27d
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:18:53 2024 +0100

    xwayland/glamor: Drop the init_screen() hook
    
    And call xwl_glamor_gbm_init_screen() directly instead.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index d99172241..69c8ff97a 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1237,7 +1237,7 @@ error:
     return FALSE;
 }
 
-static Bool
+Bool
 xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen)
 {
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
@@ -1301,7 +1301,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
     xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
     xwl_screen->gbm_backend.check_flip = NULL;
     xwl_screen->gbm_backend.get_main_device = xwl_gbm_get_main_device;
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
index 6371f2de8..a13d89c11 100644
--- a/hw/xwayland/xwayland-glamor-gbm.h
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -37,5 +37,6 @@
 void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen);
 
 #endif /* XWAYLAND_GLAMOR_GBM_H */
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 7461dd1ce..c77a0c7f8 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -400,7 +400,7 @@ xwl_glamor_init(struct xwl_screen *xwl_screen)
         return FALSE;
     }
 
-    if (!xwl_screen->egl_backend->init_screen(xwl_screen)) {
+    if (!xwl_glamor_gbm_init_screen(xwl_screen)) {
         ErrorF("EGL backend init_screen() failed, disabling glamor\n");
         return FALSE;
     }
commit e1bec429bbe134c00d47a2d00cb23ac0c98fe323
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:14:02 2024 +0100

    xwayland/glamor: Drop the init_egl() hook.
    
    And call xwl_glamor_gbm_init_egl() directly instead.
    
    Yet, keep the function separate rather than merging it back into
    xwl_glamor_init() for clarity of the code.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index dab51e1d9..d99172241 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1154,7 +1154,7 @@ xwl_glamor_gbm_init_main_dev(struct xwl_screen *xwl_screen)
     return TRUE;
 }
 
-static Bool
+Bool
 xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
 {
     struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
@@ -1301,7 +1301,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.init_egl = xwl_glamor_gbm_init_egl;
     xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
     xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
     xwl_screen->gbm_backend.check_flip = NULL;
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
index 125d8a1b5..6371f2de8 100644
--- a/hw/xwayland/xwayland-glamor-gbm.h
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -36,5 +36,6 @@
 
 void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen);
 
 #endif /* XWAYLAND_GLAMOR_GBM_H */
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index d518bfb90..7461dd1ce 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -390,7 +390,7 @@ xwl_glamor_init(struct xwl_screen *xwl_screen)
         return FALSE;
     }
 
-    if (!xwl_screen->egl_backend->init_egl(xwl_screen)) {
+    if (!xwl_glamor_gbm_init_egl(xwl_screen)) {
         ErrorF("EGL setup failed, disabling glamor\n");
         return FALSE;
     }
commit ca73cd8a9d4fba648601f78027b0099548c796de
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:09:55 2024 +0100

    xwayland/glamor: Drop xwl_glamor_gbm_has_wl_interfaces()
    
    And merge it back into xwl_glamor_has_wl_interfaces()
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 7028f9508..dab51e1d9 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -47,6 +47,7 @@
 #include "drm-client-protocol.h"
 
 #include "xwayland-glamor.h"
+#include "xwayland-glamor-gbm.h"
 #include "xwayland-pixmap.h"
 #include "xwayland-screen.h"
 
@@ -85,6 +86,14 @@ xwl_gbm_get(struct xwl_screen *xwl_screen)
                             &xwl_gbm_private_key);
 }
 
+Bool
+xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen)
+{
+    struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
+
+    return !!(xwl_gbm->drm != NULL);
+}
+
 /* There is a workaround for Mesa behaviour, which will cause black windows
  * when RGBX formats is using. Why exactly? There is an explanation:
  * 1. We create GL_RGBA texture with GL_UNSIGNED_BYTE type, all allowed by ES.
@@ -1007,19 +1016,6 @@ xwl_glamor_gbm_has_egl_extension(void)
             epoxy_has_egl_extension(NULL, "EGL_KHR_platform_gbm"));
 }
 
-static Bool
-xwl_glamor_gbm_has_wl_interfaces(struct xwl_screen *xwl_screen)
-{
-    struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
-
-    if (xwl_gbm->drm == NULL && xwl_screen->dmabuf_protocol_version < 4) {
-        LogMessageVerb(X_INFO, 3, "glamor: 'wl_drm' not supported and linux-dmabuf v4 not supported\n");
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
 static Bool
 xwl_glamor_try_to_make_context_current(struct xwl_screen *xwl_screen)
 {
@@ -1305,7 +1301,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.has_wl_interfaces = xwl_glamor_gbm_has_wl_interfaces;
     xwl_screen->gbm_backend.init_egl = xwl_glamor_gbm_init_egl;
     xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
     xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
index 411b11aec..125d8a1b5 100644
--- a/hw/xwayland/xwayland-glamor-gbm.h
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -35,5 +35,6 @@
 #include "xwayland-types.h"
 
 void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
+Bool xwl_glamor_has_wl_drm(struct xwl_screen *xwl_screen);
 
 #endif /* XWAYLAND_GLAMOR_GBM_H */
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 42a5ea820..d518bfb90 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -121,7 +121,13 @@ Bool
 xwl_glamor_has_wl_interfaces(struct xwl_screen *xwl_screen,
                             struct xwl_egl_backend *xwl_egl_backend)
 {
-    return xwl_egl_backend->has_wl_interfaces(xwl_screen);
+    if (!xwl_glamor_has_wl_drm(xwl_screen) &&
+        xwl_screen->dmabuf_protocol_version < 4) {
+        LogMessageVerb(X_INFO, 3, "glamor: 'wl_drm' not supported and linux-dmabuf v4 not supported\n");
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 struct wl_buffer *
commit 2ccabf5aa8b110b8de52fcc74a89e4dcbc91f7fe
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 11:02:50 2024 +0100

    xwayland/glamor: Drop xwl_glamor_gbm_init_wl_registry()
    
    And merge it back into xwl_glamor_init_wl_registry().
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 975733235..7028f9508 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1000,24 +1000,6 @@ xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
     return TRUE;
 }
 
-static Bool
-xwl_glamor_gbm_init_wl_registry(struct xwl_screen *xwl_screen,
-                                struct wl_registry *wl_registry,
-                                uint32_t id, const char *name,
-                                uint32_t version)
-{
-    if (strcmp(name, wl_drm_interface.name) == 0) {
-        xwl_screen_set_drm_interface(xwl_screen, id, version);
-        return TRUE;
-    } else if (strcmp(name, zwp_linux_dmabuf_v1_interface.name) == 0) {
-        xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
-        return TRUE;
-    }
-
-    /* no match */
-    return FALSE;
-}
-
 static Bool
 xwl_glamor_gbm_has_egl_extension(void)
 {
@@ -1323,7 +1305,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
     dixSetPrivate(&xwl_screen->screen->devPrivates, &xwl_gbm_private_key,
                   xwl_gbm);
 
-    xwl_screen->gbm_backend.init_wl_registry = xwl_glamor_gbm_init_wl_registry;
     xwl_screen->gbm_backend.has_wl_interfaces = xwl_glamor_gbm_has_wl_interfaces;
     xwl_screen->gbm_backend.init_egl = xwl_glamor_gbm_init_egl;
     xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 086af6a82..42a5ea820 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -39,6 +39,7 @@
 #include "glx_extinit.h"
 #endif
 
+#include "drm-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
 
 #include "xwayland-dmabuf.h"
@@ -110,14 +111,10 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                             uint32_t id, const char *interface,
                             uint32_t version)
 {
-    if (xwl_screen->gbm_backend.is_available &&
-        xwl_screen->gbm_backend.init_wl_registry(xwl_screen,
-                                                 registry,
-                                                 id,
-                                                 interface,
-                                                 version)) {
-        /* no-op */
-    }
+    if (strcmp(interface, wl_drm_interface.name) == 0)
+        xwl_screen_set_drm_interface(xwl_screen, id, version);
+    else if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0)
+        xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
 }
 
 Bool
commit 673ed3cd6daca4717e3a6498bc7643ecb7a1571f
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Mar 13 13:57:42 2024 +0100

    xwayland/glamor: Add a GLAMOR GBM header
    
    That will be used between the generic Xwayland GLAMOR functions and the
    GBM implementation.
    
    Move the definition of xwl_glamor_init_gbm() to that new header rather
    than in the generic Xwayland GLAMOR header.
    
    This is preparation work to eventually replace the xwl_egl_backend now
    that we have only one backend left.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index b61d4c0ee..4d878dae8 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -107,7 +107,8 @@ if build_xwayland_glamor
               'xwayland-glamor.c',
               'xwayland-dmabuf.h',
               'xwayland-dmabuf.c',
-              'xwayland-glamor-gbm.c'
+              'xwayland-glamor-gbm.c',
+              'xwayland-glamor-gbm.h'
             ]
 
     if build_xv
diff --git a/hw/xwayland/xwayland-glamor-gbm.h b/hw/xwayland/xwayland-glamor-gbm.h
new file mode 100644
index 000000000..411b11aec
--- /dev/null
+++ b/hw/xwayland/xwayland-glamor-gbm.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2011-2014 Intel Corporation
+ * Copyright © 2024 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including
+ * the next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef XWAYLAND_GLAMOR_GBM_H
+#define XWAYLAND_GLAMOR_GBM_H
+
+#include <xwayland-config.h>
+
+#include <sys/types.h>
+
+#include "xwayland-types.h"
+
+void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
+
+#endif /* XWAYLAND_GLAMOR_GBM_H */
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index b35aa25c2..086af6a82 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -43,6 +43,7 @@
 
 #include "xwayland-dmabuf.h"
 #include "xwayland-glamor.h"
+#include "xwayland-glamor-gbm.h"
 #include "xwayland-screen.h"
 #include "xwayland-window.h"
 #include "xwayland-window-buffers.h"
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 8e640277e..9f7b19c35 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -34,6 +34,7 @@
 #include <xf86drm.h>
 
 #include "xwayland-types.h"
+#include "xwayland-glamor-gbm.h"
 
 typedef enum _xwl_egl_backend_flags {
     XWL_EGL_BACKEND_NO_FLAG = 0,
@@ -145,8 +146,6 @@ PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
 Bool xwl_glamor_xv_init(ScreenPtr pScreen);
 #endif /* XV */
 
-void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
-
 #endif /* XWL_HAS_GLAMOR */
 
 #endif /* XWAYLAND_GLAMOR_H */
commit 701284f057b41bba0b0cc4b3f851958af95ac978
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue Mar 12 08:52:04 2024 +0100

    xwayland/glamor: Drop the EGLStream backend
    
    Now that the NVIDIA proprietary driver has grown support for GBM, the
    EGLStream backend for NVIDIA GPUs is now superseded by the standard
    GBM backend in Xwayland.
    
    This code path is therefore not used and hardly ever tested.
    
    Remove support for EGLStream in Xwayland.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>

diff --git a/hw/xwayland/man/Xwayland.man b/hw/xwayland/man/Xwayland.man
index f26b94035..46fd6c2d9 100644
--- a/hw/xwayland/man/Xwayland.man
+++ b/hw/xwayland/man/Xwayland.man
@@ -54,13 +54,6 @@ support (optional).
 
 This option is not compatible with rootless mode (\fI-rootless\fP).
 .TP 8
-.B \-eglstream
-Use EGLStream backend for NVidia GPUs. If \fIXwayland\fP was compiled with
-EGLStream support, this option will instruct \fIXwayland\fP to try that
-backend first, then fallback to the GBM backend if EGLStream is not supported
-by the Wayland server. Without this option, \fIXwayland\fP tries the GBM
-backend first, and fallback to EGLStream if GBM is not usable.
-.TP 8
 .B \-enable-ei-portal
 Enable support for the XDG portal for input emulation.
 
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index 10a884e8b..b61d4c0ee 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -102,30 +102,14 @@ if build_ei
 endif
 
 xwayland_glamor = []
-eglstream_srcs = []
 if build_xwayland_glamor
     srcs += [
               'xwayland-glamor.c',
               'xwayland-dmabuf.h',
-              'xwayland-dmabuf.c'
+              'xwayland-dmabuf.c',
+              'xwayland-glamor-gbm.c'
             ]
-    if gbm_dep.found()
-        srcs += [
-                  'xwayland-glamor-gbm.c',
-                ]
-    endif
-    if build_eglstream
-        eglstream_protodir = eglstream_dep.get_variable(pkgconfig : 'pkgdatadir')
-        eglstream_xml = join_paths(eglstream_protodir, 'wayland-eglstream.xml')
-        eglstream_controller_xml = join_paths(eglstream_protodir, 'wayland-eglstream-controller.xml')
-
-        srcs += client_header.process(eglstream_xml)
-        srcs += client_header.process(eglstream_controller_xml)
-        srcs += code.process(eglstream_xml)
-        srcs += code.process(eglstream_controller_xml)
 
-        srcs += 'xwayland-glamor-eglstream.c'
-    endif
     if build_xv
         srcs += 'xwayland-glamor-xv.c'
     endif
@@ -176,7 +160,7 @@ xwayland_server = executable(
 xwayland_vars = [
     'have_glamor=' + build_glamor.to_string(),
     'have_glamor_api=' + build_glamor.to_string(),
-    'have_eglstream=' + build_eglstream.to_string(),
+    'have_eglstream=false',
     'have_initfd=true',
     'have_listenfd=true',
     'have_verbose=true',
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
deleted file mode 100644
index 95894f403..000000000
--- a/hw/xwayland/xwayland-glamor-eglstream.c
+++ /dev/null
@@ -1,1129 +0,0 @@
-/*
- * Copyright © 2017 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Lyude Paul <lyude at redhat.com>
- *
- */
-
-#include <xwayland-config.h>
-
-#define MESA_EGL_NO_X11_HEADERS
-#define EGL_NO_X11
-#include <glamor_egl.h>
-#include <glamor.h>
-#include <glamor_priv.h>
-#include <glamor_transform.h>
-#include <glamor_transfer.h>
-
-#include <xf86drm.h>
-#include <dri3.h>
-#include <drm_fourcc.h>
-
-#include <epoxy/egl.h>
-
-#include "xwayland-glamor.h"
-#include "xwayland-pixmap.h"
-#include "xwayland-screen.h"
-#include "xwayland-window.h"
-
-#include "wayland-eglstream-client-protocol.h"
-#include "wayland-eglstream-controller-client-protocol.h"
-#include "linux-dmabuf-unstable-v1-client-protocol.h"
-
-struct xwl_eglstream_private {
-    EGLDeviceEXT egl_device;
-    struct wl_eglstream_display *display;
-    struct wl_eglstream_controller *controller;
-    uint32_t display_caps;
-
-    EGLConfig config;
-
-    Bool have_egl_damage;
-    Bool have_egl_stream_flush;
-
-    GLint blit_prog;
-    GLuint blit_vao;
-    GLuint blit_vbo;
-    GLuint blit_is_rgba_pos;
-};
-
-enum xwl_pixmap_type {
-    XWL_PIXMAP_EGLSTREAM, /* Pixmaps created by glamor. */
-    XWL_PIXMAP_DMA_BUF, /* Pixmaps allocated through DRI3. */
-};
-
-struct xwl_pixmap {
-    enum xwl_pixmap_type type;
-    /* add any new <= 4-byte member here to avoid holes on 64-bit */
-    struct xwl_screen *xwl_screen;
-    struct wl_buffer *buffer;
-    struct wl_callback *pending_cb;
-    Bool wait_for_buffer_release;
-
-    /* XWL_PIXMAP_EGLSTREAM. */
-    EGLStreamKHR stream;
-    EGLSurface surface;
-
-    /* XWL_PIXMAP_DMA_BUF. */
-    EGLImage image;
-};
-
-static DevPrivateKeyRec xwl_eglstream_private_key;
-
-static inline struct xwl_eglstream_private *
-xwl_eglstream_get(struct xwl_screen *xwl_screen)
-{
-    return dixLookupPrivate(&xwl_screen->screen->devPrivates,
-                            &xwl_eglstream_private_key);
-}
-
-static GLuint
-xwl_eglstream_build_glsl_prog(GLuint vs, GLuint fs)
-{
-    GLint ok;
-    GLuint prog;
-
-    prog = glCreateProgram();
-    glAttachShader(prog, vs);
-    glAttachShader(prog, fs);
-
-    glLinkProgram(prog);
-    glGetProgramiv(prog, GL_LINK_STATUS, &ok);
-    if (!ok) {
-        GLchar *info;
-        GLint size;
-
-        glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
-        info = malloc(size);
-
-        glGetProgramInfoLog(prog, size, NULL, info);
-        ErrorF("Failed to link: %s\n", info);
-        FatalError("GLSL link failure\n");
-    }
-
-    return prog;
-}
-
-static void
-xwl_eglstream_cleanup(struct xwl_screen *xwl_screen)
-{
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-
-    if (xwl_eglstream->display)
-        wl_eglstream_display_destroy(xwl_eglstream->display);
-    if (xwl_eglstream->controller)
-        wl_eglstream_controller_destroy(xwl_eglstream->controller);
-    if (xwl_eglstream->blit_prog) {
-        glDeleteProgram(xwl_eglstream->blit_prog);
-        glDeleteBuffers(1, &xwl_eglstream->blit_vbo);
-    }
-
-    free(xwl_eglstream);
-}
-
-static Bool
-xwl_glamor_egl_supports_device_probing(void)
-{
-    return epoxy_has_egl_extension(NULL, "EGL_EXT_device_base");
-}
-
-static void **
-xwl_glamor_egl_get_devices(int *num_devices)
-{
-    EGLDeviceEXT *devices, *tmp;
-    Bool ret;
-    int drm_dev_count = 0;
-    int i;
-
-    if (!xwl_glamor_egl_supports_device_probing())
-        return NULL;
-
-    /* Get the number of devices */
-    ret = eglQueryDevicesEXT(0, NULL, num_devices);
-    if (!ret || *num_devices < 1)
-        return NULL;
-
-    devices = calloc(*num_devices, sizeof(EGLDeviceEXT));
-    if (!devices)
-        return NULL;
-
-    ret = eglQueryDevicesEXT(*num_devices, devices, num_devices);
-    if (!ret)
-        goto error;
-
-    /* We're only ever going to care about devices that support
-     * EGL_EXT_device_drm, so filter out the ones that don't
-     */
-    for (i = 0; i < *num_devices; i++) {
-        const char *extension_str =
-            eglQueryDeviceStringEXT(devices[i], EGL_EXTENSIONS);
-
-        if (!epoxy_extension_in_string(extension_str, "EGL_EXT_device_drm"))
-            continue;
-
-        devices[drm_dev_count++] = devices[i];
-    }
-    if (!drm_dev_count)
-        goto error;
-
-    *num_devices = drm_dev_count;
-    tmp = realloc(devices, sizeof(EGLDeviceEXT) * drm_dev_count);
-    if (!tmp)
-        goto error;
-
-    devices = tmp;
-
-    return devices;
-
-error:
-    free(devices);
-
-    return NULL;
-}
-
-static Bool
-xwl_glamor_egl_device_has_egl_extensions(void *device,
-                                         const char **ext_list, size_t size)
-{
-    EGLDisplay egl_display;
-    int i;
-    Bool has_exts = TRUE;
-
-    egl_display = glamor_egl_get_display(EGL_PLATFORM_DEVICE_EXT, device);
-    if (!egl_display || !eglInitialize(egl_display, NULL, NULL))
-        return FALSE;
-
-    for (i = 0; i < size; i++) {
-        if (!epoxy_has_egl_extension(egl_display, ext_list[i])) {
-            has_exts = FALSE;
-            break;
-        }
-    }
-
-    eglTerminate(egl_display);
-    return has_exts;
-}
-
-static void
-xwl_eglstream_destroy_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
-{
-    struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
-
-    /* If we're using this stream in the current egl context, unbind it so the
-     * driver doesn't keep it around until the next eglMakeCurrent()
-     * don't have to keep it around until something else changes the surface
-     */
-    xwl_glamor_egl_make_current(xwl_screen);
-    if (eglGetCurrentSurface(EGL_READ) == xwl_pixmap->surface ||
-        eglGetCurrentSurface(EGL_DRAW) == xwl_pixmap->surface) {
-        eglMakeCurrent(xwl_screen->egl_display,
-                       EGL_NO_SURFACE, EGL_NO_SURFACE,
-                       xwl_screen->egl_context);
-    }
-
-    if (xwl_pixmap->surface != EGL_NO_SURFACE)
-        eglDestroySurface(xwl_screen->egl_display, xwl_pixmap->surface);
-
-    if (xwl_pixmap->stream != EGL_NO_STREAM_KHR)
-        eglDestroyStreamKHR(xwl_screen->egl_display, xwl_pixmap->stream);
-
-    if (xwl_pixmap->buffer)
-        wl_buffer_destroy(xwl_pixmap->buffer);
-
-    if (xwl_pixmap->image != EGL_NO_IMAGE_KHR)
-        eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image);
-
-    free(xwl_pixmap);
-}
-
-static void
-xwl_eglstream_destroy_pending_cb(PixmapPtr pixmap)
-{
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
-    if (xwl_pixmap && xwl_pixmap->pending_cb) {
-        wl_callback_destroy(xwl_pixmap->pending_cb);
-        xwl_pixmap->pending_cb = NULL;
-    }
-}
-
-static Bool
-xwl_glamor_eglstream_destroy_pixmap(PixmapPtr pixmap)
-{
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
-    if (xwl_pixmap && pixmap->refcnt == 1) {
-        xwl_eglstream_destroy_pending_cb(pixmap);
-        xwl_eglstream_destroy_pixmap_stream(xwl_pixmap);
-        xwl_pixmap_del_buffer_release_cb(pixmap);
-    }
-    return glamor_destroy_pixmap(pixmap);
-}
-
-static struct wl_buffer *
-xwl_glamor_eglstream_get_wl_buffer_for_pixmap(PixmapPtr pixmap)
-{
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
-    if (!xwl_pixmap)
-        return NULL;
-
-    return xwl_pixmap->buffer;
-}
-
-static const char *
-xwl_eglstream_get_error_str(EGLint error)
-{
-    switch (error) {
-    case EGL_BAD_PARAMETER:
-        return "EGL_BAD_PARAMETER";
-    case EGL_BAD_ATTRIBUTE:
-        return "EGL_BAD_ATTRIBUTE";
-    case EGL_BAD_MATCH:
-        return "EGL_BAD_MATCH";
-    case EGL_BAD_ACCESS:
-        return "EGL_BAD_ACCESS";
-    case EGL_BAD_STATE_KHR:
-        return "EGL_BAD_STATE_KHR";
-    case EGL_BAD_STREAM_KHR:
-        return "EGL_BAD_STREAM_KHR";
-    case EGL_BAD_DISPLAY:
-        return "EGL_BAD_DISPLAY";
-    case EGL_NOT_INITIALIZED:
-        return "EGL_NOT_INITIALIZED";
-    default:
-        return "Unknown error";
-    }
-}
-
-static const char *
-xwl_eglstream_get_stream_state_str(EGLint state)
-{
-    switch (state) {
-    case EGL_STREAM_STATE_CREATED_KHR:
-        return "EGL_STREAM_STATE_CREATED_KHR";
-    case EGL_STREAM_STATE_CONNECTING_KHR:
-        return "EGL_STREAM_STATE_CONNECTING_KHR";
-    case EGL_STREAM_STATE_EMPTY_KHR:
-        return "EGL_STREAM_STATE_EMPTY_KHR";
-    case EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR:
-        return "EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR";
-    case EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR:
-        return "EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR";
-    case EGL_STREAM_STATE_DISCONNECTED_KHR:
-        return "EGL_STREAM_STATE_DISCONNECTED_KHR";
-    default:
-        return "Unknown state";
-    }
-}
-
-static EGLint
-xwl_eglstream_get_state(EGLDisplay egl_display, EGLStreamKHR egl_stream)
-{
-    EGLint state;
-
-    eglQueryStreamKHR(egl_display, egl_stream, EGL_STREAM_STATE_KHR, &state);
-    if (!eglQueryStreamKHR(egl_display, egl_stream,
-                           EGL_STREAM_STATE_KHR, &state)) {
-        EGLint state_error = eglGetError();
-        ErrorF("eglstream: Failed to query state - error 0x%X: %s\n",
-               state_error, xwl_eglstream_get_error_str(state_error));
-        return EGL_FALSE;
-    }
-
-    return state;
-}
-
-
-static void
-xwl_eglstream_print_error(EGLDisplay egl_display,
-                          EGLStreamKHR egl_stream, EGLint error)
-{
-    ErrorF("eglstream: error 0x%X: %s\n", error,
-           xwl_eglstream_get_error_str(error));
-
-    if (error == EGL_BAD_STATE_KHR) {
-        EGLint state = xwl_eglstream_get_state(egl_display, egl_stream);
-        ErrorF("eglstream: stream state 0x%X: %s\n", state,
-               xwl_eglstream_get_stream_state_str(state));
-    }
-}
-
-static void
-xwl_eglstream_consumer_ready_callback(void *data,
-                                      struct wl_callback *callback,
-                                      uint32_t time)
-{
-    PixmapPtr pixmap = data;
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-    struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-
-    xwl_eglstream_destroy_pending_cb(pixmap);
-
-    xwl_glamor_egl_make_current(xwl_screen);
-
-    xwl_pixmap->surface = eglCreateStreamProducerSurfaceKHR(
-        xwl_screen->egl_display, xwl_eglstream->config,
-        xwl_pixmap->stream, (int[]) {
-            EGL_WIDTH,  pixmap->drawable.width,
-            EGL_HEIGHT, pixmap->drawable.height,
-            EGL_NONE
-        });
-
-    if (xwl_pixmap->surface == EGL_NO_SURFACE) {
-        ErrorF("eglstream: Failed to create EGLSurface for pixmap\n");
-        xwl_eglstream_print_error(xwl_screen->egl_display,
-                                  xwl_pixmap->stream, eglGetError());
-    } else {
-        DebugF("eglstream: completes eglstream for pixmap %p, congrats!\n",
-               pixmap);
-    }
-}
-
-static const struct wl_callback_listener consumer_ready_listener = {
-    xwl_eglstream_consumer_ready_callback
-};
-
-static void
-xwl_eglstream_buffer_release_callback(void *data)
-{
-    PixmapPtr pixmap = data;
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
-    assert(xwl_pixmap);
-
-    if (xwl_pixmap->wait_for_buffer_release) {
-        xwl_pixmap->wait_for_buffer_release = FALSE;
-        /* drop the reference we took in the ready callback, freeing if necessary */
-        dixDestroyPixmap(pixmap, 0);
-    }
-}
-
-static const struct wl_buffer_listener xwl_eglstream_buffer_release_listener = {
-    xwl_pixmap_buffer_release_cb,
-};
-
-static void
-xwl_eglstream_create_pixmap_and_stream(struct xwl_screen *xwl_screen,
-                                       WindowPtr window, PixmapPtr pixmap)
-{
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-    struct xwl_pixmap *xwl_pixmap;
-    struct xwl_window *xwl_window = xwl_window_from_window(window);
-    struct wl_array stream_attribs;
-    int stream_fd = -1;
-
-    xwl_pixmap = calloc(1, sizeof(*xwl_pixmap));
-    if (!xwl_pixmap)
-        FatalError("Not enough memory to create pixmap\n");
-    xwl_pixmap_set_private(pixmap, xwl_pixmap);
-
-    xwl_pixmap->type = XWL_PIXMAP_EGLSTREAM;
-    xwl_pixmap->image = EGL_NO_IMAGE;
-
-    xwl_glamor_egl_make_current(xwl_screen);
-
-    xwl_pixmap->wait_for_buffer_release = FALSE;
-    xwl_pixmap->xwl_screen = xwl_screen;
-    xwl_pixmap->surface = EGL_NO_SURFACE;
-    xwl_pixmap->stream = eglCreateStreamKHR(xwl_screen->egl_display, NULL);
-    if (xwl_pixmap->stream == EGL_NO_STREAM_KHR) {
-        ErrorF("eglstream: Couldn't create EGL stream.\n");
-        goto fail;
-    }
-    stream_fd = eglGetStreamFileDescriptorKHR(xwl_screen->egl_display,
-                                              xwl_pixmap->stream);
-    if (stream_fd == EGL_NO_FILE_DESCRIPTOR_KHR) {
-        ErrorF("eglstream: Couldn't get EGL stream file descriptor.\n");
-        goto fail;
-    }
-
-    wl_array_init(&stream_attribs);
-    xwl_pixmap->buffer =
-        wl_eglstream_display_create_stream(xwl_eglstream->display,
-                                           pixmap->drawable.width,
-                                           pixmap->drawable.height,
-                                           stream_fd,
-                                           WL_EGLSTREAM_HANDLE_TYPE_FD,
-                                           &stream_attribs);
-    if (!xwl_pixmap->buffer) {
-        ErrorF("eglstream: Failed to create buffer\n");
-        goto fail;
-    }
-
-    wl_buffer_add_listener(xwl_pixmap->buffer,
-                           &xwl_eglstream_buffer_release_listener,
-                           pixmap);
-
-    xwl_pixmap_set_buffer_release_cb(pixmap,
-                                     xwl_eglstream_buffer_release_callback,
-                                     pixmap);
-
-    wl_eglstream_controller_attach_eglstream_consumer(
-        xwl_eglstream->controller, xwl_window->surface, xwl_pixmap->buffer);
-
-    xwl_pixmap->pending_cb = wl_display_sync(xwl_screen->display);
-    wl_callback_add_listener(xwl_pixmap->pending_cb, &consumer_ready_listener,
-                             pixmap);
-fail:
-    if (stream_fd >= 0)
-        close(stream_fd);
-}
-
-static Bool
-xwl_glamor_eglstream_allow_commits(struct xwl_window *xwl_window)
-{
-    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-    PixmapPtr pixmap =
-        (*xwl_screen->screen->GetWindowPixmap)(xwl_window->window);
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-
-    if (xwl_pixmap) {
-        if (xwl_pixmap->pending_cb) {
-            /* Wait for the compositor to finish connecting the consumer for
-             * this eglstream */
-            return FALSE;
-        }
-
-        if (xwl_pixmap->surface != EGL_NO_SURFACE ||
-            xwl_pixmap->type == XWL_PIXMAP_DMA_BUF) {
-            return TRUE;
-        }
-
-        /* The pending stream got removed, we have a xwl_pixmap and
-         * yet we do not have a surface.
-         * So something went wrong with the surface creation, retry.
-         */
-         xwl_eglstream_destroy_pixmap_stream(xwl_pixmap);
-    }
-
-    /* Glamor pixmap has no backing stream yet; begin making one and disallow
-     * commits until then
-     */
-    xwl_eglstream_create_pixmap_and_stream(xwl_screen, xwl_window->window,
-                                           pixmap);
-
-    return FALSE;
-}
-
-static Bool
-xwl_glamor_eglstream_post_damage(struct xwl_window *xwl_window,
-                                 PixmapPtr pixmap, RegionPtr region)
-{
-    struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
-    BoxPtr box = RegionExtents(region);
-    EGLint egl_damage[] = {
-        box->x1,           box->y1,
-        box->x2 - box->x1, box->y2 - box->y1
-    };
-    GLint saved_vao;
-    int status;
-
-    if (xwl_pixmap->type != XWL_PIXMAP_EGLSTREAM)
-        /* This can happen if a client does X11 rendering on a
-         * flipping OpenGL or Vulkan window. In that case, we don't
-         * need to do the copy below.
-         */
-        return TRUE;
-
-    /* Unbind the framebuffer BEFORE binding the EGLSurface, otherwise we
-     * won't actually draw to it
-     */
-    xwl_glamor_egl_make_current(xwl_screen);
-    glamor_set_alu(&pixmap->drawable, GXcopy);
-
-    glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
-    if (eglGetCurrentSurface(EGL_READ) != xwl_pixmap->surface ||
-        eglGetCurrentSurface(EGL_DRAW) != xwl_pixmap->surface)
-        eglMakeCurrent(xwl_screen->egl_display,
-                       xwl_pixmap->surface, xwl_pixmap->surface,
-                       xwl_screen->egl_context);
-
-    /* Save current GL state */
-    glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &saved_vao);
-
-    /* Setup our GL state */
-    glUseProgram(xwl_eglstream->blit_prog);
-    glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
-    glActiveTexture(GL_TEXTURE0);
-    glBindVertexArray(xwl_eglstream->blit_vao);
-    glBindTexture(GL_TEXTURE_2D, glamor_get_pixmap_texture(pixmap));
-
-    glUniform1i(xwl_eglstream->blit_is_rgba_pos,
-                pixmap->drawable.depth >= 32);
-
-    status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
-    if (status != GL_FRAMEBUFFER_COMPLETE) {
-        ErrorF("eglstream: Framebuffer incomplete 0x%X, not posting damage\n", status);
-        status = FALSE;
-        goto out;
-    }
-
-    /* Blit rendered image into EGLStream surface */
-    glDrawBuffer(GL_BACK);
-    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
-    if (xwl_eglstream->have_egl_damage)
-        status = eglSwapBuffersWithDamageKHR(xwl_screen->egl_display,
-                                             xwl_pixmap->surface,
-                                             egl_damage, 1);
-    else
-        status = eglSwapBuffers(xwl_screen->egl_display,
-                                xwl_pixmap->surface);
-
-    if (!status) {
-        ErrorF("eglstream: buffer swap failed, not posting damage\n");
-        goto out;
-    }
-
-#ifdef EGL_NV_stream_flush
-    if (xwl_eglstream->have_egl_stream_flush)
-        /* block until stream state is updated on the compositor's side */
-        eglStreamFlushNV(xwl_screen->egl_display,
-                         xwl_pixmap->stream);
-#endif
-
-    if (!xwl_pixmap->wait_for_buffer_release) {
-        /* hang onto the pixmap until the compositor has released it */
-        pixmap->refcnt++;
-        xwl_pixmap->wait_for_buffer_release = TRUE;
-    }
-
-out:
-    /* Restore previous state */
-    glBindVertexArray(saved_vao);
-    glBindTexture(GL_TEXTURE_2D, 0);
-
-    return status;
-}
-
-static Bool
-xwl_glamor_eglstream_check_flip(PixmapPtr pixmap)
-{
-    return xwl_pixmap_get(pixmap)->type == XWL_PIXMAP_DMA_BUF;
-}
-
-static void
-xwl_eglstream_display_handle_caps(void *data,
-                                  struct wl_eglstream_display *disp,
-                                  int32_t caps)
-{
-    xwl_eglstream_get(data)->display_caps = caps;
-}
-
-static void
-xwl_eglstream_display_handle_swapinterval_override(void *data,
-                                                   struct wl_eglstream_display *disp,
-                                                   int32_t swapinterval,
-                                                   struct wl_buffer *stream)
-{
-}
-
-const struct wl_eglstream_display_listener eglstream_display_listener = {
-    .caps = xwl_eglstream_display_handle_caps,
-    .swapinterval_override = xwl_eglstream_display_handle_swapinterval_override,
-};
-
-static Bool
-xwl_glamor_eglstream_init_wl_registry(struct xwl_screen *xwl_screen,
-                                      struct wl_registry *wl_registry,
-                                      uint32_t id, const char *name,
-                                      uint32_t version)
-{
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-
-    if (strcmp(name, wl_eglstream_display_interface.name) == 0) {
-        xwl_eglstream->display = wl_registry_bind(
-            wl_registry, id, &wl_eglstream_display_interface, version);
-
-        wl_eglstream_display_add_listener(xwl_eglstream->display,
-                                          &eglstream_display_listener,
-                                          xwl_screen);
-        return TRUE;
-    } else if (strcmp(name, wl_eglstream_controller_interface.name) == 0) {
-        xwl_eglstream->controller = wl_registry_bind(
-            wl_registry, id, &wl_eglstream_controller_interface, version);
-        return TRUE;
-    } else if (strcmp(name, zwp_linux_dmabuf_v1_interface.name) == 0) {
-        xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
-        return TRUE;
-    }
-
-    /* no match */
-    return FALSE;
-}
-
-static Bool
-xwl_glamor_eglstream_has_wl_interfaces(struct xwl_screen *xwl_screen)
-{
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-
-    if (xwl_eglstream->display == NULL) {
-        LogMessageVerb(X_INFO, 3,
-                       "glamor: 'wl_eglstream_display' not supported\n");
-        return FALSE;
-    }
-
-    if (xwl_eglstream->controller == NULL) {
-        LogMessageVerb(X_INFO, 3,
-                       "glamor: 'wl_eglstream_controller' not supported\n");
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-static inline void
-xwl_eglstream_init_shaders(struct xwl_screen *xwl_screen)
-{
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-    GLint fs, vs, attrib;
-    GLuint vbo;
-
-    const char *blit_vs_src =
-        "attribute vec2 texcoord;\n"
-        "attribute vec2 position;\n"
-        "varying vec2 t;\n"
-        "void main() {\n"
-        "    t = texcoord;\n"
-        "    gl_Position = vec4(position, 0, 1);\n"
-        "}";
-
-    const char *blit_fs_src =
-        "varying vec2 t;\n"
-        "uniform sampler2D s;\n"
-        "uniform bool is_rgba;\n"
-        "void main() {\n"
-        "    if (is_rgba)\n"
-        "        gl_FragColor = texture2D(s, t);\n"
-        "    else\n"
-        "        gl_FragColor = vec4(texture2D(s, t).rgb, 1.0);\n"
-        "}";
-
-    static const float position[] = {
-        /* position */
-        -1, -1,
-         1, -1,
-         1,  1,
-        -1,  1,
-        /* texcoord */
-         0,  1,
-         1,  1,
-         1,  0,
-         0,  0,
-    };
-
-    vs = glamor_compile_glsl_prog(GL_VERTEX_SHADER, blit_vs_src);
-    fs = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, blit_fs_src);
-
-    xwl_eglstream->blit_prog = xwl_eglstream_build_glsl_prog(vs, fs);
-    glDeleteShader(vs);
-    glDeleteShader(fs);
-
-    /* Create the blitter's vao */
-    glGenVertexArrays(1, &xwl_eglstream->blit_vao);
-    glBindVertexArray(xwl_eglstream->blit_vao);
-
-    /* Set the data for both position and texcoord in the vbo */
-    glGenBuffers(1, &vbo);
-    glBindBuffer(GL_ARRAY_BUFFER, vbo);
-    glBufferData(GL_ARRAY_BUFFER, sizeof(position), position, GL_STATIC_DRAW);
-    xwl_eglstream->blit_vbo = vbo;
-
-    /* Define each shader attribute's data location in our vbo */
-    attrib = glGetAttribLocation(xwl_eglstream->blit_prog, "position");
-    glVertexAttribPointer(attrib, 2, GL_FLOAT, TRUE, 0, NULL);
-    glEnableVertexAttribArray(attrib);
-
-    attrib = glGetAttribLocation(xwl_eglstream->blit_prog, "texcoord");
-    glVertexAttribPointer(attrib, 2, GL_FLOAT, TRUE, 0,
-                          (void*)(sizeof(float) * 8));
-    glEnableVertexAttribArray(attrib);
-
-    /* Save the location of uniforms we'll set later */
-    xwl_eglstream->blit_is_rgba_pos =
-        glGetUniformLocation(xwl_eglstream->blit_prog, "is_rgba");
-}
-
-static int
-xwl_dri3_open_client(ClientPtr client,
-                     ScreenPtr screen,
-                     RRProviderPtr provider,
-                     int *pfd)
-{
-    /* Not supported with this backend. */
-    return BadImplementation;
-}
-
-static PixmapPtr
-xwl_dri3_pixmap_from_fds(ScreenPtr screen,
-                         CARD8 num_fds, const int *fds,
-                         CARD16 width, CARD16 height,
-                         const CARD32 *strides, const CARD32 *offsets,
-                         CARD8 depth, CARD8 bpp,
-                         uint64_t modifier)
-{
-    PixmapPtr pixmap;
-    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
-    struct xwl_pixmap *xwl_pixmap;
-    unsigned int texture;
-    EGLint image_attribs[48];
-    uint32_t mod_hi = modifier >> 32, mod_lo = modifier & 0xffffffff, format;
-    int attrib = 0, i;
-    struct zwp_linux_buffer_params_v1 *params;
-
-    format = wl_drm_format_for_depth(depth);
-    if (!xwl_glamor_is_modifier_supported(xwl_screen, format, modifier)) {
-        ErrorF("glamor: unsupported format modifier\n");
-        return NULL;
-    }
-
-    xwl_pixmap = calloc(1, sizeof (*xwl_pixmap));
-    if (!xwl_pixmap)
-        return NULL;
-    xwl_pixmap->type = XWL_PIXMAP_DMA_BUF;
-    xwl_pixmap->xwl_screen = xwl_screen;
-
-    xwl_pixmap->buffer = NULL;
-    xwl_pixmap->stream = EGL_NO_STREAM_KHR;
-    xwl_pixmap->surface = EGL_NO_SURFACE;
-
-    params = zwp_linux_dmabuf_v1_create_params(xwl_screen->dmabuf);
-    for (i = 0; i < num_fds; i++) {
-        zwp_linux_buffer_params_v1_add(params, fds[i], i,
-                                       offsets[i], strides[i],
-                                       mod_hi, mod_lo);
-    }
-    xwl_pixmap->buffer =
-        zwp_linux_buffer_params_v1_create_immed(params, width, height,
-                                                format, 0);
-    zwp_linux_buffer_params_v1_destroy(params);
-
-
-    image_attribs[attrib++] = EGL_WIDTH;
-    image_attribs[attrib++] = width;
-    image_attribs[attrib++] = EGL_HEIGHT;
-    image_attribs[attrib++] = height;
-    image_attribs[attrib++] = EGL_LINUX_DRM_FOURCC_EXT;
-    image_attribs[attrib++] = drm_format_for_depth(depth, bpp);
-
-    if (num_fds > 0) {
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_FD_EXT;
-        image_attribs[attrib++] = fds[0];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
-        image_attribs[attrib++] = offsets[0];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
-        image_attribs[attrib++] = strides[0];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
-        image_attribs[attrib++] = mod_hi;
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
-        image_attribs[attrib++] = mod_lo;
-    }
-    if (num_fds > 1) {
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_FD_EXT;
-        image_attribs[attrib++] = fds[1];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT;
-        image_attribs[attrib++] = offsets[1];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
-        image_attribs[attrib++] = strides[1];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
-        image_attribs[attrib++] = mod_hi;
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
-        image_attribs[attrib++] = mod_lo;
-    }
-    if (num_fds > 2) {
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_FD_EXT;
-        image_attribs[attrib++] = fds[2];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_OFFSET_EXT;
-        image_attribs[attrib++] = offsets[2];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
-        image_attribs[attrib++] = strides[2];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT;
-        image_attribs[attrib++] = mod_hi;
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT;
-        image_attribs[attrib++] = mod_lo;
-    }
-    if (num_fds > 3) {
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_FD_EXT;
-        image_attribs[attrib++] = fds[3];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
-        image_attribs[attrib++] = offsets[3];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_PITCH_EXT;
-        image_attribs[attrib++] = strides[3];
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
-        image_attribs[attrib++] = mod_hi;
-        image_attribs[attrib++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
-        image_attribs[attrib++] = mod_lo;
-    }
-    image_attribs[attrib++] = EGL_NONE;
-
-    xwl_glamor_egl_make_current(xwl_screen);
-
-    /* eglCreateImageKHR will close fds */
-    xwl_pixmap->image = eglCreateImageKHR(xwl_screen->egl_display,
-                                          EGL_NO_CONTEXT,
-                                          EGL_LINUX_DMA_BUF_EXT,
-                                          NULL, image_attribs);
-    if (xwl_pixmap->image == EGL_NO_IMAGE_KHR) {
-        ErrorF("eglCreateImageKHR failed!\n");
-        if (xwl_pixmap->buffer)
-            wl_buffer_destroy(xwl_pixmap->buffer);
-        free(xwl_pixmap);
-        return NULL;
-    }
-
-    glGenTextures(1, &texture);
-    glBindTexture(GL_TEXTURE_2D, texture);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image);
-    glBindTexture(GL_TEXTURE_2D, 0);
-
-    pixmap = glamor_create_pixmap(screen, width, height, depth,
-                                  GLAMOR_CREATE_PIXMAP_NO_TEXTURE);
-    glamor_set_pixmap_texture(pixmap, texture);
-    glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
-    wl_buffer_add_listener(xwl_pixmap->buffer,
-                           &xwl_eglstream_buffer_release_listener,
-                           pixmap);
-    xwl_pixmap_set_private(pixmap, xwl_pixmap);
-
-    return pixmap;
-}
-
-static const dri3_screen_info_rec xwl_dri3_info = {
-    .version = 2,
-    .open = NULL,
-    .pixmap_from_fds = xwl_dri3_pixmap_from_fds,
-    .fds_from_pixmap = NULL,
-    .open_client = xwl_dri3_open_client,
-    .get_formats = xwl_glamor_get_formats,
-    .get_modifiers = xwl_glamor_get_modifiers,
-    .get_drawable_modifiers = xwl_glamor_get_drawable_modifiers,
-};
-
-static Bool
-xwl_glamor_eglstream_init_egl(struct xwl_screen *xwl_screen)
-{
-    struct xwl_eglstream_private *xwl_eglstream =
-        xwl_eglstream_get(xwl_screen);
-    EGLConfig config;
-    const EGLint attrib_list[] = {
-        EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
-        EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
-        EGL_CONTEXT_MAJOR_VERSION_KHR,
-        GLAMOR_GL_CORE_VER_MAJOR,
-        EGL_CONTEXT_MINOR_VERSION_KHR,
-        GLAMOR_GL_CORE_VER_MINOR,
-        EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
-        EGL_NONE
-    };
-    const EGLint config_attribs[] = {
-        EGL_SURFACE_TYPE, EGL_STREAM_BIT_KHR,
-        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
-        EGL_RED_SIZE, 8,
-        EGL_GREEN_SIZE, 8,
-        EGL_BLUE_SIZE, 8,
-        EGL_ALPHA_SIZE, 8,
-        EGL_NONE,
-    };
-    int n;
-
-    if (!(xwl_screen->glamor & XWL_GLAMOR_GL)) {
-        ErrorF("glamor: eglstream backend requires desktop OpenGL\n");
-        goto error;
-    }
-
-    xwl_screen->egl_display = glamor_egl_get_display(
-        EGL_PLATFORM_DEVICE_EXT, xwl_eglstream->egl_device);
-    if (!xwl_screen->egl_display)
-        goto error;
-
-    if (!eglInitialize(xwl_screen->egl_display, NULL, NULL)) {
-        xwl_screen->egl_display = NULL;
-        goto error;
-    }
-
-    if (!epoxy_has_egl_extension(xwl_screen->egl_display,
-                                 "EGL_IMG_context_priority")) {
-        ErrorF("EGL_IMG_context_priority not available\n");
-        goto error;
-    }
-
-    eglChooseConfig(xwl_screen->egl_display, config_attribs, &config, 1, &n);
-    if (!n) {
-        ErrorF("No acceptable EGL configs found\n");
-        goto error;
-    }
-
-    xwl_eglstream->config = config;
-#if 0
-    xwl_screen->formats =
-        XWL_FORMAT_RGB565 | XWL_FORMAT_XRGB8888 | XWL_FORMAT_ARGB8888;
-#endif
-
-    eglBindAPI(EGL_OPENGL_API);
-    xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
-                                               EGL_NO_CONFIG_KHR,
-                                               EGL_NO_CONTEXT,
-                                               attrib_list);
-    if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
-        ErrorF("Failed to create main EGL context: 0x%x\n", eglGetError());
-        goto error;
-    }
-
-    if (!eglMakeCurrent(xwl_screen->egl_display,
-                        EGL_NO_SURFACE, EGL_NO_SURFACE,
-                        xwl_screen->egl_context)) {
-        ErrorF("Failed to make EGL context current\n");
-        goto error;
-    }
-
-    xwl_eglstream->have_egl_damage =
-        epoxy_has_egl_extension(xwl_screen->egl_display,
-                                "EGL_KHR_swap_buffers_with_damage");
-    if (!xwl_eglstream->have_egl_damage)
-        ErrorF("Driver lacks EGL_KHR_swap_buffers_with_damage, performance "
-               "will be affected\n");
-
-#ifdef EGL_NV_stream_flush
-    xwl_eglstream->have_egl_stream_flush =
-        epoxy_has_egl_extension(xwl_screen->egl_display,
-                                "EGL_NV_stream_flush");
-#else
-    xwl_eglstream->have_egl_stream_flush = FALSE;
-#endif /* EGL_NV_stream_flush */
-
-    if (!xwl_eglstream->have_egl_stream_flush)
-        ErrorF("EGL_NV_stream_flush not available, "
-               "this may cause visible corruption.\n");
-
-    xwl_eglstream_init_shaders(xwl_screen);
-
-    if (epoxy_has_gl_extension("GL_OES_EGL_image")) {
-        if (dri3_screen_init(xwl_screen->screen, &xwl_dri3_info))
-            xwl_screen->glvnd_vendor = "nvidia";
-        else
-            ErrorF("DRI3 initialization failed. Performance will be affected.\n");
-    } else {
-        ErrorF("Driver lacks GL_OES_EGL_image, performance will be affected.\n");
-    }
-
-    return TRUE;
-error:
-    xwl_eglstream_cleanup(xwl_screen);
-    return FALSE;
-}
-
-static Bool
-xwl_glamor_eglstream_init_screen(struct xwl_screen *xwl_screen)
-{
-    ScreenPtr screen = xwl_screen->screen;
-
-    /* We can just let glamor handle CreatePixmap */
-    screen->DestroyPixmap = xwl_glamor_eglstream_destroy_pixmap;
-
-    return TRUE;
-}
-
-static EGLDeviceEXT
-xwl_eglstream_get_device(struct xwl_screen *xwl_screen)
-{
-    void **devices = NULL;
-    const char *exts[] = {
-        "EGL_KHR_stream",
-        "EGL_KHR_stream_producer_eglsurface",
-    };
-    int num_devices, i;
-    EGLDeviceEXT device = EGL_NO_DEVICE_EXT;
-
-    /* No device specified by the user, so find one ourselves */
-    devices = xwl_glamor_egl_get_devices(&num_devices);
-    if (!devices)
-        goto out;
-
-    for (i = 0; i < num_devices; i++) {
-        if (xwl_glamor_egl_device_has_egl_extensions(devices[i], exts,
-                                                     ARRAY_SIZE(exts))) {
-            device = devices[i];
-            break;
-        }
-    }
-
-    free(devices);
-out:
-    if (!device)
-        LogMessageVerb(X_INFO, 3, "glamor: No eglstream capable devices found\n");
-    return device;
-}
-
-void
-xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
-{
-    struct xwl_eglstream_private *xwl_eglstream;
-    EGLDeviceEXT egl_device;
-
-    xwl_screen->eglstream_backend.is_available = FALSE;
-    egl_device = xwl_eglstream_get_device(xwl_screen);
-    if (egl_device == EGL_NO_DEVICE_EXT)
-        return;
-
-    if (!dixRegisterPrivateKey(&xwl_eglstream_private_key, PRIVATE_SCREEN, 0))
-        return;
-
-    xwl_eglstream = calloc(1, sizeof(*xwl_eglstream));
-    if (!xwl_eglstream) {
-        ErrorF("Failed to allocate memory required to init EGLStream support\n");
-        return;
-    }
-
-    dixSetPrivate(&xwl_screen->screen->devPrivates,
-                  &xwl_eglstream_private_key, xwl_eglstream);
-
-    xwl_eglstream->egl_device = egl_device;
-
-    xwl_screen->eglstream_backend.init_egl = xwl_glamor_eglstream_init_egl;
-    xwl_screen->eglstream_backend.init_wl_registry = xwl_glamor_eglstream_init_wl_registry;
-    xwl_screen->eglstream_backend.has_wl_interfaces = xwl_glamor_eglstream_has_wl_interfaces;
-    xwl_screen->eglstream_backend.init_screen = xwl_glamor_eglstream_init_screen;
-    xwl_screen->eglstream_backend.get_wl_buffer_for_pixmap = xwl_glamor_eglstream_get_wl_buffer_for_pixmap;
-    xwl_screen->eglstream_backend.post_damage = xwl_glamor_eglstream_post_damage;
-    xwl_screen->eglstream_backend.allow_commits = xwl_glamor_eglstream_allow_commits;
-    xwl_screen->eglstream_backend.check_flip = xwl_glamor_eglstream_check_flip;
-    xwl_screen->eglstream_backend.get_main_device = NULL;
-    xwl_screen->eglstream_backend.is_available = TRUE;
-    xwl_screen->eglstream_backend.backend_flags = XWL_EGL_BACKEND_NO_FLAG;
-}
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 73ac9df49..b35aa25c2 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -116,13 +116,6 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
                                                  interface,
                                                  version)) {
         /* no-op */
-    } else if (xwl_screen->eglstream_backend.is_available &&
-               xwl_screen->eglstream_backend.init_wl_registry(xwl_screen,
-                                                              registry,
-                                                              id,
-                                                              interface,
-                                                              version)) {
-        /* no-op */
     }
 }
 
@@ -348,17 +341,12 @@ xwl_glamor_create_pixmap_for_window(struct xwl_window *xwl_window)
 }
 
 void
-xwl_glamor_init_backends(struct xwl_screen *xwl_screen, Bool use_eglstream)
+xwl_glamor_init_backends(struct xwl_screen *xwl_screen)
 {
 #ifdef GLAMOR_HAS_GBM
     xwl_glamor_init_gbm(xwl_screen);
-    if (!xwl_screen->gbm_backend.is_available && !use_eglstream)
-        ErrorF("Xwayland glamor: GBM backend (default) is not available\n");
-#endif
-#ifdef XWL_HAS_EGLSTREAM
-    xwl_glamor_init_eglstream(xwl_screen);
-    if (!xwl_screen->eglstream_backend.is_available && use_eglstream)
-        ErrorF("Xwayland glamor: EGLStream backend requested but not available\n");
+    if (!xwl_screen->gbm_backend.is_available)
+        ErrorF("Xwayland glamor: GBM backend is not available\n");
 #endif
 }
 
@@ -380,31 +368,10 @@ xwl_glamor_select_gbm_backend(struct xwl_screen *xwl_screen)
     return FALSE;
 }
 
-static Bool
-xwl_glamor_select_eglstream_backend(struct xwl_screen *xwl_screen)
-{
-#ifdef XWL_HAS_EGLSTREAM
-    if (xwl_screen->eglstream_backend.is_available &&
-        xwl_glamor_has_wl_interfaces(xwl_screen, &xwl_screen->eglstream_backend)) {
-        xwl_screen->egl_backend = &xwl_screen->eglstream_backend;
-        LogMessageVerb(X_INFO, 3, "glamor: Using EGLStream backend\n");
-        return TRUE;
-    }
-    else
-        LogMessageVerb(X_INFO, 3,
-                       "Missing Wayland requirements for glamor EGLStream backend\n");
-#endif
-
-    return FALSE;
-}
-
 void
-xwl_glamor_select_backend(struct xwl_screen *xwl_screen, Bool use_eglstream)
+xwl_glamor_select_backend(struct xwl_screen *xwl_screen)
 {
-    if (!xwl_glamor_select_eglstream_backend(xwl_screen)) {
-        if (!use_eglstream)
-            xwl_glamor_select_gbm_backend(xwl_screen);
-    }
+    xwl_glamor_select_gbm_backend(xwl_screen);
 }
 
 Bool
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index cadc62f6f..8e640277e 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -118,10 +118,8 @@ struct xwl_egl_backend {
 
 #ifdef XWL_HAS_GLAMOR
 
-void xwl_glamor_init_backends(struct xwl_screen *xwl_screen,
-                              Bool use_eglstream);
-void xwl_glamor_select_backend(struct xwl_screen *xwl_screen,
-                               Bool use_eglstream);
+void xwl_glamor_init_backends(struct xwl_screen *xwl_screen);
+void xwl_glamor_select_backend(struct xwl_screen *xwl_screen);
 Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
 
 Bool xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
@@ -147,22 +145,8 @@ PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
 Bool xwl_glamor_xv_init(ScreenPtr pScreen);
 #endif /* XV */
 
-#endif /* XWL_HAS_GLAMOR */
-
-#ifdef GLAMOR_HAS_GBM
 void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen);
-#else
-static inline void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
-{
-}
-#endif
-
-#ifdef XWL_HAS_EGLSTREAM
-void xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen);
-#else
-static inline void xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
-{
-}
-#endif
+
+#endif /* XWL_HAS_GLAMOR */
 
 #endif /* XWAYLAND_GLAMOR_H */
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index d40fc270a..9dcc5d937 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -758,9 +758,6 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     int ret, bpc, green_bpc, i;
     unsigned int xwl_width = 640;
     unsigned int xwl_height = 480;
-#ifdef XWL_HAS_GLAMOR
-    Bool use_eglstreams = FALSE;
-#endif
     Bool use_fixed_size = FALSE;
 
     if (!dixRegisterPrivateKey(&xwl_screen_private_key, PRIVATE_SCREEN, 0))
@@ -813,13 +810,6 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
         else if (strcmp(argv[i], "-shm") == 0) {
             xwl_screen->glamor = XWL_GLAMOR_NONE;
         }
-        else if (strcmp(argv[i], "-eglstream") == 0) {
-#ifdef XWL_HAS_EGLSTREAM
-            use_eglstreams = TRUE;
-#else
-            ErrorF("Xwayland glamor: this build does not have EGLStream support\n");
-#endif
-        }
 #ifdef XWL_HAS_GLAMOR
         else if (strcmp(argv[i], "-glamor") == 0) {
             if (strncmp(argv[i + 1], "es", 2) == 0)
@@ -885,7 +875,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 
 #ifdef XWL_HAS_GLAMOR
     if (xwl_screen->glamor)
-        xwl_glamor_init_backends(xwl_screen, use_eglstreams);
+        xwl_glamor_init_backends(xwl_screen);
 #endif
 
     /* In rootless mode, we don't have any screen storage, and the only
@@ -1008,7 +998,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 
 #ifdef XWL_HAS_GLAMOR
     if (xwl_screen->glamor) {
-        xwl_glamor_select_backend(xwl_screen, use_eglstreams);
+        xwl_glamor_select_backend(xwl_screen);
 
         if (xwl_screen->egl_backend == NULL || !xwl_glamor_init(xwl_screen)) {
            ErrorF("Failed to initialize glamor, falling back to sw\n");
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index 63740a8e2..ad627585b 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -128,7 +128,6 @@ struct xwl_screen {
     void *egl_display, *egl_context;
 
     struct xwl_egl_backend gbm_backend;
-    struct xwl_egl_backend eglstream_backend;
     /* pointer to the current backend for creating pixmaps on wayland */
     struct xwl_egl_backend *egl_backend;
 
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 1bc4239f8..7ef0056e8 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -104,9 +104,6 @@ ddxUseMsg(void)
     ErrorF("-initfd fd             add given fd as a listen socket for initialization clients\n");
     ErrorF("-listenfd fd           add given fd as a listen socket\n");
     ErrorF("-listen fd             deprecated, use \"-listenfd\" instead\n");
-#ifdef XWL_HAS_EGLSTREAM
-    ErrorF("-eglstream             use eglstream backend for nvidia GPUs\n");
-#endif
     ErrorF("-shm                   use shared memory for passing buffers\n");
 #ifdef XWL_HAS_GLAMOR
     ErrorF("-glamor [gl|es|off]    use given API for Glamor acceleration. Incompatible with -shm option\n");
@@ -238,9 +235,6 @@ ddxProcessArgument(int argc, char *argv[], int i)
         LogSetParameter(XLOG_VERBOSITY, ++verbosity);
         return 1;
     }
-    else if (strcmp(argv[i], "-eglstream") == 0) {
-        return 1;
-    }
     else if (strcmp(argv[i], "-version") == 0) {
         xwl_show_version();
         exit(0);
diff --git a/include/meson.build b/include/meson.build
index aa0c13c6b..c0afc6ee2 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -416,11 +416,10 @@ configure_file(output : 'xwin-config.h',
                input : 'xwin-config.h.meson.in',
                configuration : xwin_data)
 
-build_xwayland_glamor = build_glamor and (gbm_dep.found() or build_eglstream)
+build_xwayland_glamor = build_glamor and gbm_dep.found()
 
 xwayland_data = configuration_data()
 xwayland_data.set('XWL_HAS_GLAMOR', build_xwayland_glamor ? '1' : false)
-xwayland_data.set('XWL_HAS_EGLSTREAM', build_eglstream ? '1' : false)
 xwayland_data.set('XWL_HAS_LIBDECOR', have_libdecor ? '1' : false)
 xwayland_data.set('XWL_HAS_XWAYLAND_EXTENSION', xwaylandproto_dep.found() ? '1' : false)
 xwayland_data.set('XWL_HAS_EI', build_ei)
diff --git a/include/xwayland-config.h.meson.in b/include/xwayland-config.h.meson.in
index 5d65aba79..17ca8fcb0 100644
--- a/include/xwayland-config.h.meson.in
+++ b/include/xwayland-config.h.meson.in
@@ -7,9 +7,6 @@
 /* Build glamor support for Xwayland */
 #mesondefine XWL_HAS_GLAMOR
 
-/* Build eglstream support for Xwayland */
-#mesondefine XWL_HAS_EGLSTREAM
-
 /* Build Xwayland with libdecor support*/
 #mesondefine XWL_HAS_LIBDECOR
 
diff --git a/meson.build b/meson.build
index 858d0de97..0cfa50ce1 100644
--- a/meson.build
+++ b/meson.build
@@ -363,21 +363,6 @@ else
     have_libdecor = false
 endif
 
-eglstream_option = get_option('xwayland_eglstream')
-if build_xwayland and build_glamor
-    eglstream_dep = dependency('wayland-eglstream-protocols', required:false)
-    if eglstream_option == 'auto'
-        build_eglstream = eglstream_dep.found()
-    else
-        build_eglstream = eglstream_option == 'true'
-        if build_eglstream and not eglstream_dep.found()
-            error('glamor EGLStream support requested, but wayland-eglstream-protocols not found')
-        endif
-    endif
-else
-    build_eglstream = false
-endif
-
 if build_xwayland
     libei_dep = dependency('libei-1.0', version: '>= 1.0.0', required: get_option('xwayland_ei') in ['portal', 'socket'])
     liboeffis_dep = dependency('liboeffis-1.0', version: '>= 1.0.0', required: get_option('xwayland_ei') == 'portal')
diff --git a/meson_options.txt b/meson_options.txt
index de081709d..49407198c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,8 +6,6 @@ option('xwayland', type: 'combo', choices: ['true', 'false', 'auto'], value: 'au
        description: 'Enable Xwayland X server')
 option('glamor', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
        description: 'Enable glamor (default yes for Xorg/Xwayland builds)')
-option('xwayland_eglstream', type: 'combo', choices: ['true', 'false', 'auto'],
-       value: 'auto', description: 'Enable EGLStream support for glamor on Xwayland')
 option('xwayland_ei', type: 'combo', choices: ['socket', 'portal', 'false', 'auto'],
        value: 'auto', description: 'Enable emulated input support on Xwayland')
 option('xnest', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',


More information about the xorg-commit mailing list