Add sync core speed

This commit is contained in:
Pavel Barabanov 2025-04-11 18:52:04 +03:00 committed by MrPurple666
parent d25bea5762
commit 70c2439d8c
7 changed files with 53 additions and 5 deletions

View file

@ -10,6 +10,7 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
CPU_DEBUG_MODE("cpu_debug_mode"), CPU_DEBUG_MODE("cpu_debug_mode"),
FASTMEM("cpuopt_fastmem"), FASTMEM("cpuopt_fastmem"),
FASTMEM_EXCLUSIVES("cpuopt_fastmem_exclusives"), FASTMEM_EXCLUSIVES("cpuopt_fastmem_exclusives"),
CORE_SYNC_CORE_SPEED("sync_core_speed"),
RENDERER_USE_SPEED_LIMIT("use_speed_limit"), RENDERER_USE_SPEED_LIMIT("use_speed_limit"),
USE_DOCKED_MODE("use_docked_mode"), USE_DOCKED_MODE("use_docked_mode"),
RENDERER_USE_DISK_SHADER_CACHE("use_disk_shader_cache"), RENDERER_USE_DISK_SHADER_CACHE("use_disk_shader_cache"),
@ -28,8 +29,7 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
TOUCHSCREEN("touchscreen"), TOUCHSCREEN("touchscreen"),
SHOW_THERMAL_OVERLAY("show_thermal_overlay"), SHOW_THERMAL_OVERLAY("show_thermal_overlay"),
ENABLE_FRAME_INTERPOLATION("enable_frame_interpolation"), ENABLE_FRAME_INTERPOLATION("enable_frame_interpolation"),
ENABLE_FRAME_SKIPPING("enable_frame_skipping"), ENABLE_FRAME_SKIPPING("enable_frame_skipping");
CORE_USE_MULTI_CORE("use_multi_core");
external fun isFrameSkippingEnabled(): Boolean external fun isFrameSkippingEnabled(): Boolean
external fun isFrameInterpolationEnabled(): Boolean external fun isFrameInterpolationEnabled(): Boolean

View file

