From 5fcc9a1bd15cdfe34d78eee6c1781129d2beba6b Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Tue, 16 Aug 2022 08:55:39 +0000 Subject: [PATCH] [util] Move platform specific sleep to own function in fps limiter --- src/util/util_fps_limiter.cpp | 21 +++++++++++++-------- src/util/util_fps_limiter.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/util/util_fps_limiter.cpp b/src/util/util_fps_limiter.cpp index 7bc9ed17..66737eaf 100644 --- a/src/util/util_fps_limiter.cpp +++ b/src/util/util_fps_limiter.cpp @@ -111,14 +111,7 @@ namespace dxvk { while (remaining > sleepThreshold) { TimerDuration sleepDuration = remaining - sleepThreshold; - if (NtDelayExecution) { - LARGE_INTEGER ticks; - ticks.QuadPart = -sleepDuration.count(); - - NtDelayExecution(FALSE, &ticks); - } else { - std::this_thread::sleep_for(sleepDuration); - } + performSleep(sleepDuration); t1 = dxvk::high_resolution_clock::now(); remaining -= std::chrono::duration_cast(t1 - t0); @@ -173,4 +166,16 @@ namespace dxvk { } } + + void FpsLimiter::performSleep(TimerDuration sleepDuration) { + if (NtDelayExecution) { + LARGE_INTEGER ticks; + ticks.QuadPart = -sleepDuration.count(); + + NtDelayExecution(FALSE, &ticks); + } else { + std::this_thread::sleep_for(sleepDuration); + } + } + } diff --git a/src/util/util_fps_limiter.h b/src/util/util_fps_limiter.h index b5ad21be..94890c2c 100644 --- a/src/util/util_fps_limiter.h +++ b/src/util/util_fps_limiter.h @@ -86,6 +86,8 @@ namespace dxvk { void updateSleepGranularity(); + void performSleep(TimerDuration sleepDuration); + }; }