1
0
Fork 0

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
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
This commit is contained in:
Daniel van Vugt 2023-07-18 16:08:25 +08:00 committed by Mingi Sung
parent 5901e0d170
commit 2d7d3999cc
Signed by: sungmg
GPG key ID: 41BAFD6FFD8036C5

View file

@ -264,10 +264,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;
@ -389,8 +385,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;
@ -415,14 +412,23 @@ 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)
{
/* User thread cursor-only updates with no "swap": we do know
* the combined time from dispatch to flip at least.
*/
dispatch_to_swap_us = 0;
swap_to_flip_us = flip_time_us - dispatch_time_us;
}
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",