From aab01c73914eeadf75672ab954538cd34d07e817 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 2 Jul 2024 12:36:01 +0200 Subject: [PATCH] xwayland/window-buffers: Do not always set syncpnts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function xwl_window_swap_pixmap() can be called from two places, either from xwl_window_attach_buffer() or from damage_report(). When called from xwl_window_attach_buffer(), the new buffer is attached and the surface committed. However, when called from damage_report(), a new buffer might not be attached before the surface is committed. That's fine with implicit synchronization, but if we use explicit synchronization, committing a surface without a new buffer attached but with a release timeline point set is a protocol error: | If at surface commit time there is a pending release timeline point | set but no pending buffer attached, a no_buffer error is raised. To avoid such an issue, add a new parameter to xwl_window_swap_pixmap() to hint whether it should set the synchronization points, and have the synchronization points set only from xwl_window_attach_buffer(). v2: Rename param to handle_sync (Michel) Suggested-by: Michel Dänzer Signed-off-by: Olivier Fourdan Part-of: --- hw/xwayland/xwayland-window-buffers.c | 4 ++-- hw/xwayland/xwayland-window-buffers.h | 2 +- hw/xwayland/xwayland-window.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c index 442e9e2fd..e3f8ffe21 100644 --- a/hw/xwayland/xwayland-window-buffers.c +++ b/hw/xwayland/xwayland-window-buffers.c @@ -350,7 +350,7 @@ xwl_window_realloc_pixmap(struct xwl_window *xwl_window) } PixmapPtr -xwl_window_swap_pixmap(struct xwl_window *xwl_window) +xwl_window_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync) { struct xwl_screen *xwl_screen = xwl_window->xwl_screen; WindowPtr surface_window = xwl_window->surface_window; @@ -409,7 +409,7 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window) xwl_window_buffer->refcnt++; #ifdef XWL_HAS_GLAMOR - if (!xwl_glamor_supports_implicit_sync(xwl_screen)) { + if (handle_sync && !xwl_glamor_supports_implicit_sync(xwl_screen)) { if (xwl_screen->explicit_sync && xwl_glamor_gbm_set_syncpts(xwl_window, window_pixmap)) { implicit_sync = FALSE; /* wait until the release fence is available before re-using this buffer */ diff --git a/hw/xwayland/xwayland-window-buffers.h b/hw/xwayland/xwayland-window-buffers.h index ee26d3244..af46eb91b 100644 --- a/hw/xwayland/xwayland-window-buffers.h +++ b/hw/xwayland/xwayland-window-buffers.h @@ -36,6 +36,6 @@ void xwl_window_buffer_release(struct xwl_window_buffer *xwl_window_buffer); 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_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync); #endif /* XWAYLAND_WINDOW_BUFFERS_H */ diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index 12bb3009c..90ece334a 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -318,7 +318,7 @@ damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data) window_pixmap = xwl_screen->screen->GetWindowPixmap(xwl_window->surface_window); if (xwl_is_client_pixmap(window_pixmap)) - xwl_screen->screen->DestroyPixmap(xwl_window_swap_pixmap(xwl_window)); + xwl_screen->screen->DestroyPixmap(xwl_window_swap_pixmap(xwl_window, FALSE)); } static void @@ -1955,7 +1955,7 @@ xwl_window_attach_buffer(struct xwl_window *xwl_window) PixmapPtr pixmap; int i; - pixmap = xwl_window_swap_pixmap(xwl_window); + pixmap = xwl_window_swap_pixmap(xwl_window, TRUE); buffer = xwl_pixmap_get_wl_buffer(pixmap); if (!buffer) {