From 17648c4b2d03f93a17ab76c642461f0ce2801f70 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Tue, 18 Jul 2023 16:08:25 +0800 Subject: [PATCH] clutter/frame-clock: Record measurements of zero for cursor-only updates But only if we've ever got actual swap measurements (COGL_FEATURE_ID_TIMESTAMP_QUERY). If it's supported then we now drop to double buffering and get optimal latency on a burst of cursor-only updates. Closes: https://launchpad.net/bugs/2023363 --- clutter/clutter/clutter-frame-clock.c | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index 016c4c209..0993ae8c6 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -262,10 +262,6 @@ static void maybe_update_longterm_max_duration_us (ClutterFrameClock *frame_clock, ClutterFrameInfo *frame_info) { - /* Do not update long-term max if there has been no measurement */ - if (!frame_clock->shortterm_max_update_duration_us) - return; - if ((frame_info->presentation_time - frame_clock->longterm_promotion_us) < G_USEC_PER_SEC) return; @@ -387,8 +383,9 @@ clutter_frame_clock_notify_presented (ClutterFrameClock *frame_clock, frame_clock->got_measurements_last_frame = FALSE; - if (frame_info->cpu_time_before_buffer_swap_us != 0 && - frame_info->has_valid_gpu_rendering_duration) + if ((frame_info->cpu_time_before_buffer_swap_us != 0 && + frame_info->has_valid_gpu_rendering_duration) || + frame_clock->ever_got_measurements) { int64_t dispatch_to_swap_us, swap_to_rendering_done_us, swap_to_flip_us; int64_t dispatch_time_us = 0, flip_time_us = 0; @@ -413,14 +410,21 @@ clutter_frame_clock_notify_presented (ClutterFrameClock *frame_clock, break; } - dispatch_to_swap_us = - frame_info->cpu_time_before_buffer_swap_us - - dispatch_time_us; + if (frame_info->cpu_time_before_buffer_swap_us == 0) + { + /* Cursor-only updates with no "swap" or "flip" */ + dispatch_to_swap_us = 0; + swap_to_flip_us = 0; + } + else + { + dispatch_to_swap_us = frame_info->cpu_time_before_buffer_swap_us - + dispatch_time_us; + swap_to_flip_us = flip_time_us - + frame_info->cpu_time_before_buffer_swap_us; + } swap_to_rendering_done_us = frame_info->gpu_rendering_duration_ns / 1000; - swap_to_flip_us = - flip_time_us - - frame_info->cpu_time_before_buffer_swap_us; CLUTTER_NOTE (FRAME_TIMINGS, "%s: update2dispatch %ld µs, dispatch2swap %ld µs, swap2render %ld µs, swap2flip %ld µs",