mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Remove latency markers
Some parts of the engine have to be rebuild in order to implement this correctly, therefore, it has been removed for now to avoid potential performance problems. fps_max_rt and fps_max_gfx have been limited to 295 to avoid a contest with the engine's hard limit causing huge performance hits.
This commit is contained in:
parent
4927654da0
commit
907e582f55
@ -74,7 +74,6 @@ ConVar* r_visualizetraces_duration = nullptr;
|
||||
|
||||
ConVar* gfx_nvnUseLowLatency = nullptr;
|
||||
ConVar* gfx_nvnUseLowLatencyBoost = nullptr;
|
||||
ConVar* gfx_nvnUseMarkersToOptimize = nullptr;
|
||||
#endif // !DEDICATED
|
||||
|
||||
ConVar* stream_overlay = nullptr;
|
||||
@ -312,13 +311,12 @@ void ConVar_StaticInit(void)
|
||||
r_drawWorldMeshesDepthAtTheEnd = ConVar::StaticCreate("r_drawWorldMeshesDepthAtTheEnd", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth at the end).", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
||||
#ifndef DEDICATED
|
||||
fps_max_rt = ConVar::StaticCreate("fps_max_rt", "0", FCVAR_RELEASE, "Frame rate limiter within the render thread. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, false, 0.f, nullptr, nullptr);
|
||||
fps_max_rt = ConVar::StaticCreate("fps_max_rt", "0", FCVAR_RELEASE, "Frame rate limiter within the render thread. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, true, 295.f, nullptr, nullptr);
|
||||
fps_max_rt_tolerance = ConVar::StaticCreate("fps_max_rt_tolerance", "0.25", FCVAR_RELEASE, "Maximum amount of frame time before frame limiter restarts.", true, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
||||
fps_max_gfx = ConVar::StaticCreate("fps_max_gfx", "0", FCVAR_RELEASE, "Frame rate limiter using NVIDIA Reflex Low Latency SDK. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, false, 0.f, &GFX_NVN_Changed_f, nullptr);
|
||||
fps_max_gfx = ConVar::StaticCreate("fps_max_gfx", "0", FCVAR_RELEASE, "Frame rate limiter using NVIDIA Reflex Low Latency SDK. -1 indicates use the desktop refresh. 0 is disabled.", true, -1.f, true, 295.f, &GFX_NVN_Changed_f, nullptr);
|
||||
gfx_nvnUseLowLatency = ConVar::StaticCreate("gfx_nvnUseLowLatency" , "1", FCVAR_RELEASE | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency SDK." , false, 0.f, false, 0.f, &GFX_NVN_Changed_f, nullptr);
|
||||
gfx_nvnUseLowLatencyBoost = ConVar::StaticCreate("gfx_nvnUseLowLatencyBoost", "1", FCVAR_RELEASE | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency Boost.", false, 0.f, false, 0.f, &GFX_NVN_Changed_f, nullptr);
|
||||
gfx_nvnUseMarkersToOptimize = ConVar::StaticCreate("gfx_nvnUseMarkersToOptimize", "1", FCVAR_RELEASE | FCVAR_ARCHIVE, "Enables NVIDIA Reflex Low Latency Timing.", false, 0.f, false, 0.f, &GFX_NVN_Changed_f, nullptr);
|
||||
#endif // !DEDICATED
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -65,7 +65,6 @@ extern ConVar* r_visualizetraces_duration;
|
||||
|
||||
extern ConVar* gfx_nvnUseLowLatency;
|
||||
extern ConVar* gfx_nvnUseLowLatencyBoost;
|
||||
extern ConVar* gfx_nvnUseMarkersToOptimize;
|
||||
#endif // !DEDICATED
|
||||
|
||||
extern ConVar* stream_overlay;
|
||||
|
@ -23,15 +23,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHLClient::FrameStageNotify(CHLClient* pHLClient, ClientFrameStage_t frameStage)
|
||||
{
|
||||
// Must be performed before the call, before scene starts rendering.
|
||||
if (frameStage == ClientFrameStage_t::FRAME_RENDER_START)
|
||||
GFX_SetLatencyMarker(D3D11Device(), RENDERSUBMIT_START);
|
||||
|
||||
CHLClient_FrameStageNotify(pHLClient, frameStage);
|
||||
|
||||
// Must be performed after the call, after the scene has been rendered.
|
||||
if (frameStage == ClientFrameStage_t::FRAME_RENDER_END)
|
||||
GFX_SetLatencyMarker(D3D11Device(), RENDERSUBMIT_END);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -16,11 +16,6 @@
|
||||
static float s_lastMovementCall = 0.0;
|
||||
static float s_LastFrameTime = 0.0;
|
||||
|
||||
// The game supports sending multiple movement frames per simulation tick,
|
||||
// therefore we need to track when the last call was, and make sure we only
|
||||
// call these latency markers once per engine frame.
|
||||
static int s_LastMovementReflexFrame = -1;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: run client's movement frame
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -146,30 +141,12 @@ void CL_MoveEx()
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: hook and run latency markers before simulation
|
||||
//-----------------------------------------------------------------------------
|
||||
void H_CL_Move()
|
||||
{
|
||||
int currentReflexFrame = GFX_GetFrameNumber();
|
||||
|
||||
if (currentReflexFrame != s_LastMovementReflexFrame)
|
||||
GFX_SetLatencyMarker(D3D11Device(), SIMULATION_START);
|
||||
|
||||
CL_MoveEx();
|
||||
|
||||
if (currentReflexFrame != s_LastMovementReflexFrame)
|
||||
GFX_SetLatencyMarker(D3D11Device(), SIMULATION_END);
|
||||
|
||||
s_LastMovementReflexFrame = currentReflexFrame;
|
||||
}
|
||||
|
||||
void VCL_Main::Attach() const
|
||||
{
|
||||
DetourAttach(&CL_Move, &H_CL_Move);
|
||||
DetourAttach(&CL_Move, &CL_MoveEx);
|
||||
}
|
||||
|
||||
void VCL_Main::Detach() const
|
||||
{
|
||||
DetourDetach(&CL_Move, &H_CL_Move);
|
||||
DetourDetach(&CL_Move, &CL_MoveEx);
|
||||
}
|
||||
|
@ -45,27 +45,6 @@ void CFrameLimit::Reset(double targetFps)
|
||||
m_Frames = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: halts the thread until the next vertical blank occurs
|
||||
// Output : true on success, false otherwise
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CFrameLimit::WaitForVBlank(void)
|
||||
{
|
||||
IDXGIOutput* dxgiOutput;
|
||||
IDXGISwapChain* swapChain = D3D11SwapChain();
|
||||
|
||||
if (swapChain != nullptr &&
|
||||
SUCCEEDED(swapChain->GetContainingOutput(&dxgiOutput)))
|
||||
{
|
||||
DwmFlush();
|
||||
dxgiOutput->WaitForVBlank();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: runs the frame limiter logic
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -113,23 +92,19 @@ void CFrameLimit::Run(void)
|
||||
//return;
|
||||
}
|
||||
|
||||
ID3D11Device* pDevice = D3D11Device();
|
||||
m_Next.QuadPart = (LONGLONG)((m_Start.QuadPart + (double)m_Frames * (m_MilliSeconds / 1000.0) * (double)g_pPerformanceFrequency->QuadPart));
|
||||
|
||||
if (m_Next.QuadPart > 0ULL)
|
||||
{
|
||||
while (m_Time.QuadPart < m_Next.QuadPart)
|
||||
{
|
||||
if ((double)(m_Next.QuadPart - m_Time.QuadPart) > (0.016666666667 * (double)g_pPerformanceFrequency->QuadPart))
|
||||
if ((double)(m_Next.QuadPart - m_Time.QuadPart) > (0.0166667 * (double)g_pPerformanceFrequency->QuadPart))
|
||||
{
|
||||
WaitForVBlank();
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
QueryPerformanceCounter(&m_Time);
|
||||
}
|
||||
|
||||
if (pDevice != nullptr)
|
||||
D3D11Device()->Release();
|
||||
}
|
||||
|
||||
//m_Last.QuadPart = m_Time.QuadPart;
|
||||
|
@ -11,7 +11,6 @@ public:
|
||||
|
||||
void Reset(double target);
|
||||
void Run(void);
|
||||
bool WaitForVBlank(void);
|
||||
|
||||
private:
|
||||
double m_MilliSeconds;
|
||||
|
@ -161,25 +161,6 @@ void CEngineAPI::VSetStartupInfo(CEngineAPI* pEngineAPI, StartupInfo_t* pStartup
|
||||
void CEngineAPI::PumpMessages()
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
// Message pump partially rebuild from the engine, this has to be done here
|
||||
// as we need to call the LATENCY_PING marker once we wee a message.
|
||||
MSG msg;
|
||||
bool ping = false;
|
||||
|
||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
|
||||
if (!ping)
|
||||
ping = true;
|
||||
}
|
||||
|
||||
if (ping)
|
||||
GFX_SetLatencyMarker(D3D11Device(), PC_LATENCY_PING);
|
||||
|
||||
// Run original, note that the message peek logic has been moved to this
|
||||
// function!!!
|
||||
CEngineAPI_PumpMessages();
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
@ -206,7 +187,6 @@ bool CEngineAPI::MainLoop()
|
||||
{
|
||||
const bool bUseLowLatencyMode = gfx_nvnUseLowLatency->GetBool();
|
||||
const bool bUseLowLatencyBoost = gfx_nvnUseLowLatencyBoost->GetBool();
|
||||
const bool bUseLowLatencyTiming = gfx_nvnUseMarkersToOptimize->GetBool();
|
||||
|
||||
float fpsMax = fps_max_gfx->GetFloat();
|
||||
|
||||
@ -225,7 +205,7 @@ bool CEngineAPI::MainLoop()
|
||||
}
|
||||
|
||||
GFX_UpdateLowLatencyParameters(D3D11Device(), bUseLowLatencyMode,
|
||||
bUseLowLatencyBoost, bUseLowLatencyTiming, fpsMax);
|
||||
bUseLowLatencyBoost, false, fpsMax);
|
||||
}
|
||||
|
||||
GFX_RunLowLatencyFrame(D3D11Device());
|
||||
|
@ -145,12 +145,7 @@ HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT n
|
||||
DrawImGui();
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO[ AMOS ]: Profile performance by placing the marker before and after the
|
||||
// frame limit call!!!
|
||||
GFX_SetLatencyMarker(D3D11Device(), PRESENT_START);
|
||||
HRESULT result = s_fnSwapChainPresent(pSwapChain, nSyncInterval, nFlags);
|
||||
|
||||
GFX_SetLatencyMarker(D3D11Device(), PRESENT_END);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user