From ebd89d934fb7bed21cf2d9707bf905b701cb2a2c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 15 Sep 2024 12:45:26 +0200 Subject: [PATCH] NVIDIA: only run and shutdown PCL stats if it has been initialized --- src/geforce/reflex.cpp | 10 ++++++++-- src/geforce/reflex.h | 2 ++ src/materialsystem/cmaterialsystem.cpp | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/geforce/reflex.cpp b/src/geforce/reflex.cpp index 3fa593dc..f157be08 100644 --- a/src/geforce/reflex.cpp +++ b/src/geforce/reflex.cpp @@ -16,6 +16,9 @@ static bool s_ReflexModeInfoUpToDate = false; // If not, the Low Latency SDK will not run. static NvAPI_Status s_ReflexModeUpdateStatus = NvAPI_Status::NVAPI_OK; +// True if the PCL stats system was initialized. +bool g_PCLStatsAvailable = false; + //----------------------------------------------------------------------------- // Purpose: enable/disable low latency SDK // Input : enable - @@ -133,6 +136,9 @@ void GeForce_SetLatencyMarker(IUnknown* const device, NvAPI_D3D_SetLatencyMarker(device, ¶ms); } - // PCLStats runs separately and is supported on non-NVIDIA hardware. - PCLSTATS_MARKER(markerType, frameID); + if (g_PCLStatsAvailable) + { + // PCLStats runs separately and is supported on non-NVIDIA hardware. + PCLSTATS_MARKER(markerType, frameID); + } } diff --git a/src/geforce/reflex.h b/src/geforce/reflex.h index 567be185..696f745d 100644 --- a/src/geforce/reflex.h +++ b/src/geforce/reflex.h @@ -1,6 +1,8 @@ #ifndef GFSDK_REFLEX_H #define GFSDK_REFLEX_H +extern bool g_PCLStatsAvailable; + void GeForce_EnableLowLatencySDK(const bool enable); bool GeForce_IsLowLatencySDKEnabled(void); diff --git a/src/materialsystem/cmaterialsystem.cpp b/src/materialsystem/cmaterialsystem.cpp index eb9d375e..158705f4 100644 --- a/src/materialsystem/cmaterialsystem.cpp +++ b/src/materialsystem/cmaterialsystem.cpp @@ -63,6 +63,8 @@ InitReturnVal_t CMaterialSystem::Init(CMaterialSystem* thisptr) { Radeon_InitLowLatencySDK(); PCLSTATS_INIT(0); + + g_PCLStatsAvailable = true; } return CMaterialSystem__Init(thisptr); @@ -77,7 +79,9 @@ int CMaterialSystem::Shutdown(CMaterialSystem* thisptr) #ifndef MATERIALSYSTEM_NODX if (s_useLowLatency) { - PCLSTATS_SHUTDOWN(); + if (g_PCLStatsAvailable) + PCLSTATS_SHUTDOWN(); + Radeon_ShutdownLowLatencySDK(); } #endif