mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Bugfix: only run NVIDIA Reflex if we ran an actual engine frame
CEngine::Frame() tends to return out early if we are ahead of frame time, and therefore need to sleep. In this particular engine, CEngine::Frame() returns true if it had actually executed an engine frame, else it returns false. Therefore, we end up calling 'NvAPI_D3D_Sleep()' multiple times a frame, and thus causing a major loss in performance. Now we check if we have actually ran a frame (incrementing reflex frame if so). If the frame was not incremented, but 'GFX_RunLowLatencyFrame()' was called, it will not call 'NvAPI_D3D_Sleep()'. Code has been tested and appears to work on my system (never called twice or more per frame). Needs more testing on other systems to make sure its good.
This commit is contained in:
parent
c8dea8927c
commit
4927654da0
@ -232,7 +232,13 @@ bool CEngineAPI::MainLoop()
|
||||
CEngineAPI::PumpMessages();
|
||||
#endif // !DEDICATED
|
||||
|
||||
g_pEngine->Frame();
|
||||
if (g_pEngine->Frame())
|
||||
{
|
||||
#ifndef DEDICATED
|
||||
// Only increment frame number if we ran an actual engine frame.
|
||||
GFX_IncrementFrameNumber();
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,8 @@ bool s_ReflexModeInfoUpToDate = false;
|
||||
NvAPI_Status s_ReflexModeUpdateStatus = NvAPI_Status::NVAPI_OK;
|
||||
|
||||
// Static frame number counter for latency markers.
|
||||
int s_ReflexFrameNumber = -1;
|
||||
int s_ReflexFrameNumber = 0;
|
||||
int s_ReflexLastFrameNumber = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: mark the parameters as out-of-date; force update next frame
|
||||
@ -105,10 +106,15 @@ void GFX_UpdateLowLatencyParameters(IUnknown* device, const bool useLowLatencyMo
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFX_RunLowLatencyFrame(IUnknown* device)
|
||||
{
|
||||
GFX_IncrementFrameNumber();
|
||||
int currentFrameNumber = GFX_GetFrameNumber();
|
||||
|
||||
if (s_ReflexLastFrameNumber == currentFrameNumber)
|
||||
return;
|
||||
|
||||
if (GFX_ParameterUpdateWasSuccessful())
|
||||
NvAPI_D3D_Sleep(device);
|
||||
|
||||
s_ReflexLastFrameNumber = currentFrameNumber;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -5,6 +5,7 @@ void GFX_MarkLowLatencyParametersOutOfDate(void);
|
||||
bool GFX_HasPendingLowLatencyParameterUpdates(void);
|
||||
|
||||
int GFX_GetFrameNumber(void);
|
||||
void GFX_IncrementFrameNumber(void);
|
||||
|
||||
void GFX_UpdateLowLatencyParameters(IUnknown* device, const bool useLowLatencyMode,
|
||||
const bool useLowLatencyBoost, const bool useMarkersToOptimize,
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
virtual void SetNextState(EngineState_t iNextState) = 0;
|
||||
virtual EngineState_t GetState(void) = 0;
|
||||
|
||||
virtual void Frame(void) = 0;
|
||||
virtual bool Frame(void) = 0; // Returns true if an engine frame is being ran.
|
||||
virtual float GetFrameTime(void) = 0;
|
||||
virtual float GetPreviousTime(void) = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user