Cache verified customMsTickRate
The `customTickRateMs()` function is being called every millisecond, adding the verification to every call leads to unnecessary overhead. The tick rate is verified when loading and when saving.
This commit is contained in:
+21
-18
@@ -29,10 +29,27 @@ namespace advsettings
|
|||||||
{
|
{
|
||||||
QSettings* OverlayController::_appSettings = nullptr;
|
QSettings* OverlayController::_appSettings = nullptr;
|
||||||
|
|
||||||
|
int verifyCustomTickRate( const int tickRate )
|
||||||
|
{
|
||||||
|
if ( tickRate < 1 )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( tickRate > k_maxCustomTickRate )
|
||||||
|
{
|
||||||
|
return k_maxCustomTickRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tickRate;
|
||||||
|
}
|
||||||
|
|
||||||
OverlayController::OverlayController( bool desktopMode,
|
OverlayController::OverlayController( bool desktopMode,
|
||||||
bool noSound,
|
bool noSound,
|
||||||
QQmlEngine& qmlEngine )
|
QQmlEngine& qmlEngine )
|
||||||
: QObject(), m_desktopMode( desktopMode ), m_noSound( noSound ), m_actions()
|
: QObject(), m_desktopMode( desktopMode ), m_noSound( noSound ),
|
||||||
|
m_verifiedCustomTickRateMs( verifyCustomTickRate( settings::getSetting(
|
||||||
|
settings::IntSetting::APPLICATION_customTickRateMs ) ) ),
|
||||||
|
m_actions()
|
||||||
{
|
{
|
||||||
// Arbitrarily chosen Max Length of Directory path, should be sufficient for
|
// Arbitrarily chosen Max Length of Directory path, should be sufficient for
|
||||||
// Any set-up
|
// Any set-up
|
||||||
@@ -805,25 +822,9 @@ void OverlayController::setPreviousShutdownSafe( bool value )
|
|||||||
settings::BoolSetting::APPLICATION_previousShutdownSafe, value );
|
settings::BoolSetting::APPLICATION_previousShutdownSafe, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
int verifyCustomTickRate( const int tickRate )
|
|
||||||
{
|
|
||||||
if ( tickRate < 1 )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if ( tickRate > k_maxCustomTickRate )
|
|
||||||
{
|
|
||||||
return k_maxCustomTickRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tickRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OverlayController::customTickRateMs() const
|
int OverlayController::customTickRateMs() const
|
||||||
{
|
{
|
||||||
const auto tickRate = settings::getSetting(
|
return m_verifiedCustomTickRateMs;
|
||||||
settings::IntSetting::APPLICATION_customTickRateMs );
|
|
||||||
return verifyCustomTickRate( tickRate );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::setCustomTickRateMs( int value, bool notify )
|
void OverlayController::setCustomTickRateMs( int value, bool notify )
|
||||||
@@ -832,6 +833,8 @@ void OverlayController::setCustomTickRateMs( int value, bool notify )
|
|||||||
|
|
||||||
settings::setSetting( settings::IntSetting::APPLICATION_customTickRateMs,
|
settings::setSetting( settings::IntSetting::APPLICATION_customTickRateMs,
|
||||||
verifiedTickRate );
|
verifiedTickRate );
|
||||||
|
m_verifiedCustomTickRateMs = verifiedTickRate;
|
||||||
|
|
||||||
if ( notify )
|
if ( notify )
|
||||||
{
|
{
|
||||||
emit customTickRateMsChanged( verifiedTickRate );
|
emit customTickRateMsChanged( verifiedTickRate );
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ private:
|
|||||||
uint64_t m_lastFrame = 0;
|
uint64_t m_lastFrame = 0;
|
||||||
int m_vsyncTooLateCounter = 0;
|
int m_vsyncTooLateCounter = 0;
|
||||||
int m_customTickRateCounter = 0;
|
int m_customTickRateCounter = 0;
|
||||||
|
int m_verifiedCustomTickRateMs = 0;
|
||||||
|
|
||||||
input::SteamIVRInput m_actions;
|
input::SteamIVRInput m_actions;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user