Engine: don't run NVIDIA Reflex if -gfx_disableLowLatency was specified

This command line argument should fully disable NVIDIA Reflex, AMD Anti-Lag 2 and PCL statistics.
This commit is contained in:
Kawe Mazidjatari 2024-09-16 16:27:02 +02:00
parent 0eb0d73ae1
commit 10efa56c58
5 changed files with 33 additions and 6 deletions

View File

@ -234,7 +234,7 @@ void CEngineAPI::UpdateLowLatencyParameters()
void CEngineAPI::RunLowLatencyFrame() void CEngineAPI::RunLowLatencyFrame()
{ {
#ifndef DEDICATED #ifndef DEDICATED
if (GeForce_IsLowLatencySDKEnabled()) if (GeForce_IsLowLatencySDKAvailable())
{ {
if (GeForce_HasPendingLowLatencyParameterUpdates()) if (GeForce_HasPendingLowLatencyParameterUpdates())
{ {

View File

@ -9,6 +9,8 @@
static bool s_LowLatencySDKEnabled = false; static bool s_LowLatencySDKEnabled = false;
static bool s_LowLatencyAvailable = false;
// If false, the system will call 'NvAPI_D3D_SetSleepMode' to update the parameters. // If false, the system will call 'NvAPI_D3D_SetSleepMode' to update the parameters.
static bool s_ReflexModeInfoUpToDate = false; static bool s_ReflexModeInfoUpToDate = false;
@ -31,9 +33,9 @@ void GeForce_EnableLowLatencySDK(const bool enable)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: whether we should run the low latency SDK // Purpose: whether we should run the low latency SDK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool GeForce_IsLowLatencySDKEnabled(void) bool GeForce_IsLowLatencySDKAvailable(void)
{ {
if (!s_LowLatencySDKEnabled) if (!s_LowLatencySDKEnabled || !s_LowLatencyAvailable)
return false; return false;
const MaterialAdapterInfo_t& adapterInfo = g_pMaterialAdapterMgr->GetAdapterInfo(); const MaterialAdapterInfo_t& adapterInfo = g_pMaterialAdapterMgr->GetAdapterInfo();
@ -42,6 +44,23 @@ bool GeForce_IsLowLatencySDKEnabled(void)
return adapterInfo.m_VendorID == NVIDIA_VENDOR_ID; return adapterInfo.m_VendorID == NVIDIA_VENDOR_ID;
} }
//-----------------------------------------------------------------------------
// Purpose: initialize the low latency SDK
//-----------------------------------------------------------------------------
bool GeForce_InitLowLatencySDK(void)
{
s_LowLatencyAvailable = true;
return s_LowLatencyAvailable;
}
//-----------------------------------------------------------------------------
// Purpose: shutdown the low latency SDK
//-----------------------------------------------------------------------------
void GeForce_ShutdownLowLatencySDK(void)
{
s_LowLatencyAvailable = false;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: mark the parameters as out-of-date; force update next frame // Purpose: mark the parameters as out-of-date; force update next frame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -126,7 +145,7 @@ void GeForce_SetLatencyMarker(IUnknown* const device,
{ {
Assert(device); Assert(device);
if (GeForce_ParameterUpdateWasSuccessful() && GeForce_IsLowLatencySDKEnabled()) if (GeForce_ParameterUpdateWasSuccessful() && GeForce_IsLowLatencySDKAvailable())
{ {
NV_LATENCY_MARKER_PARAMS params = {}; NV_LATENCY_MARKER_PARAMS params = {};
params.version = NV_LATENCY_MARKER_PARAMS_VER1; params.version = NV_LATENCY_MARKER_PARAMS_VER1;

View File

@ -4,7 +4,10 @@
extern bool g_PCLStatsAvailable; extern bool g_PCLStatsAvailable;
void GeForce_EnableLowLatencySDK(const bool enable); void GeForce_EnableLowLatencySDK(const bool enable);
bool GeForce_IsLowLatencySDKEnabled(void); bool GeForce_IsLowLatencySDKAvailable(void);
bool GeForce_InitLowLatencySDK(void);
void GeForce_ShutdownLowLatencySDK(void);
void GeForce_MarkLowLatencyParametersOutOfDate(void); void GeForce_MarkLowLatencyParametersOutOfDate(void);
bool GeForce_HasPendingLowLatencyParameterUpdates(void); bool GeForce_HasPendingLowLatencyParameterUpdates(void);

View File

@ -11,6 +11,7 @@
#include "rtech/pak/pakstate.h" #include "rtech/pak/pakstate.h"
#include "engine/cmodel_bsp.h" #include "engine/cmodel_bsp.h"
#include "engine/sys_engine.h" #include "engine/sys_engine.h"
#include "engine/sys_dll2.h"
#include "geforce/reflex.h" #include "geforce/reflex.h"
#include "radeon/antilag.h" #include "radeon/antilag.h"
#ifndef MATERIALSYSTEM_NODX #ifndef MATERIALSYSTEM_NODX
@ -61,9 +62,10 @@ InitReturnVal_t CMaterialSystem::Init(CMaterialSystem* thisptr)
if (s_useLowLatency) if (s_useLowLatency)
{ {
GeForce_InitLowLatencySDK();
Radeon_InitLowLatencySDK(); Radeon_InitLowLatencySDK();
PCLSTATS_INIT(0);
PCLSTATS_INIT(0);
g_PCLStatsAvailable = true; g_PCLStatsAvailable = true;
} }
@ -83,6 +85,7 @@ int CMaterialSystem::Shutdown(CMaterialSystem* thisptr)
PCLSTATS_SHUTDOWN(); PCLSTATS_SHUTDOWN();
Radeon_ShutdownLowLatencySDK(); Radeon_ShutdownLowLatencySDK();
GeForce_ShutdownLowLatencySDK();
} }
#endif #endif

View File

@ -28,6 +28,8 @@ void Radeon_EnableLowLatencySDK(const bool enable)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool Radeon_IsLowLatencySDKAvailable(void) bool Radeon_IsLowLatencySDKAvailable(void)
{ {
// NOTE: don't check on s_LowLatencySDKEnabled here as this needs to be
// provided to the driver itself.
if (!s_LowLatencyAvailable) if (!s_LowLatencyAvailable)
return false; return false;