From 23f3c17f0ceaf46f61e35dc74c999ec6eb24b047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Mon, 19 Aug 2024 18:56:20 +0200 Subject: [PATCH] kms/impl-device: Use deadline timer for all updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not with VRR though, because the deadline timer fires at most every 33ms then. Previously, the deadline timer was used only for cursor-only updates. Using it for other updates means they pick up the latest cursor position available at the deadline, resulting in the lowest possible input→output latency for cursor movement. TTBOMK this unlocks the full potential of the KMS thread given the current atomic KMS API. v2: * Don't call meta_kms_update_merge_from with twice the same update pointer. v3: * Don't arm deadline timer if crtc_frame->pending_page_flip is true. v4: * Tweak want_deadline_timer indentation per check-code-style CI job. v5: * Also check crtc_frame->await_flush for want_deadline_timer. v6: * Tweak coding style to keep lines shorter. (Jonas Ådahl) Part-of: --- src/backends/native/meta-kms-impl-device.c | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 06e689f14..e956b5a78 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -1840,6 +1840,7 @@ meta_kms_impl_device_update_ready (MetaThreadImpl *impl, MetaKmsImplDevice *impl_device = meta_kms_device_get_impl_device (device); MetaKmsImplDevicePrivate *priv = meta_kms_impl_device_get_instance_private (impl_device); + gboolean want_deadline_timer; MetaKmsUpdate *update; MetaKmsCrtc *latch_crtc; MetaKmsFeedback *feedback; @@ -1853,24 +1854,39 @@ meta_kms_impl_device_update_ready (MetaThreadImpl *impl, latch_crtc = g_steal_pointer (&crtc_frame->submitted_update.latch_crtc); - if (crtc_frame->pending_page_flip && + want_deadline_timer = + !crtc_frame->await_flush && + is_using_deadline_timer (impl_device) && + !meta_kms_crtc_get_current_state (crtc_frame->crtc)->vrr.enabled; + + if ((want_deadline_timer || crtc_frame->pending_page_flip) && !meta_kms_update_get_mode_sets (update)) { - g_assert (latch_crtc); + if (crtc_frame->pending_page_flip) + { + g_assert (latch_crtc); - meta_topic (META_DEBUG_KMS, - "Queuing update on CRTC %u (%s): pending page flip", - meta_kms_crtc_get_id (latch_crtc), - priv->path); + meta_topic (META_DEBUG_KMS, + "Queuing update on CRTC %u (%s): pending page flip", + meta_kms_crtc_get_id (latch_crtc), + priv->path); + } queue_update (impl_device, crtc_frame, update); - return GINT_TO_POINTER (TRUE); + + if (crtc_frame->pending_page_flip || + ensure_deadline_timer_armed (impl_device, crtc_frame)) + return GINT_TO_POINTER (TRUE); } if (crtc_frame->pending_update) { - meta_kms_update_merge_from (crtc_frame->pending_update, update); - meta_kms_update_free (update); + if (update != crtc_frame->pending_update) + { + meta_kms_update_merge_from (crtc_frame->pending_update, update); + meta_kms_update_free (update); + } + update = g_steal_pointer (&crtc_frame->pending_update); disarm_crtc_frame_deadline_timer (crtc_frame); }