From f9b6dcc9866bf42d48b2d2281431a706e99948cc Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 20 Aug 2020 15:18:45 +1000 Subject: [PATCH] [client] only resync the timer if we got an early frame This prevents a slow update (ie, 30ups) from pulling the refresh rate below the minimum (ie, 60fps). --- VERSION | 2 +- client/src/main.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 78d01c79..020680e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B2-rc4-6-g7e362050f7+1 \ No newline at end of file +B2-rc4-7-g5c912e3c27+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 0f7ba80e..0436b73d 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -213,12 +213,16 @@ static int renderThread(void * unused) if (atomic_fetch_sub_explicit(&a_framesPending, 1, memory_order_release) > 1) continue; - if (lgWaitEventAbs(e_frame, &time)) + if (lgWaitEventAbs(e_frame, &time) && state.frameTime > 0) { - if (state.frameTime > 0) + /* only resync the timer if we got an early frame */ + struct timespec now, diff; + clock_gettime(CLOCK_REALTIME, &now); + tsDiff(&diff, &now, &time); + if (diff.tv_sec == 0 && diff.tv_nsec < state.frameTime) { resyncCheck = 0; - clock_gettime(CLOCK_REALTIME, &time); + memcpy(&time, &now, sizeof(struct timespec)); tsAdd(&time, state.frameTime); } }