From e8a213beef9ed285d1c7e1c84db626f3b871a5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sun, 12 Nov 2023 16:07:02 +0100 Subject: [PATCH] kms/impl-device/atomic: Set IN_FENCE_FD for direct scanout Since meta_kms_impl_device_get_sync_file always returns the same file descriptor referencing the same sync_file, this means the atomic ioctl doesn't need to wait for any fences to signal. This is fine because we already waited for the buffer to become idle before applying the Wayland surface state. Fixes the atomic commit ioctl spuriously synchronizing to the screen cast paint (at least with the amdgpu driver), which could result in the page flip missing its target scanout cycle. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3148 v2: * Rename local variable to signaled_sync_file for consistency with new function name Part-of: --- .../native/meta-kms-impl-device-atomic.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/backends/native/meta-kms-impl-device-atomic.c b/src/backends/native/meta-kms-impl-device-atomic.c index 5d03cff44..f2f7acecd 100644 --- a/src/backends/native/meta-kms-impl-device-atomic.c +++ b/src/backends/native/meta-kms-impl-device-atomic.c @@ -588,6 +588,30 @@ process_plane_assignment (MetaKmsImplDevice *impl_device, error)) return FALSE; } + + if (plane_assignment->flags & META_KMS_ASSIGN_PLANE_FLAG_DIRECT_SCANOUT) + { + int signaled_sync_file; + + signaled_sync_file = + meta_kms_impl_device_get_signaled_sync_file (impl_device); + + if (signaled_sync_file >= 0) + { + g_autoptr (GError) local_error = NULL; + + if (!add_plane_property (impl_device, + plane, req, + META_KMS_PLANE_PROP_IN_FENCE_FD, + signaled_sync_file, + &local_error)) + { + meta_topic (META_DEBUG_KMS, + "add_plane_property failed for IN_FENCE_FD: %s", + local_error->message); + } + } + } } else {