diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2024-06-18 13:58:45 +0200 |
---|---|---|
committer | Olivier Fourdan <fourdan@gmail.com> | 2024-07-04 08:36:40 +0000 |
commit | 33486519dcc0417dbfe5243017ab215e4548e0ba (patch) | |
tree | 6e56ad5c3aac708a68cb4ef9999aaff95d0fc147 /hw | |
parent | 6636b7c0039d295a97e0db4b4ac54f92952ee489 (diff) |
xwayland/window-buffers: Move code to submit pixmaps
Move the code which takes care of submitting pixmaps and the
synchronization points to its own function.
This will allow to reuse that code from different code path.
No functional change intended.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit 33330f0dc96c126895e2670b22de4d7980a60283)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1569>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xwayland/xwayland-window-buffers.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c index e3f8ffe21..ad2cef156 100644 --- a/hw/xwayland/xwayland-window-buffers.c +++ b/hw/xwayland/xwayland-window-buffers.c @@ -349,6 +349,32 @@ xwl_window_realloc_pixmap(struct xwl_window *xwl_window) screen->DestroyPixmap(window_pixmap); } +static Bool +xwl_window_handle_pixmap_sync(struct xwl_window *xwl_window, + PixmapPtr pixmap, + struct xwl_window_buffer *xwl_window_buffer) +{ + Bool implicit_sync = TRUE; +#ifdef XWL_HAS_GLAMOR + struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + + if (!xwl_glamor_supports_implicit_sync(xwl_screen)) { + if (xwl_screen->explicit_sync && xwl_glamor_gbm_set_syncpts(xwl_window, pixmap)) { + implicit_sync = FALSE; + /* wait until the release fence is available before re-using this buffer */ + xwl_glamor_gbm_wait_release_fence(xwl_window, pixmap, xwl_window_buffer); + } else { + /* If glamor does not support implicit sync and we can't use + * explicit sync, wait for the GPU to be idle before presenting. + * Note that buffer re-use will still be unsynchronized :( + */ + glamor_finish(xwl_screen->screen); + } + } +#endif /* XWL_HAS_GLAMOR */ + return implicit_sync; +} + PixmapPtr xwl_window_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync) { @@ -356,7 +382,6 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync) WindowPtr surface_window = xwl_window->surface_window; struct xwl_window_buffer *xwl_window_buffer; PixmapPtr window_pixmap; - Bool implicit_sync = TRUE; window_pixmap = (*xwl_screen->screen->GetWindowPixmap) (surface_window); @@ -408,23 +433,8 @@ xwl_window_swap_pixmap(struct xwl_window *xwl_window, Bool handle_sync) /* Hold a reference on the buffer until it's released by the compositor */ xwl_window_buffer->refcnt++; -#ifdef XWL_HAS_GLAMOR - 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 */ - xwl_glamor_gbm_wait_release_fence(xwl_window, window_pixmap, xwl_window_buffer); - } else { - /* If glamor does not support implicit sync and we can't use - * explicit sync, wait for the GPU to be idle before presenting. - * Note that buffer re-use will still be unsynchronized :( - */ - glamor_finish(xwl_screen->screen); - } - } -#endif /* XWL_HAS_GLAMOR */ - - if (implicit_sync) { + if (handle_sync && + xwl_window_handle_pixmap_sync(xwl_window, window_pixmap, xwl_window_buffer)) { xwl_pixmap_set_buffer_release_cb(xwl_window_buffer->pixmap, xwl_window_buffer_release_callback, xwl_window_buffer); |