From eaa5347fa31670749c5f9b0ff16d2c1c8e744d27 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:24:59 +0200 Subject: [PATCH] Only run NVIDIA Reflex if the display driver vendor is NVIDIA This is to ensure we don't cause any performance hits when running the game on an AMD or Intel GPU. --- r5dev/engine/sys_dll2.cpp | 47 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/r5dev/engine/sys_dll2.cpp b/r5dev/engine/sys_dll2.cpp index a878d759..0a8317c2 100644 --- a/r5dev/engine/sys_dll2.cpp +++ b/r5dev/engine/sys_dll2.cpp @@ -17,6 +17,7 @@ #include "engine/traceinit.h" #ifndef DEDICATED #include "engine/sys_mainwind.h" +#include "materialsystem/cmaterialsystem.h" #include "windows/id3dx.h" #include "client/vengineclient_impl.h" #include "geforce/reflex.h" @@ -183,32 +184,40 @@ bool CEngineAPI::MainLoop() } #ifndef DEDICATED - if (GFX_HasPendingLowLatencyParameterUpdates()) + const MaterialAdapterInfo_t& adapterInfo = g_pMaterialAdapterMgr->GetAdapterInfo(); + + // Only run on NVIDIA display drivers; AMD and Intel are not + // supported by NVIDIA Reflex. + if (adapterInfo.m_VendorID == NVIDIA_VENDOR_ID) { - const bool bUseLowLatencyMode = gfx_nvnUseLowLatency->GetBool(); - const bool bUseLowLatencyBoost = gfx_nvnUseLowLatencyBoost->GetBool(); - - float fpsMax = fps_max_gfx->GetFloat(); - - if (fpsMax == -1.0f) + if (GFX_HasPendingLowLatencyParameterUpdates()) { - const float globalFps = fps_max->GetFloat(); + const bool bUseLowLatencyMode = gfx_nvnUseLowLatency->GetBool(); + const bool bUseLowLatencyBoost = gfx_nvnUseLowLatencyBoost->GetBool(); - // Make sure the global fps limiter is 'unlimited' - // before we let the gfx frame limiter cap it to - // the desktop's refresh rate; not adhering to - // this will result in a major performance drop. - if (globalFps == 0.0f) - fpsMax = g_pGame->GetTVRefreshRate(); - else - fpsMax = 0.0f; // Don't let NVIDIA limit the frame rate. + float fpsMax = fps_max_gfx->GetFloat(); + + if (fpsMax == -1.0f) + { + const float globalFps = fps_max->GetFloat(); + + // Make sure the global fps limiter is 'unlimited' + // before we let the gfx frame limiter cap it to + // the desktop's refresh rate; not adhering to + // this will result in a major performance drop. + if (globalFps == 0.0f) + fpsMax = g_pGame->GetTVRefreshRate(); + else + fpsMax = 0.0f; // Don't let NVIDIA limit the frame rate. + } + + GFX_UpdateLowLatencyParameters(D3D11Device(), bUseLowLatencyMode, + bUseLowLatencyBoost, false, fpsMax); } - GFX_UpdateLowLatencyParameters(D3D11Device(), bUseLowLatencyMode, - bUseLowLatencyBoost, false, fpsMax); + GFX_RunLowLatencyFrame(D3D11Device()); } - GFX_RunLowLatencyFrame(D3D11Device()); CEngineAPI::PumpMessages(); #endif // !DEDICATED