From 4132b5ef3d120f851b553bf7367d3bf4e729c403 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 28 Sep 2024 23:50:42 +1000 Subject: [PATCH] Settings: Remove 'Increase Timer Resolution' option It's no longer needed since I switched to high-resolution waitable timers, which are supported on Win10 1803+. --- src/common/timer.cpp | 2 +- src/core/fullscreen_ui.cpp | 11 ------ src/core/settings.cpp | 2 -- src/core/settings.h | 1 - src/core/system.cpp | 36 ++++--------------- src/duckstation-qt/advancedsettingswidget.cpp | 4 --- 6 files changed, 8 insertions(+), 48 deletions(-) diff --git a/src/common/timer.cpp b/src/common/timer.cpp index fc547c637..f1ff5cd67 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -135,7 +135,7 @@ void Timer::SleepUntil(Value value, bool exact) } // falling back to sleep... bad. - Sleep(static_cast(static_cast(diff) / 1000000)); + Sleep(static_cast(ConvertValueToMilliseconds(diff))); } } diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 2aaeab8f2..be83f63f0 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -5121,12 +5121,6 @@ void FullscreenUI::DrawAdvancedSettingsPage() FSUI_CSTR("Enable debugging when supported by the host's renderer API. Only for developer use."), "GPU", "UseDebugDevice", false); -#ifdef _WIN32 - DrawToggleSetting(bsi, FSUI_CSTR("Increase Timer Resolution"), - FSUI_CSTR("Enables more precise frame pacing at the cost of battery life."), "Main", - "IncreaseTimerResolution", true); -#endif - DrawToggleSetting(bsi, FSUI_CSTR("Allow Booting Without SBI File"), FSUI_CSTR("Allows loading protected games without subchannel information."), "CDROM", "AllowBootingWithoutSBIFile", false); @@ -7259,9 +7253,6 @@ TRANSLATE_NOOP("FullscreenUI", "Contributor List"); TRANSLATE_NOOP("FullscreenUI", "Controller Port {}"); TRANSLATE_NOOP("FullscreenUI", "Controller Port {} Macros"); TRANSLATE_NOOP("FullscreenUI", "Controller Port {} Settings"); -TRANSLATE_NOOP("FullscreenUI", "Controller Port {}{}"); -TRANSLATE_NOOP("FullscreenUI", "Controller Port {}{} Macros"); -TRANSLATE_NOOP("FullscreenUI", "Controller Port {}{} Settings"); TRANSLATE_NOOP("FullscreenUI", "Controller Settings"); TRANSLATE_NOOP("FullscreenUI", "Controller Type"); TRANSLATE_NOOP("FullscreenUI", "Controller settings reset to default."); @@ -7354,7 +7345,6 @@ TRANSLATE_NOOP("FullscreenUI", "Enable/Disable the Player LED on DualSense contr TRANSLATE_NOOP("FullscreenUI", "Enables alignment and bus exceptions. Not needed for any known games."); TRANSLATE_NOOP("FullscreenUI", "Enables an additional 6MB of RAM to obtain a total of 2+6 = 8MB, usually present on dev consoles."); TRANSLATE_NOOP("FullscreenUI", "Enables an additional three controller slots on each port. Not supported in all games."); -TRANSLATE_NOOP("FullscreenUI", "Enables more precise frame pacing at the cost of battery life."); TRANSLATE_NOOP("FullscreenUI", "Enables smooth scrolling of menus in Big Picture UI."); TRANSLATE_NOOP("FullscreenUI", "Enables the older, less accurate MDEC decoding routines. May be required for old replacement backgrounds to match/load."); TRANSLATE_NOOP("FullscreenUI", "Enables the replacement of background textures in supported games."); @@ -7427,7 +7417,6 @@ TRANSLATE_NOOP("FullscreenUI", "How many saves will be kept for rewinding. Highe TRANSLATE_NOOP("FullscreenUI", "How often a rewind state will be created. Higher frequencies have greater system requirements."); TRANSLATE_NOOP("FullscreenUI", "Identifies any new files added to the game directories."); TRANSLATE_NOOP("FullscreenUI", "If not enabled, the current post processing chain will be ignored."); -TRANSLATE_NOOP("FullscreenUI", "Increase Timer Resolution"); TRANSLATE_NOOP("FullscreenUI", "Increases the field of view from 4:3 to the chosen display aspect ratio in 3D games."); TRANSLATE_NOOP("FullscreenUI", "Increases the precision of polygon culling, reducing the number of holes in geometry."); TRANSLATE_NOOP("FullscreenUI", "Infinite/Instantaneous"); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 9a9ffc77d..01662e5d4 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -148,7 +148,6 @@ void Settings::Load(SettingsInterface& si, SettingsInterface& controller_si) fast_forward_speed = si.GetFloatValue("Main", "FastForwardSpeed", 0.0f); turbo_speed = si.GetFloatValue("Main", "TurboSpeed", 0.0f); sync_to_host_refresh_rate = si.GetBoolValue("Main", "SyncToHostRefreshRate", false); - increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true); inhibit_screensaver = si.GetBoolValue("Main", "InhibitScreensaver", true); start_paused = si.GetBoolValue("Main", "StartPaused", false); start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false); @@ -464,7 +463,6 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const if (!ignore_base) { si.SetBoolValue("Main", "SyncToHostRefreshRate", sync_to_host_refresh_rate); - si.SetBoolValue("Main", "IncreaseTimerResolution", increase_timer_resolution); si.SetBoolValue("Main", "InhibitScreensaver", inhibit_screensaver); si.SetBoolValue("Main", "StartPaused", start_paused); si.SetBoolValue("Main", "StartFullscreen", start_fullscreen); diff --git a/src/core/settings.h b/src/core/settings.h index 49ba595e1..5ddcfc381 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -77,7 +77,6 @@ struct Settings float fast_forward_speed = 0.0f; float turbo_speed = 0.0f; bool sync_to_host_refresh_rate : 1 = false; - bool increase_timer_resolution : 1 = true; bool inhibit_screensaver : 1 = true; bool start_paused : 1 = false; bool start_fullscreen : 1 = false; diff --git a/src/core/system.cpp b/src/core/system.cpp index 71aee249f..0a432dd5d 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -85,8 +85,6 @@ LOG_CHANNEL(System); #ifdef _WIN32 #include "common/windows_headers.h" #include -#include -#include #endif #ifndef __ANDROID__ @@ -223,8 +221,6 @@ static bool DoRunahead(); static void UpdateSessionTime(const std::string& prev_serial); -static void SetTimerResolutionIncreased(bool enabled); - #ifdef ENABLE_DISCORD_PRESENCE static void InitializeDiscordPresence(); static void ShutdownDiscordPresence(); @@ -1969,8 +1965,6 @@ void System::DestroySystem() if (g_settings.inhibit_screensaver) PlatformMisc::ResumeScreensaver(); - SetTimerResolutionIncreased(false); - s_cpu_thread_usage = {}; ClearMemorySaveStates(); @@ -2323,10 +2317,14 @@ void System::Throttle(Common::Timer::Value current_time) #endif #if 0 - DEV_LOG("Asked for {:.2f} ms, slept for {:.2f} ms, {:.2f} ms late", + const Common::Timer::Value time_after_sleep = Common::Timer::GetCurrentValue(); + DEV_LOG("Asked for {:.2f} ms, slept for {:.2f} ms, {:.2f} ms {}", Common::Timer::ConvertValueToMilliseconds(s_next_frame_time - current_time), - Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - current_time), - Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - s_next_frame_time)); + Common::Timer::ConvertValueToMilliseconds(time_after_sleep - current_time), + Common::Timer::ConvertValueToMilliseconds((time_after_sleep < s_next_frame_time) ? + (s_next_frame_time - time_after_sleep) : + (time_after_sleep - s_next_frame_time)), + (time_after_sleep < s_next_frame_time) ? "early" : "late"); #endif s_next_frame_time += s_frame_period; @@ -3437,9 +3435,6 @@ void System::UpdateSpeedLimiterState() ResetThrottler(); UpdateDisplayVSync(); - if (g_settings.increase_timer_resolution) - SetTimerResolutionIncreased(s_throttler_enabled); - #ifdef __APPLE__ // To get any resemblence of consistent frame times on MacOS, we need to tell the scheduler how often we need to run. // Assume a maximum of 7ms for running a frame. It'll be much lower than that, Apple Silicon is fast. @@ -4468,7 +4463,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings) } if (g_settings.audio_backend != old_settings.audio_backend || - g_settings.increase_timer_resolution != old_settings.increase_timer_resolution || g_settings.emulation_speed != old_settings.emulation_speed || g_settings.fast_forward_speed != old_settings.fast_forward_speed || g_settings.display_optimal_frame_pacing != old_settings.display_optimal_frame_pacing || @@ -5841,22 +5835,6 @@ void System::InvalidateDisplay() g_gpu->RestoreDeviceContext(); } -void System::SetTimerResolutionIncreased(bool enabled) -{ -#if defined(_WIN32) - static bool current_state = false; - if (current_state == enabled) - return; - - current_state = enabled; - - if (enabled) - timeBeginPeriod(1); - else - timeEndPeriod(1); -#endif -} - void System::UpdateSessionTime(const std::string& prev_serial) { const u64 ctime = Common::Timer::GetCurrentValue(); diff --git a/src/duckstation-qt/advancedsettingswidget.cpp b/src/duckstation-qt/advancedsettingswidget.cpp index c9af71ca3..a9557564f 100644 --- a/src/duckstation-qt/advancedsettingswidget.cpp +++ b/src/duckstation-qt/advancedsettingswidget.cpp @@ -218,8 +218,6 @@ void AdvancedSettingsWidget::addTweakOptions() addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Apply Compatibility Settings"), "Main", "ApplyCompatibilitySettings", true); - addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Increase Timer Resolution"), "Main", - "IncreaseTimerResolution", true); addBooleanTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Load Devices From Save States"), "Main", "LoadDevicesFromSaveStates", false); addChoiceTweakOption(m_dialog, m_ui.tweakOptionTable, tr("Save State Compression"), "Main", "SaveStateCompression", @@ -281,7 +279,6 @@ void AdvancedSettingsWidget::onResetToDefaultClicked() setBooleanTweakOption(m_ui.tweakOptionTable, i++, true); // Apply Game Settings setBooleanTweakOption(m_ui.tweakOptionTable, i++, true); // Apply compatibility settings - setBooleanTweakOption(m_ui.tweakOptionTable, i++, true); // Increase Timer Resolution setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Load Devices From Save States setChoiceTweakOption(m_ui.tweakOptionTable, i++, Settings::DEFAULT_SAVE_STATE_COMPRESSION_MODE); // Save State Compression @@ -312,7 +309,6 @@ void AdvancedSettingsWidget::onResetToDefaultClicked() // for per-game it's easier to just clear and recreate SettingsInterface* sif = m_dialog->getSettingsInterface(); sif->DeleteValue("Main", "ApplyCompatibilitySettings"); - sif->DeleteValue("Main", "IncreaseTimerResolution"); sif->DeleteValue("Main", "LoadDevicesFromSaveStates"); sif->DeleteValue("Main", "CompressSaveStates"); sif->DeleteValue("Display", "ActiveStartOffset");