From 05a5b82f59a9db1d51f6849bcaa262fdb3b913a8 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Tue, 16 Aug 2022 08:52:24 +0000 Subject: [PATCH] [util] Move sleep granularity getting to own function --- src/util/util_fps_limiter.cpp | 12 ++++++++---- src/util/util_fps_limiter.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/util/util_fps_limiter.cpp b/src/util/util_fps_limiter.cpp index 61677b01..7bc9ed17 100644 --- a/src/util/util_fps_limiter.cpp +++ b/src/util/util_fps_limiter.cpp @@ -137,6 +137,14 @@ namespace dxvk { void FpsLimiter::initialize() { + updateSleepGranularity(); + m_sleepThreshold = 4 * m_sleepGranularity; + m_lastFrame = dxvk::high_resolution_clock::now(); + m_initialized = true; + } + + + void FpsLimiter::updateSleepGranularity() { HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); if (ntdll) { @@ -163,10 +171,6 @@ namespace dxvk { // Assume 1ms sleep granularity by default m_sleepGranularity = TimerDuration(10000); } - - m_sleepThreshold = 4 * m_sleepGranularity; - m_lastFrame = dxvk::high_resolution_clock::now(); - m_initialized = true; } } diff --git a/src/util/util_fps_limiter.h b/src/util/util_fps_limiter.h index ac3d92c8..b5ad21be 100644 --- a/src/util/util_fps_limiter.h +++ b/src/util/util_fps_limiter.h @@ -84,6 +84,8 @@ namespace dxvk { void initialize(); + void updateSleepGranularity(); + }; }