NVIDIA: add PC_LATENCY_PING marker to msg pump

This commit is contained in:
Kawe Mazidjatari 2023-12-24 20:38:50 +01:00
parent aa1a43ac4f
commit 0e62280896
2 changed files with 35 additions and 3 deletions

View File

@ -6,6 +6,8 @@
#include "core/stdafx.h"
#include "vpc/IAppSystem.h"
#include "windows/id3dx.h"
#include "geforce/reflex.h"
#include "inputsystem/inputsystem.h"
////-----------------------------------------------------------------------------
@ -49,6 +51,27 @@
// return CallVFunc<ButtonCode_t>(index, this, pString);
//}
LRESULT CInputSystem::WindowProc(void* unused, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (g_pInputSystem->m_bEnabled &&
((hwnd == g_pInputSystem->m_hAttachedHWnd) || (uMsg == WM_ACTIVATEAPP)) &&
(uMsg != WM_CLOSE))
{
if (PCLSTATS_IS_PING_MSG_ID(uMsg))
{
GFX_SetLatencyMarker(D3D11Device(), PC_LATENCY_PING);
}
}
return v_CInputSystem__WindowProc(unused, hwnd, uMsg, wParam, lParam);
}
void VInputSystem::Detour(const bool bAttach) const
{
DetourSetup(&v_CInputSystem__WindowProc, &CInputSystem::WindowProc, bAttach);
}
///////////////////////////////////////////////////////////////////////////////
CInputSystem* g_pInputSystem = nullptr;
bool(**g_fnSyncRTWithIn)(void) = nullptr;

View File

@ -11,6 +11,9 @@ class CInputSystem : public CTier1AppSystem< IInputSystem >
{
public:
// !!!interface implemented in engine!!!
public:
// Hook statics:
static LRESULT WindowProc(void* unused, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
enum
@ -162,18 +165,24 @@ private:
static_assert(sizeof(CInputSystem) == 0x18E8);
///////////////////////////////////////////////////////////////////////////////
inline LRESULT (*v_CInputSystem__WindowProc)(void* thisptr, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern CInputSystem* g_pInputSystem;
extern bool(**g_fnSyncRTWithIn)(void); // Belongs to an array of callbacks, see CMaterialSystem::MatsysMode_Init().
extern bool(**g_fnSyncRTWithIn)(void); // Belongs to an array of functions, see CMaterialSystem::MatsysMode_Init().
///////////////////////////////////////////////////////////////////////////////
class VInputSystem : public IDetour
{
virtual void GetAdr(void) const
{
LogFunAdr("CInputSystem::WindowProc", reinterpret_cast<uintptr_t>(v_CInputSystem__WindowProc));
LogVarAdr("g_pInputSystem", reinterpret_cast<uintptr_t>(g_pInputSystem));
LogVarAdr("g_fnSyncRTWithIn", reinterpret_cast<uintptr_t>(g_fnSyncRTWithIn));
}
virtual void GetFun(void) const { }
virtual void GetFun(void) const
{
g_GameDll.FindPatternSIMD("48 89 4C 24 ?? 55 56 41 54 41 55 48 83 EC 48", v_CInputSystem__WindowProc);
}
virtual void GetVar(void) const
{
g_pInputSystem = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 85 C9 74 11")
@ -183,6 +192,6 @@ class VInputSystem : public IDetour
g_fnSyncRTWithIn = l_EngineApi_PumpMessages.FindPattern("74 06").FindPatternSelf("FF 15").ResolveRelativeAddressSelf(2, 6).RCast<bool(**)(void)>();
}
virtual void GetCon(void) const { }
virtual void Detour(const bool bAttach) const { }
virtual void Detour(const bool bAttach) const;
};
///////////////////////////////////////////////////////////////////////////////