diff --git a/r5dev/common/global.cpp b/r5dev/common/global.cpp index 16823564..cd72b74f 100644 --- a/r5dev/common/global.cpp +++ b/r5dev/common/global.cpp @@ -26,6 +26,7 @@ ConVar* fps_max_vsync = nullptr; #ifndef DEDICATED ConVar* fps_max_rt = nullptr; ConVar* fps_max_rt_tolerance = nullptr; +ConVar* fps_max_rt_sleep_threshold = nullptr; ConVar* fps_max_gfx = nullptr; #endif // !DEDICATED @@ -312,8 +313,9 @@ void ConVar_StaticInit(void) r_drawWorldMeshesDepthAtTheEnd = ConVar::StaticCreate("r_drawWorldMeshesDepthAtTheEnd", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth at the end).", false, 0.f, false, 0.f, nullptr, nullptr); #ifndef DEDICATED - fps_max_rt = ConVar::StaticCreate("fps_max_rt", "0", FCVAR_RELEASE, "Frame rate limiter within the render thread. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, true, 295.f, nullptr, nullptr); - fps_max_rt_tolerance = ConVar::StaticCreate("fps_max_rt_tolerance", "0.25", FCVAR_RELEASE, "Maximum amount of frame time before frame limiter restarts.", true, 0.f, false, 0.f, nullptr, nullptr); + fps_max_rt = ConVar::StaticCreate("fps_max_rt", "0", FCVAR_RELEASE, "Frame rate limiter within the render thread. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, true, 295.f, nullptr, nullptr); + fps_max_rt_tolerance = ConVar::StaticCreate("fps_max_rt_tolerance", "0.25", FCVAR_RELEASE, "Maximum amount of frame time before frame limiter restarts.", true, 0.f, false, 0.f, nullptr, nullptr); + fps_max_rt_sleep_threshold = ConVar::StaticCreate("fps_max_rt_sleep_threshold", "0.016666667", FCVAR_RELEASE, "Frame limiter starts to sleep when frame time exceeds this threshold.", true, 0.f, false, 0.f, nullptr, nullptr); fps_max_gfx = ConVar::StaticCreate("fps_max_gfx", "0", FCVAR_RELEASE, "Frame rate limiter using NVIDIA Reflex Low Latency SDK. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, true, 295.f, &GFX_NVN_Changed_f, nullptr); gfx_nvnUseLowLatency = ConVar::StaticCreate("gfx_nvnUseLowLatency" , "1", FCVAR_RELEASE | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency SDK." , false, 0.f, false, 0.f, &GFX_NVN_Changed_f, nullptr); diff --git a/r5dev/common/global.h b/r5dev/common/global.h index 9b20f609..a4f19f06 100644 --- a/r5dev/common/global.h +++ b/r5dev/common/global.h @@ -17,6 +17,7 @@ extern ConVar* fps_max_vsync; #ifndef DEDICATED extern ConVar* fps_max_rt; extern ConVar* fps_max_rt_tolerance; +extern ConVar* fps_max_rt_sleep_threshold; extern ConVar* fps_max_gfx; #endif // !DEDICATED diff --git a/r5dev/engine/framelimit.cpp b/r5dev/engine/framelimit.cpp index c0477817..0bbe906f 100644 --- a/r5dev/engine/framelimit.cpp +++ b/r5dev/engine/framelimit.cpp @@ -98,7 +98,7 @@ void CFrameLimit::Run(void) { while (m_Time.QuadPart < m_Next.QuadPart) { - if ((double)(m_Next.QuadPart - m_Time.QuadPart) > (0.0166667 * (double)g_pPerformanceFrequency->QuadPart)) + if ((double)(m_Next.QuadPart - m_Time.QuadPart) > (fps_max_rt_sleep_threshold->GetFloat() * (double)g_pPerformanceFrequency->QuadPart)) { Sleep(10); }