From d411a8b611aab57b2ac068928ddc09bef2b2a097 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 4 Mar 2024 17:15:13 +0100 Subject: [PATCH] xwayland: add workaround for drivers that don't support impicit sync Without either implicit or explicit synchronization, the result of rendering is pretty much undefined, and many glitches can appear. This still doesn't synchronize buffer release, but it works around most glitches until explicit sync is supported. Signed-off-by: Xaver Hugl Part-of: --- hw/xwayland/xwayland-present.c | 5 ++++- hw/xwayland/xwayland-window-buffers.c | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c index d973dea23..91dc396fb 100644 --- a/hw/xwayland/xwayland-present.c +++ b/hw/xwayland/xwayland-present.c @@ -695,7 +695,10 @@ xwl_present_check_flip(RRCrtcPtr crtc, if (xwl_window->xwl_screen->glamor && !xwl_glamor_check_flip(present_window, pixmap)) return FALSE; -#endif + + if (!xwl_glamor_supports_implicit_sync(xwl_window->xwl_screen)) + return FALSE; +#endif /* XWL_HAS_GLAMOR */ /* Can't flip if the window pixmap doesn't match the xwl_window parent * window's, e.g. because a client redirected this window or one of its diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c index ced9d9567..85c987de7 100644 --- a/hw/xwayland/xwayland-window-buffers.c +++ b/hw/xwayland/xwayland-window-buffers.c @@ -32,6 +32,9 @@ #include "xwayland-pixmap.h" #include "xwayland-screen.h" #include "xwayland-window-buffers.h" +#ifdef XWL_HAS_GLAMOR +#include "glamor.h" +#endif #define BUFFER_TIMEOUT 1 * 1000 /* ms */ @@ -384,6 +387,12 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window) /* Hold a reference on the buffer until it's released by the compositor */ xwl_window_buffer->refcnt++; + +#ifdef XWL_HAS_GLAMOR + if (!xwl_glamor_supports_implicit_sync(xwl_screen)) { + glamor_finish(xwl_screen->screen); + } +#endif /* XWL_HAS_GLAMOR */ xwl_pixmap_set_buffer_release_cb(xwl_window_buffer->pixmap, xwl_window_buffer_release_callback, xwl_window_buffer);