Add cvar for NVAPI frame limiter

Might be useful for someone.
This commit is contained in:
Kawe Mazidjatari 2023-09-10 01:44:04 +02:00
parent fce3b1f46a
commit bf01287129
3 changed files with 11 additions and 2 deletions

View File

@ -22,6 +22,10 @@ ConVar* debug_draw_box_depth_test = nullptr;
ConVar* developer = nullptr;
ConVar* fps_max = nullptr;
#ifndef DEDICATED
ConVar* fps_max_gfx = nullptr;
#endif // !DEDICATED
ConVar* base_tickinterval_sp = nullptr;
ConVar* base_tickinterval_mp = nullptr;
@ -304,6 +308,7 @@ 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_gfx = ConVar::StaticCreate("fps_max_gfx", "0", FCVAR_RELEASE, "Frame rate limiter using NVIDIA Reflex Low Latency SDK.", true, 0.f, false, 0.f, nullptr, nullptr);
gfx_nvnUseLowLatency = ConVar::StaticCreate("gfx_nvnUseLowLatency" , "1", FCVAR_RELEASE | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency SDK." , false, 0.f, false, 0.f, nullptr, nullptr);
gfx_nvnUseLowLatencyBoost = ConVar::StaticCreate("gfx_nvnUseLowLatencyBoost", "1", FCVAR_RELEASE | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency Boost.", false, 0.f, false, 0.f, nullptr, nullptr);
#endif // !DEDICATED

View File

@ -13,6 +13,10 @@ extern ConVar* debug_draw_box_depth_test;
extern ConVar* developer;
extern ConVar* fps_max;
#ifndef DEDICATED
extern ConVar* fps_max_gfx;
#endif // !DEDICATED
extern ConVar* base_tickinterval_sp;
extern ConVar* base_tickinterval_mp;

View File

@ -173,14 +173,14 @@ bool CEngineAPI::MainLoop()
#ifndef DEDICATED
const bool bUseLowLatencyMode = gfx_nvnUseLowLatency->GetBool();
const bool bUseLowLatencyBoost = gfx_nvnUseLowLatencyBoost->GetBool();
//const float fpsMax = fps_max->GetFloat();
const float fpsMax = fps_max_gfx->GetFloat();
NV_SET_SLEEP_MODE_PARAMS_V1 params = {};
params.version = NV_SET_SLEEP_MODE_PARAMS_VER1;
params.bLowLatencyMode = bUseLowLatencyMode;
params.bLowLatencyBoost = bUseLowLatencyMode && bUseLowLatencyBoost;
params.minimumIntervalUs = 0;// /*!!!leaving this 0 results in better performance!!!*/ fpsMax > 0 ? (NvU32)((1000.0f / fpsMax) * 1000.0f) : 0;
params.minimumIntervalUs = fpsMax > 0 ? (NvU32)((1000.0f / fpsMax) * 1000.0f) : 0;
params.bUseMarkersToOptimize = false;
NvAPI_Status status = NvAPI_D3D_SetSleepMode(*g_ppGameDevice, &params);