r5sdk/r5dev/engine/framelimit.h
Kawe Mazidjatari 07dade5d5d Implement high precision frame limiter
Limits frames at a much higher level of precision than 'fps_max' and 'fps_max_gfx', probably ideal to reduce input latency even more. Also changed the logic of the NVIDIA Reflex frame limiter, to which it would use the desktop's refresh rate if set to '-1'. The new render thread frame limiter has a similar behavior. Using desktop refresh rates on the render thread or NVIDIA Reflex frame limiter requires 'fps_max' to be set to 0 (unlimited), as it would otherwise result in a major performance drop due to a contest if fps_max_(gfx/rt) is set to a similar number as fps_max.
2023-09-11 22:20:24 +02:00

32 lines
647 B
C++

#ifndef FRAMELIMIT_H
#define FRAMELIMIT_H
//-----------------------------------------------------------------------------
// RenderThread frame limiter
//-----------------------------------------------------------------------------
class CFrameLimit
{
public:
CFrameLimit(void);
void Reset(double target);
void Run(void);
bool WaitForVBlank(void);
private:
double m_MilliSeconds;
double m_FramesPerSecond;
//double m_EffectiveMilliSeconds;
//LARGE_INTEGER m_Last;
LARGE_INTEGER m_Start;
LARGE_INTEGER m_Next;
LARGE_INTEGER m_Time;
uint32_t m_Frames;
bool m_bRestart;
};
extern CFrameLimit g_FrameLimiter;
#endif // FRAMELIMIT_H