feat(settings): add frame skipping option to improve performance

- Added a new setting `frame_skipping` in the settings configuration.
- Provides users the ability to enable or disable frame skipping via the UI.
- Frame skipping helps improve performance by skipping frames when the emulator can't maintain the target frame rate, at the cost of visual fluidity.
- Added descriptive text to explain the setting's purpose and its impact on gameplay.
This commit is contained in:
Phoenix 2024-09-11 21:27:33 +10:00
parent 25b8a93db0
commit 7bad57e519
4 changed files with 39 additions and 4 deletions

View File

@ -28,7 +28,8 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
TOUCHSCREEN("touchscreen"),
SHOW_THERMAL_OVERLAY("show_thermal_overlay"),
CORE_USE_MULTI_CORE("use_multi_core"),
SYNC_CORE_SPEED("sync_core_speed");
SYNC_CORE_SPEED("sync_core_speed"),
FRAME_SKIPPING("frame_skipping");
override fun getBoolean(needsGlobal: Boolean): Boolean =
NativeConfig.getBoolean(key, needsGlobal)

View File

@ -176,6 +176,7 @@ private fun addPhoenixHacksSubmenu(sl: ArrayList<SettingsItem>) {
addPhoenixHacksSettings(sl) // Add the actual settings under Phoenix Hacks
// Add settings using keys directly
add(BooleanSetting.FRAME_SKIPPING.key)
add(BooleanSetting.CORE_USE_MULTI_CORE.key)
add(BooleanSetting.SYNC_CORE_SPEED.key)
add(IntSetting.RENDERER_SHADER_BACKEND.key)
@ -224,9 +225,35 @@ private fun addPhoenixHacksSubmenu(sl: ArrayList<SettingsItem>) {
override fun reset() = BooleanSetting.CORE_USE_MULTI_CORE.reset()
}
private val frameSkippingSetting = object : AbstractBooleanSetting {
override val key = "frame_skipping"
override fun getBoolean(needsGlobal: Boolean): Boolean {
return BooleanSetting.FRAME_SKIPPING.getBoolean(needsGlobal)
}
override fun setBoolean(value: Boolean) {
BooleanSetting.FRAME_SKIPPING.setBoolean(value)
NativeLibrary.setFrameSkipping(value) // Ensure this toggles the frame skipping in Vulkan renderer
}
override val defaultValue = BooleanSetting.FRAME_SKIPPING.defaultValue
override fun getValueAsString(needsGlobal: Boolean): String = getBoolean(needsGlobal).toString()
override fun reset() = setBoolean(defaultValue)
}
private fun addPhoenixHacksSettings(sl: ArrayList<SettingsItem>) {
sl.apply {
// Add the multi-core setting to Phoenix Hacks submenu
add(
SwitchSetting(
frameSkippingSetting,
titleId = R.string.frame_skipping,
descriptionId = R.string.frame_skipping_description
)
)
add(
SwitchSetting(
useSyncCoreSpeedSetting,

View File

@ -212,6 +212,9 @@ struct Values {
&use_speed_limit};
SwitchableSetting<bool> sync_core_speed{linkage, false, "sync_core_speed", Category::Core, Specialization::Default};
// Frame-Skipping (Experimental)
SwitchableSetting<bool> frame_skipping{linkage, false, "frame_skipping", Category::Graphics, Specialization::Default};
// Cpu
SwitchableSetting<CpuBackend, true> cpu_backend{linkage,
#ifdef HAS_NCE
@ -603,15 +606,14 @@ struct Values {
// Miscellaneous
Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
Setting<bool> use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous};
// Network
Setting<std::string> network_interface{linkage, std::string(), "network_interface",
Category::Network};
// WebService
Setting<bool> enable_telemetry{linkage, true, "enable_telemetry", Category::WebService};
Setting<std::string> web_api_url{linkage, "https://api.uzuy-emu.org", "web_api_url",
Setting<bool> enable_telemetry{linkage, false, "enable_telemetry", Category::WebService};
Setting<std::string> web_api_url{linkage, "http://localhost", "web_api_url",
Category::WebService};
Setting<std::string> uzuy_username{linkage, std::string(), "uzuy_username",
Category::WebService};

View File

@ -184,6 +184,11 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
INSERT(Settings, bg_red, QStringLiteral(), QStringLiteral());
INSERT(Settings, bg_green, QStringLiteral(), QStringLiteral());
INSERT(Settings, bg_blue, QStringLiteral(), QStringLiteral());
// Frame Skipping (Advanced)
INSERT(Settings, frame_skipping, tr("Enable Frame Skipping"),
tr("Enables frame skipping to improve performance in cases where the emulator cannot maintain the target frame rate. "
"Frame skipping will cause some frames to be skipped to maintain smoother gameplay at the cost of visual fluidity. "
"This is especially useful on lower-end hardware."));
// Renderer (Advanced Graphics)
INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"),