Prevent low vsync fps from slowing tick under old 20ms
This commit is contained in:
@@ -540,7 +540,18 @@ void OverlayController::OnTimeoutPumpEvents()
|
|||||||
|
|
||||||
// wait for the next frame after executing our main event loop once.
|
// wait for the next frame after executing our main event loop once.
|
||||||
m_lastFrame = m_currentFrame;
|
m_lastFrame = m_currentFrame;
|
||||||
|
m_vsyncTooLateCounter = 0;
|
||||||
}
|
}
|
||||||
|
else if ( m_vsyncTooLateCounter >= k_nonVsyncTickRate )
|
||||||
|
{
|
||||||
|
mainEventLoop();
|
||||||
|
// m_lastFrame = m_currentFrame + 1 skips the next vsync frame in case
|
||||||
|
// it was just about to trigger, to prevent double updates faster than
|
||||||
|
// 11ms.
|
||||||
|
m_lastFrame = m_currentFrame + 1;
|
||||||
|
m_vsyncTooLateCounter = 0;
|
||||||
|
}
|
||||||
|
m_vsyncTooLateCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::mainEventLoop()
|
void OverlayController::mainEventLoop()
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ constexpr int k_reviveSettingsUpdateCounter = 139;
|
|||||||
constexpr int k_settingsTabSettingsUpdateCounter = 157;
|
constexpr int k_settingsTabSettingsUpdateCounter = 157;
|
||||||
constexpr int k_steamVrSettingsUpdateCounter = 97;
|
constexpr int k_steamVrSettingsUpdateCounter = 97;
|
||||||
constexpr int k_utilitiesSettingsUpdateCounter = 19;
|
constexpr int k_utilitiesSettingsUpdateCounter = 19;
|
||||||
|
// k_nonVsyncTickRate determines number of ms we wait to force the next event
|
||||||
|
// loop tick when vsync is too late due to dropped frames.
|
||||||
|
constexpr int k_nonVsyncTickRate = 20;
|
||||||
|
|
||||||
class OverlayController : public QObject
|
class OverlayController : public QObject
|
||||||
{
|
{
|
||||||
@@ -102,6 +105,7 @@ private:
|
|||||||
|
|
||||||
uint64_t m_currentFrame = 0;
|
uint64_t m_currentFrame = 0;
|
||||||
uint64_t m_lastFrame = 0;
|
uint64_t m_lastFrame = 0;
|
||||||
|
int m_vsyncTooLateCounter = 0;
|
||||||
|
|
||||||
// OpenVR_Init must be declared before any other class that uses OpenVR
|
// OpenVR_Init must be declared before any other class that uses OpenVR
|
||||||
// function calls since objects are initialized in order of declaration in
|
// function calls since objects are initialized in order of declaration in
|
||||||
|
|||||||
Reference in New Issue
Block a user