From 703baa94fe3abe044509f3870a94e37d79bb40a4 Mon Sep 17 00:00:00 2001 From: Connor Smith Date: Fri, 18 Mar 2022 20:24:48 -0400 Subject: [PATCH] Make app pacing more robust to variable composition->display times. If the last returned display time shifts backwards slightly with respect to the last sampled display time from the compositor, the next predicted display time will not move forward by one frame. Adding half the display period to the comparison makes the pacing robust to this case. --- src/xrt/auxiliary/util/u_pacing_app.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xrt/auxiliary/util/u_pacing_app.c b/src/xrt/auxiliary/util/u_pacing_app.c index d414aeda1..9dd862906 100644 --- a/src/xrt/auxiliary/util/u_pacing_app.c +++ b/src/xrt/auxiliary/util/u_pacing_app.c @@ -199,8 +199,10 @@ predict_display_time(const struct pacing_app *pa, uint64_t now_ns, uint64_t peri // Start from the last time that the driver displayed something. uint64_t val = last_sample_displayed(pa); - // Return a time after the last returned display time. - while (val <= last_return_predicted_display(pa)) { + // Return a time after the last returned display time. Add half the + // display period to the comparison for robustness when the last display + // time shifts slightly with respect to the last sample. + while (val <= last_return_predicted_display(pa) + (period_ns / 2)) { val += period_ns; }