mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: keep a slightly early vsync tick for frame pacing
This commit is contained in:
1 parent
b88eebe09b
commit
53c63b6dc2
1 file changed
+13
-3
@@ -807,11 +807,21 @@ static uint32_t nominal_refresh_ns(void) {
|
||||
return (uint32_t)(1000000000000LL / (int64_t)mhz);
|
||||
}
|
||||
|
||||
/* Gamescope paces from this timestamp (#717). The Choreographer tick is often still
|
||||
* slightly ahead of this thread, because the UI thread queues the callback, and that
|
||||
* used to throw the tick away (render_ns < tick) and report the draw time instead.
|
||||
* Keep a tick within one refresh of the draw, ahead or behind. A missing tick, or one
|
||||
* more than a refresh away, falls back to the draw time. Never report the next refresh:
|
||||
* gamescope would wake a frame late. */
|
||||
static int64_t presented_ns(int64_t render_ns) {
|
||||
if (!g_tick_vsync_ns || render_ns - g_last_vsync_ns > (int64_t)nominal_refresh_ns() ||
|
||||
render_ns < g_tick_vsync_ns)
|
||||
int64_t tick = g_tick_vsync_ns;
|
||||
int64_t refresh = (int64_t)nominal_refresh_ns();
|
||||
if (!tick || render_ns - g_last_vsync_ns > refresh)
|
||||
return render_ns;
|
||||
return g_tick_vsync_ns;
|
||||
int64_t delta = render_ns - tick;
|
||||
if (delta > refresh || -delta > refresh)
|
||||
return render_ns;
|
||||
return tick;
|
||||
}
|
||||
|
||||
static void feedback_present_all(struct wl_list *list, int64_t t) {
|
||||
|
||||
Reference in new issue
Block a user