Add cvar for low latency timing (work in progress)

Work in progress NVIDIA Low Latency timing implementation.
This commit is contained in:
Kawe Mazidjatari 2023-09-12 00:19:47 +02:00
parent 804f96625b
commit 9df90d4a25
5 changed files with 16 additions and 8 deletions

View File

@ -74,6 +74,7 @@ ConVar* r_visualizetraces_duration = nullptr;
ConVar* gfx_nvnUseLowLatency = nullptr;
ConVar* gfx_nvnUseLowLatencyBoost = nullptr;
ConVar* gfx_nvnUseMarkersToOptimize = nullptr;
#endif // !DEDICATED
ConVar* stream_overlay = nullptr;
@ -316,6 +317,7 @@ void ConVar_StaticInit(void)
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, 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);
gfx_nvnUseMarkersToOptimize = ConVar::StaticCreate("gfx_nvnUseMarkersToOptimize", "0", FCVAR_DEVELOPMENTONLY /*!!! MAKE RELEASE ONCE IMPLEMENTED !!!*/ | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency Timing.", false, 0.f, false, 0.f, nullptr, nullptr);
#endif // !DEDICATED
//-------------------------------------------------------------------------

View File

@ -65,6 +65,7 @@ extern ConVar* r_visualizetraces_duration;
extern ConVar* gfx_nvnUseLowLatency;
extern ConVar* gfx_nvnUseLowLatencyBoost;
extern ConVar* gfx_nvnUseMarkersToOptimize;
#endif // !DEDICATED
extern ConVar* stream_overlay;

View File

@ -175,6 +175,7 @@ bool CEngineAPI::MainLoop()
#ifndef DEDICATED
const bool bUseLowLatencyMode = gfx_nvnUseLowLatency->GetBool();
const bool bUseLowLatencyBoost = gfx_nvnUseLowLatencyBoost->GetBool();
const bool bUseLowLatencyTiming = gfx_nvnUseMarkersToOptimize->GetBool();
float fpsMax = fps_max_gfx->GetFloat();
@ -192,7 +193,8 @@ bool CEngineAPI::MainLoop()
fpsMax = 0.0f; // Don't let NVIDIA limit the frame rate.
}
GFX_RunLowLatencySDK(D3D11Device(), bUseLowLatencyMode, bUseLowLatencyBoost, fpsMax);
GFX_RunLowLatencySDK(D3D11Device(), bUseLowLatencyMode,
bUseLowLatencyBoost, bUseLowLatencyTiming, fpsMax);
CEngineAPI_PumpMessages();
#endif // !DEDICATED

View File

@ -9,13 +9,15 @@
//-----------------------------------------------------------------------------
// Purpose: runs the low latency sdk
// Input : device -
// useLowLatencyMode -
// useLowLatencyBoost -
// maxFramesPerSecond -
// Input : *device -
// useLowLatencyMode -
// useLowLatencyBoost -
// useMarkersToOptimize -
// maxFramesPerSecond -
//-----------------------------------------------------------------------------
void GFX_RunLowLatencySDK(IUnknown* device, const bool useLowLatencyMode,
const bool useLowLatencyBoost, const float maxFramesPerSecond)
const bool useLowLatencyBoost, const bool useMarkersToOptimize,
const float maxFramesPerSecond)
{
Assert(device);
Assert(IsFinite(maxFramesPerSecond));
@ -28,7 +30,7 @@ void GFX_RunLowLatencySDK(IUnknown* device, const bool useLowLatencyMode,
params.minimumIntervalUs = maxFramesPerSecond > 0
? (NvU32)((1000.0f / maxFramesPerSecond) * 1000.0f)
: 0;
params.bUseMarkersToOptimize = false;
params.bUseMarkersToOptimize = useMarkersToOptimize;
NvAPI_Status status = NvAPI_D3D_SetSleepMode(device, &params);

View File

@ -2,6 +2,7 @@
#define GFSDK_REFLEX_H
void GFX_RunLowLatencySDK(IUnknown* device, const bool useLowLatencyMode,
const bool useLowLatencyBoost, const float maxFramesPerSecond);
const bool useLowLatencyBoost, const bool useMarkersToOptimize,
const float maxFramesPerSecond);
#endif // GFSDK_REFLEX_H