@ -206,6 +206,25 @@ abstract class SettingsItem(
override fun reset() = BooleanSetting.ENABLE_FRAME_SKIPPING.reset() override fun reset() = BooleanSetting.ENABLE_FRAME_SKIPPING.reset()
} }
val syncCoreSpeedSetting = object : AbstractBooleanSetting {
override val key = BooleanSetting.CORE_SYNC_CORE_SPEED.key
override fun getBoolean(needsGlobal: Boolean): Boolean {
return BooleanSetting.CORE_SYNC_CORE_SPEED.getBoolean(needsGlobal)
}
override fun setBoolean(value: Boolean) {
BooleanSetting.CORE_SYNC_CORE_SPEED.setBoolean(value)
}
override val defaultValue = BooleanSetting.CORE_SYNC_CORE_SPEED.defaultValue
override fun getValueAsString(needsGlobal: Boolean): String =
BooleanSetting.CORE_SYNC_CORE_SPEED.getValueAsString(needsGlobal)
override fun reset() = BooleanSetting.CORE_SYNC_CORE_SPEED.reset()
}
put( put(
SwitchSetting( SwitchSetting(
BooleanSetting.ENABLE_FRAME_INTERPOLATION, BooleanSetting.ENABLE_FRAME_INTERPOLATION,
@ -230,6 +249,14 @@ abstract class SettingsItem(
) )
) )
put(
SwitchSetting(
syncCoreSpeedSetting,
titleId = R.string.use_sync_core,
descriptionId = R.string.use_sync_core_description
)
)
put( put(
SingleChoiceSetting( SingleChoiceSetting(
IntSetting.REGION_INDEX, IntSetting.REGION_INDEX,

View file

@ -159,6 +159,7 @@ class SettingsFragmentPresenter(
add(StringSetting.DEVICE_NAME.key) add(StringSetting.DEVICE_NAME.key)
add(BooleanSetting.RENDERER_USE_SPEED_LIMIT.key) add(BooleanSetting.RENDERER_USE_SPEED_LIMIT.key)
add(ShortSetting.RENDERER_SPEED_LIMIT.key) add(ShortSetting.RENDERER_SPEED_LIMIT.key)
add(BooleanSetting.CORE_SYNC_CORE_SPEED.key)
add(BooleanSetting.USE_DOCKED_MODE.key) add(BooleanSetting.USE_DOCKED_MODE.key)
add(IntSetting.REGION_INDEX.key) add(IntSetting.REGION_INDEX.key)
add(IntSetting.LANGUAGE_INDEX.key) add(IntSetting.LANGUAGE_INDEX.key)

View file

@ -217,6 +217,10 @@
<string name="cpu_accuracy">CPU accuracy</string> <string name="cpu_accuracy">CPU accuracy</string>
<string name="value_with_units">%1$s%2$s</string> <string name="value_with_units">%1$s%2$s</string>
<!-- Use Sync Core -->
<string name="use_sync_core">Synchronize Core Speed</string>
<string name="use_sync_core_description">Synchronize the core tick speed to the maximum speed percentage to improve performance without altering the games actual speed.</string>
<!-- System settings strings --> <!-- System settings strings -->
<string name="device_name">Device name</string> <string name="device_name">Device name</string>
<string name="use_docked_mode">Docked Mode</string> <string name="use_docked_mode">Docked Mode</string>

View file

@ -210,6 +210,7 @@ struct Values {
true, true,
true, true,
&use_speed_limit}; &use_speed_limit};
SwitchableSetting<bool> sync_core_speed{linkage, false, "sync_core_speed", Category::Core, Specialization::Default};
// Cpu // Cpu
SwitchableSetting<CpuBackend, true> cpu_backend{linkage, SwitchableSetting<CpuBackend, true> cpu_backend{linkage,

View file

@ -14,6 +14,7 @@
#include "common/x64/cpu_wait.h" #include "common/x64/cpu_wait.h"
#endif #endif
#include "common/settings.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hardware_properties.h" #include "core/hardware_properties.h"
@ -184,10 +185,20 @@ void CoreTiming::ResetTicks() {
} }
u64 CoreTiming::GetClockTicks() const { u64 CoreTiming::GetClockTicks() const {
u64 fres;
if (is_multicore) [[likely]] { if (is_multicore) [[likely]] {
return clock->GetCNTPCT(); fres = clock->GetCNTPCT();
} else {
fres = Common::WallClock::CPUTickToCNTPCT(cpu_ticks);
}
if (Settings::values.sync_core_speed.GetValue()) {
const double ticks = static_cast<double>(fres);
const double speed_limit = static_cast<double>(Settings::values.speed_limit.GetValue())*0.01;
return static_cast<u64>(ticks/speed_limit);
} else {
return fres;
} }
return Common::WallClock::CPUTickToCNTPCT(cpu_ticks);
} }
u64 CoreTiming::GetGPUTicks() const { u64 CoreTiming::GetGPUTicks() const {

View file

@ -71,6 +71,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
"faster or not.\n200% for a 30 FPS game is 60 FPS, and for a " "faster or not.\n200% for a 30 FPS game is 60 FPS, and for a "
"60 FPS game it will be 120 FPS.\nDisabling it means unlocking the framerate to the " "60 FPS game it will be 120 FPS.\nDisabling it means unlocking the framerate to the "
"maximum your PC can reach.")); "maximum your PC can reach."));
INSERT(Settings, sync_core_speed, tr("Synchronize Core Speed"),
tr("Synchronizes CPU core speed with the game's maximum rendering speed to boost FPS without affecting game speed (animations, physics, etc.).\n"
"Compatibility varies by game; many (especially older ones) may not respond well.\n"
"Can help reduce stuttering at lower framerates."));
// Cpu // Cpu
INSERT(Settings, cpu_accuracy, tr("Accuracy:"), INSERT(Settings, cpu_accuracy, tr("Accuracy:"),