mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
NVIDIA: check if adapter is from NVIDIA in GFX_SetLatencyMarker()
Moved adapter vendor check to its own func, added a global which could be used to fully disable the low latency system. Also added groundwork for the (future) PCL stats implementation.
This commit is contained in:
parent
82c522a424
commit
51b866f6a1
@ -184,11 +184,7 @@ bool CEngineAPI::MainLoop()
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
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)
|
||||
if (GFX_IsLowLatencySDKEnabled())
|
||||
{
|
||||
if (GFX_HasPendingLowLatencyParameterUpdates())
|
||||
{
|
||||
|
@ -5,6 +5,9 @@
|
||||
//===========================================================================//
|
||||
#include "reflex.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "materialsystem/cmaterialsystem.h"
|
||||
|
||||
static bool s_LowLatencySDKEnabled = false;
|
||||
|
||||
// If false, the system will call 'NvAPI_D3D_SetSleepMode' to update the parameters.
|
||||
bool s_ReflexModeInfoUpToDate = false;
|
||||
@ -17,6 +20,29 @@ NvAPI_Status s_ReflexModeUpdateStatus = NvAPI_Status::NVAPI_OK;
|
||||
NvU64 s_ReflexFrameNumber = 0;
|
||||
NvU64 s_ReflexLastFrameNumber = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: enable/disable low latency SDK
|
||||
// Input : enable -
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFX_EnableLowLatencySDK(const bool enable)
|
||||
{
|
||||
s_LowLatencySDKEnabled = enable;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: whether we should run the low latency SDK
|
||||
//-----------------------------------------------------------------------------
|
||||
bool GFX_IsLowLatencySDKEnabled(void)
|
||||
{
|
||||
if (!s_LowLatencySDKEnabled)
|
||||
return false;
|
||||
|
||||
const MaterialAdapterInfo_t& adapterInfo = g_pMaterialAdapterMgr->GetAdapterInfo();
|
||||
// Only run on NVIDIA display drivers; AMD and Intel are not
|
||||
// supported by NVIDIA Reflex.
|
||||
return adapterInfo.m_VendorID == NVIDIA_VENDOR_ID;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: mark the parameters as out-of-date; force update next frame
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -101,6 +127,7 @@ void GFX_UpdateLowLatencyParameters(IUnknown* device, const bool useLowLatencyMo
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFX_RunLowLatencyFrame(IUnknown* device)
|
||||
{
|
||||
Assert(device);
|
||||
const NvU64 currentFrameNumber = GFX_GetFrameNumber();
|
||||
|
||||
if (s_ReflexLastFrameNumber == currentFrameNumber)
|
||||
@ -121,15 +148,15 @@ void GFX_RunLowLatencyFrame(IUnknown* device)
|
||||
void GFX_SetLatencyMarker(IUnknown* device,
|
||||
const NV_LATENCY_MARKER_TYPE markerType)
|
||||
{
|
||||
// TODO[ AMOS ]: should we keep calling this, even when the call to
|
||||
// 'NvAPI_D3D_SetSleepMode(...)' has failed?
|
||||
if (GFX_ParameterUpdateWasSuccessful())
|
||||
{
|
||||
NV_LATENCY_MARKER_PARAMS params = {};
|
||||
params.version = NV_LATENCY_MARKER_PARAMS_VER1;
|
||||
params.frameID = s_ReflexFrameNumber;
|
||||
params.markerType = markerType;
|
||||
Assert(device);
|
||||
|
||||
NvAPI_D3D_SetLatencyMarker(device, ¶ms);
|
||||
}
|
||||
if (!GFX_IsLowLatencySDKEnabled())
|
||||
return;
|
||||
|
||||
NV_LATENCY_MARKER_PARAMS params = {};
|
||||
params.version = NV_LATENCY_MARKER_PARAMS_VER1;
|
||||
params.frameID = s_ReflexFrameNumber;
|
||||
params.markerType = markerType;
|
||||
|
||||
NvAPI_D3D_SetLatencyMarker(device, ¶ms);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
#ifndef GFSDK_REFLEX_H
|
||||
#define GFSDK_REFLEX_H
|
||||
|
||||
void GFX_EnableLowLatencySDK(const bool enable);
|
||||
bool GFX_IsLowLatencySDKEnabled(void);
|
||||
|
||||
void GFX_MarkLowLatencyParametersOutOfDate(void);
|
||||
bool GFX_HasPendingLowLatencyParameterUpdates(void);
|
||||
|
||||
|
@ -5,15 +5,21 @@
|
||||
//===========================================================================//
|
||||
#include "core/stdafx.h"
|
||||
#include "tier0/crashhandler.h"
|
||||
#include "tier0/commandline.h"
|
||||
#include "tier1/cvar.h"
|
||||
#include "vpc/keyvalues.h"
|
||||
#include "rtech/rtech_utils.h"
|
||||
#include "engine/cmodel_bsp.h"
|
||||
#include "geforce/reflex.h"
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
#include "materialsystem/cmaterialglue.h"
|
||||
#endif // !MATERIALSYSTEM_NODX
|
||||
#include "materialsystem/cmaterialsystem.h"
|
||||
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
//PCLSTATS_DEFINE()
|
||||
#endif // MATERIALSYSTEM_NODX
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: initialization of the material system
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -30,10 +36,30 @@ InitReturnVal_t CMaterialSystem::Init(CMaterialSystem* thisptr)
|
||||
return INIT_FAILED;
|
||||
#else
|
||||
// Initialize as usual.
|
||||
GFX_EnableLowLatencySDK(!CommandLine()->CheckParm("-gfx_nvnDisableLowLatency"));
|
||||
|
||||
//if (GFX_IsLowLatencySDKEnabled())
|
||||
//{
|
||||
// PCLSTATS_INIT(0);
|
||||
//}
|
||||
|
||||
return CMaterialSystem__Init(thisptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: shutdown of the material system
|
||||
//-----------------------------------------------------------------------------
|
||||
int CMaterialSystem::Shutdown(CMaterialSystem* thisptr)
|
||||
{
|
||||
//if (GFX_IsLowLatencySDKEnabled())
|
||||
//{
|
||||
// PCLSTATS_SHUTDOWN();
|
||||
//}
|
||||
|
||||
return CMaterialSystem__Shutdown(thisptr);
|
||||
}
|
||||
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: loads and processes STBSP files
|
||||
@ -124,6 +150,7 @@ Vector2D CMaterialSystem::GetScreenSize(CMaterialSystem* pMatSys)
|
||||
void VMaterialSystem::Detour(const bool bAttach) const
|
||||
{
|
||||
DetourSetup(&CMaterialSystem__Init, &CMaterialSystem::Init, bAttach);
|
||||
DetourSetup(&CMaterialSystem__Shutdown, &CMaterialSystem::Shutdown, bAttach);
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
DetourSetup(&v_StreamDB_Init, &StreamDB_Init, bAttach);
|
||||
DetourSetup(&v_DispatchDrawCall, &DispatchDrawCall, bAttach);
|
||||
|
@ -9,6 +9,7 @@ class CMaterialSystem
|
||||
{
|
||||
public:
|
||||
static InitReturnVal_t Init(CMaterialSystem* thisptr);
|
||||
static int Shutdown(CMaterialSystem* thisptr);
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
static CMaterialGlue* FindMaterialEx(CMaterialSystem* pMatSys, const char* pMaterialName, uint8_t nMaterialType, int nUnk, bool bComplain);
|
||||
static Vector2D GetScreenSize(CMaterialSystem* pMatSys = nullptr);
|
||||
@ -52,6 +53,9 @@ inline CMaterialDeviceMgr* g_pMaterialAdapterMgr = nullptr;
|
||||
inline CMemory p_CMaterialSystem__Init;
|
||||
inline InitReturnVal_t(*CMaterialSystem__Init)(CMaterialSystem* thisptr);
|
||||
|
||||
inline CMemory p_CMaterialSystem__Shutdown;
|
||||
inline int(*CMaterialSystem__Shutdown)(CMaterialSystem* thisptr);
|
||||
|
||||
inline CMemory p_CMaterialSystem__Disconnect;
|
||||
inline void(*CMaterialSystem__Disconnect)(void);
|
||||
|
||||
@ -91,6 +95,7 @@ class VMaterialSystem : public IDetour
|
||||
{
|
||||
LogConAdr("CMaterial::`vftable'", reinterpret_cast<uintptr_t>(g_pMaterialVFTable));
|
||||
LogFunAdr("CMaterialSystem::Init", p_CMaterialSystem__Init.GetPtr());
|
||||
LogFunAdr("CMaterialSystem::Shutdown", p_CMaterialSystem__Shutdown.GetPtr());
|
||||
LogFunAdr("CMaterialSystem::Disconnect", p_CMaterialSystem__Disconnect.GetPtr());
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
LogFunAdr("CMaterialSystem::FindMaterialEx", p_CMaterialSystem__FindMaterialEx.GetPtr());
|
||||
@ -111,6 +116,9 @@ class VMaterialSystem : public IDetour
|
||||
p_CMaterialSystem__Init = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??");
|
||||
CMaterialSystem__Init = p_CMaterialSystem__Init.RCast<InitReturnVal_t(*)(CMaterialSystem*)>(); /*48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??*/
|
||||
|
||||
p_CMaterialSystem__Shutdown = g_GameDll.FindPatternSIMD("48 83 EC 58 48 89 6C 24 ??");
|
||||
CMaterialSystem__Shutdown = p_CMaterialSystem__Shutdown.RCast<int(*)(CMaterialSystem*)>(); /*48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 70 48 83 3D ?? ?? ?? ?? ??*/
|
||||
|
||||
p_CMaterialSystem__Disconnect = g_GameDll.FindPatternSIMD("48 83 EC 28 8B 0D ?? ?? ?? ?? 48 89 6C 24 ??");
|
||||
CMaterialSystem__Disconnect = p_CMaterialSystem__Disconnect.RCast<void(*)(void)>();
|
||||
#ifndef MATERIALSYSTEM_NODX
|
||||
|
Loading…
x
Reference in New Issue
Block a user