summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <mdaenzer@redhat.com>2024-04-26 12:44:52 +0200
committerOlivier Fourdan <ofourdan@redhat.com>2024-05-02 10:50:04 +0200
commit9f28e2a85d4bb29489f2b464291e5de4e78f5c9d (patch)
tree78eb3567dbbc3be1a3f5a46e6b3fc05b96a638ac
parent07470d2ca200de3ec13634e60802d76ec422d78f (diff)
xwayland/present: Skip queued flip when a new one becomes ready
If multiple flips become ready for the same MSC, we would previously execute them all sequentially, one per MSC for sync flips. This could result in an unbounded flip queue and corresponding memory consumption. With implicit sync, leave the mailbox handling to the compositor for async flips though. v2: * Use present_vblank_rec::sync_flip. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1664 Fixes: e1f16fb1aca5 ("xwayland: don't scrap pending present requests") (cherry picked from commit 0d9a54aa975e050ba044271a48c037416b5d54ca) Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1494>
-rw-r--r--hw/xwayland/xwayland-present.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 43f053dfb..60427cca0 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -1053,6 +1053,25 @@ retry:
}
if (flip_pending && vblank->flip && !notify_only) {
+ present_vblank_ptr flip_queued_last;
+
+ flip_queued_last = xorg_list_last_entry(&xwl_present_window->flip_queue,
+ present_vblank_rec, event_queue);
+
+ /* Do mailbox handling for queued flips, to prevent the flip queue from
+ * growing unbounded.
+ */
+ if (flip_queued_last != flip_pending &&
+ (flip_queued_last->sync_flip
+#ifdef DRI3
+ || vblank->acquire_syncobj
+#endif
+ )) {
+ xorg_list_del(&flip_queued_last->event_queue);
+ present_vblank_scrap(flip_queued_last);
+ xwl_present_re_execute(flip_queued_last);
+ }
+
DebugPresent(("\tr %" PRIu64 " %p (pending %p)\n",
vblank->event_id, vblank, flip_pending));
xorg_list_append(&vblank->event_queue, &xwl_present_window->flip_queue);