From 5ccfaf0517ed365e64458783b30f521d3ed21c78 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 4 May 2023 03:44:53 -0400 Subject: [PATCH] settings: Pool SetGlobal functions --- src/common/settings.cpp | 63 +++-------------------------------------- src/common/settings.h | 12 ++++++-- 2 files changed, 14 insertions(+), 61 deletions(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 3f56afe944..e3f30f7e32 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -7,6 +7,7 @@ #include #include #endif +#include #include #include "common/assert.h" @@ -210,65 +211,9 @@ void RestoreGlobalState(bool is_powered_on) { return; } - // Audio - values.volume.SetGlobal(true); - - // Core - values.use_multi_core.SetGlobal(true); - values.use_unsafe_extended_memory_layout.SetGlobal(true); - - // CPU - values.cpu_accuracy.SetGlobal(true); - values.cpuopt_unsafe_unfuse_fma.SetGlobal(true); - values.cpuopt_unsafe_reduce_fp_error.SetGlobal(true); - values.cpuopt_unsafe_ignore_standard_fpcr.SetGlobal(true); - values.cpuopt_unsafe_inaccurate_nan.SetGlobal(true); - values.cpuopt_unsafe_fastmem_check.SetGlobal(true); - values.cpuopt_unsafe_ignore_global_monitor.SetGlobal(true); - - // Renderer - values.fsr_sharpening_slider.SetGlobal(true); - values.renderer_backend.SetGlobal(true); - values.async_presentation.SetGlobal(true); - values.renderer_force_max_clock.SetGlobal(true); - values.vulkan_device.SetGlobal(true); - values.fullscreen_mode.SetGlobal(true); - values.aspect_ratio.SetGlobal(true); - values.resolution_setup.SetGlobal(true); - values.scaling_filter.SetGlobal(true); - values.anti_aliasing.SetGlobal(true); - values.max_anisotropy.SetGlobal(true); - values.use_speed_limit.SetGlobal(true); - values.speed_limit.SetGlobal(true); - values.use_disk_shader_cache.SetGlobal(true); - values.gpu_accuracy.SetGlobal(true); - values.use_asynchronous_gpu_emulation.SetGlobal(true); - values.nvdec_emulation.SetGlobal(true); - values.accelerate_astc.SetGlobal(true); - values.astc_recompression.SetGlobal(true); - values.use_reactive_flushing.SetGlobal(true); - values.shader_backend.SetGlobal(true); - values.use_asynchronous_shaders.SetGlobal(true); - values.use_fast_gpu_time.SetGlobal(true); - values.use_vulkan_driver_pipeline_cache.SetGlobal(true); - values.bg_red.SetGlobal(true); - values.bg_green.SetGlobal(true); - values.bg_blue.SetGlobal(true); - values.enable_compute_pipelines.SetGlobal(true); - values.use_video_framerate.SetGlobal(true); - - // System - values.language_index.SetGlobal(true); - values.region_index.SetGlobal(true); - values.time_zone_index.SetGlobal(true); - values.rng_seed.SetGlobal(true); - values.sound_index.SetGlobal(true); - - // Controls - values.players.SetGlobal(true); - values.use_docked_mode.SetGlobal(true); - values.vibration_enabled.SetGlobal(true); - values.motion_enabled.SetGlobal(true); + for (const auto& reset : global_reset_registry) { + reset(); + } } } // namespace Settings diff --git a/src/common/settings.h b/src/common/settings.h index b8ab34f7f8..61d15467d2 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include #include @@ -125,6 +127,8 @@ struct ResolutionScalingInfo { } }; +static std::forward_list> global_reset_registry; + /** The Setting class is a simple resource manager. It defines a label and default value alongside * the actual value of the setting for simpler and less-error prone use with frontend * configurations. Specifying a default value and label is required. A minimum and maximum range can @@ -255,7 +259,9 @@ public: */ explicit SwitchableSetting(const Type& default_val, const std::string& name) requires(!ranged) - : Setting{default_val, name} {} + : Setting{default_val, name} { + global_reset_registry.push_front([this]() { this->SetGlobal(true); }); + } virtual ~SwitchableSetting() = default; /** @@ -269,7 +275,9 @@ public: explicit SwitchableSetting(const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name) requires(ranged) - : Setting{default_val, min_val, max_val, name} {} + : Setting{default_val, min_val, max_val, name} { + global_reset_registry.push_front([this]() { this->SetGlobal(true); }); + } /** * Tells this setting to represent either the global or custom setting when other member