From 22689d722ab4e13ab272c3534f5d18a55c94084f Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 3 Apr 2024 16:58:13 +0800 Subject: [PATCH] compositor/sync-ring: Allow the gpu_fence to be moved When the compositor inserts two waits in a frame, such as f606a4424a5afc, the second insertion shouldn't break the ring's state machine as easily as it does. We can instead merge the two GL waits into one by simply moving the GL fence to the latest insertion. Each insertion still does its own X11 sync though. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3384 Part-of: --- src/compositor/meta-sync-ring.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/compositor/meta-sync-ring.c b/src/compositor/meta-sync-ring.c index 8f5d1a046..1267dd4f2 100644 --- a/src/compositor/meta-sync-ring.c +++ b/src/compositor/meta-sync-ring.c @@ -544,20 +544,29 @@ gboolean meta_sync_ring_insert_wait (void) { MetaSyncRing *ring = meta_sync_ring_get (); + MetaSync *sync; if (!ring) return FALSE; g_return_val_if_fail (ring->xdisplay != NULL, FALSE); - if (ring->current_sync->state != META_SYNC_STATE_READY) + sync = ring->current_sync; + + if (sync->state == META_SYNC_STATE_WAITING) + { + meta_gl_delete_sync (sync->gpu_fence); + sync->gpu_fence = 0; + sync->state = META_SYNC_STATE_READY; + } + else if (sync->state != META_SYNC_STATE_READY) { meta_warning ("MetaSyncRing: Sync object is not ready -- were events handled properly?"); if (!meta_sync_ring_reboot (ring->xdisplay)) return FALSE; } - meta_sync_insert (ring->current_sync); + meta_sync_insert (sync); return TRUE; }