Replace hardcoded sleep threshold constant

Replaced with a cvar.
This commit is contained in:
Amos 2023-09-14 09:17:03 +02:00
parent 1874443425
commit 95cd34eb23
3 changed files with 6 additions and 3 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);
}