From 92466165f60ea894253d9d6b7be834d84f496c78 Mon Sep 17 00:00:00 2001 From: Eladash Date: Wed, 29 Jan 2020 22:42:41 +0200 Subject: [PATCH] Increase Maximum Vblank Rate and Clocks Scale Allow x30 times the speed of vblank rate + clocks scale of original PS3. In theory a 60 fps limit game which scales frame limit perfectly with vblank rate can be played at up to 1800 fps with this change. And: * Fixed lv2 sleep with Clocks Scaling * Make these settings dynamicaly adjustable. * Avoid code duplication --- rpcs3/Emu/Cell/lv2/sys_sync.h | 9 +++------ rpcs3/Emu/RSX/RSXThread.cpp | 6 +++--- rpcs3/Emu/System.h | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_sync.h b/rpcs3/Emu/Cell/lv2/sys_sync.h index 281ae8a06c..4e5b26337b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_sync.h +++ b/rpcs3/Emu/Cell/lv2/sys_sync.h @@ -253,13 +253,10 @@ public: template static bool wait_timeout(u64 usec, cpu_thread* const cpu = {}) { - static_assert(UINT64_MAX / cond_variable::max_timeout >= g_cfg.core.clocks_scale.max, "timeout may overflow during scaling"); + static_assert(UINT64_MAX / cond_variable::max_timeout >= 100, "max timeout is not valid for scaling"); - // Clamp to max timeout accepted - const u64 max_usec = cond_variable::max_timeout * 100 / g_cfg.core.clocks_scale.max; - - // Now scale the result - usec = (std::min(usec, max_usec) * g_cfg.core.clocks_scale) / 100; + // Clamp and scale the result + usec = std::min(std::min(usec, UINT64_MAX / 100) * 100 / g_cfg.core.clocks_scale, cond_variable::max_timeout); extern u64 get_system_time(); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 16f89b7b3a..3ba7802455 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -502,12 +502,12 @@ namespace rsx #endif u64 start_time = get_system_time(); - const u64 period_time = 1000000 / g_cfg.video.vblank_rate; - const u64 wait_sleep = period_time - u64{period_time >= host_min_quantum} * host_min_quantum; - // TODO: exit condition while (!Emu.IsStopped() && !m_rsx_thread_exiting) { + const u64 period_time = 1000000 / g_cfg.video.vblank_rate; + const u64 wait_sleep = period_time - u64{period_time >= host_min_quantum} * host_min_quantum; + if (get_system_time() - start_time >= period_time) { do diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index cd1601fb28..4e58ceeaba 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -424,7 +424,7 @@ struct cfg_root : cfg::node cfg::set_entry load_libraries{this, "Load libraries"}; cfg::_bool hle_lwmutex{this, "HLE lwmutex"}; // Force alternative lwmutex/lwcond implementation - cfg::_int<10, 1000> clocks_scale{this, "Clocks scale", 100}; // Changing this from 100 (percentage) may affect game speed in unexpected ways + cfg::_int<10, 3000> clocks_scale{this, "Clocks scale", 100, true}; // Changing this from 100 (percentage) may affect game speed in unexpected ways cfg::_enum sleep_timers_accuracy{this, "Sleep Timers Accuracy", #ifdef __linux__ sleep_timers_accuracy_level::_as_host}; @@ -504,7 +504,7 @@ struct cfg_root : cfg::node cfg::_int<1, 1024> min_scalable_dimension{this, "Minimum Scalable Dimension", 16}; cfg::_int<0, 30000000> driver_recovery_timeout{this, "Driver Recovery Timeout", 1000000, true}; cfg::_int<0, 16667> driver_wakeup_delay{this, "Driver Wake-Up Delay", 1, true}; - cfg::_int<1, 500> vblank_rate{this, "Vblank Rate", 60}; // Changing this from 60 may affect game speed in unexpected ways + cfg::_int<1, 1800> vblank_rate{this, "Vblank Rate", 60, true}; // Changing this from 60 may affect game speed in unexpected ways struct node_vk : cfg::node {