From 5e9885bec1ea2c36994e5a19e35e6cecc6ea7523 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 10 Dec 2017 17:27:02 +1100 Subject: [PATCH] [client] apply fps limiter when presentation time is too low --- client/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/main.c b/client/main.c index a9243dbd..974bcc6a 100644 --- a/client/main.c +++ b/client/main.c @@ -163,6 +163,12 @@ uint64_t detectPresentTime() const uint64_t t = (microtime() - start) / 20; DEBUG_INFO("detected: %lu (%f Hz)", t, 1000000.0f / t); + if (t < 2000) + { + DEBUG_INFO("present time too low, setting framerate limit to %d Hz", FPS_LIMIT); + return ceil((1000000.0/(double)FPS_LIMIT)); + } + return t; } @@ -176,11 +182,7 @@ int renderThread(void * unused) SDL_Texture * textTexture = NULL; SDL_Rect textRect; - const uint64_t presentTime = - params.vsync ? - detectPresentTime() : - ceil((1000000.0/(double)FPS_LIMIT)); - + const uint64_t presentTime = detectPresentTime(); unsigned int lateCount = 0; int pollDelay = 0;