summaryrefslogtreecommitdiffstats
path: root/src/core/perf_stats.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-08-22 07:19:50 +0200
committerGitHub <noreply@github.com>2018-08-22 07:19:50 +0200
commitcea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b (patch)
tree0fd784bbd8788158b88a0ee3125278b8f5e79e4c /src/core/perf_stats.cpp
parentMerge pull request #1154 from OatmealDome/topology-lines (diff)
parentPort #3353 from Citra (diff)
downloadyuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.tar
yuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.tar.gz
yuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.tar.bz2
yuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.tar.lz
yuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.tar.xz
yuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.tar.zst
yuzu-cea627b0fc109ee27b3d0cabd8f803c8c2c2ac8b.zip
Diffstat (limited to 'src/core/perf_stats.cpp')
-rw-r--r--src/core/perf_stats.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 4e5633edb..93d23de21 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -78,20 +78,29 @@ void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
// values increase the time needed to recover and limit framerate again after spikes.
constexpr microseconds MAX_LAG_TIME_US = 25000us;
- if (!Settings::values.toggle_framelimit) {
+ if (!Settings::values.use_frame_limit) {
return;
}
auto now = Clock::now();
- frame_limiting_delta_err += current_system_time_us - previous_system_time_us;
+ const double sleep_scale = Settings::values.frame_limit / 100.0;
+
+ // Max lag caused by slow frames. Shouldn't be more than the length of a frame at the current
+ // speed percent or it will clamp too much and prevent this from properly limiting to that
+ // percent. High values means it'll take longer after a slow frame to recover and start
+ // limiting
+ const microseconds max_lag_time_us = duration_cast<microseconds>(
+ std::chrono::duration<double, std::chrono::microseconds::period>(25ms / sleep_scale));
+ frame_limiting_delta_err += duration_cast<microseconds>(
+ std::chrono::duration<double, std::chrono::microseconds::period>(
+ (current_system_time_us - previous_system_time_us) / sleep_scale));
frame_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime);
frame_limiting_delta_err =
- std::clamp(frame_limiting_delta_err, -MAX_LAG_TIME_US, MAX_LAG_TIME_US);
+ std::clamp(frame_limiting_delta_err, -max_lag_time_us, max_lag_time_us);
if (frame_limiting_delta_err > microseconds::zero()) {
std::this_thread::sleep_for(frame_limiting_delta_err);
-
auto now_after_sleep = Clock::now();
frame_limiting_delta_err -= duration_cast<microseconds>(now_after_sleep - now);
now = now_after_sleep;