From 5cffa342884df531d911555f7b3db9d2f6d1d1f0 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 3 May 2023 20:42:33 -0400 Subject: settings,video_core: Consolidate ASTC decoding options Just puts them all neatly into one place. --- src/common/settings.cpp | 2 -- src/common/settings.h | 11 +++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 5972480e5..3f56afe94 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -82,7 +82,6 @@ void LogSettings() { values.use_asynchronous_gpu_emulation.GetValue()); log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue()); log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue()); - log_setting("Renderer_AsyncASTC", values.async_astc.GetValue()); log_setting("Renderer_AstcRecompression", values.astc_recompression.GetValue()); log_setting("Renderer_UseVsync", values.vsync_mode.GetValue()); log_setting("Renderer_UseReactiveFlushing", values.use_reactive_flushing.GetValue()); @@ -246,7 +245,6 @@ void RestoreGlobalState(bool is_powered_on) { values.use_asynchronous_gpu_emulation.SetGlobal(true); values.nvdec_emulation.SetGlobal(true); values.accelerate_astc.SetGlobal(true); - values.async_astc.SetGlobal(true); values.astc_recompression.SetGlobal(true); values.use_reactive_flushing.SetGlobal(true); values.shader_backend.SetGlobal(true); diff --git a/src/common/settings.h b/src/common/settings.h index 59e96e74f..b8ab34f7f 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -16,6 +16,12 @@ namespace Settings { +enum class AstcDecodeMode : u32 { + CPU = 0, + GPU = 1, + CPUAsynchronous = 2, +}; + enum class VSyncMode : u32 { Immediate = 0, Mailbox = 1, @@ -467,8 +473,9 @@ struct Values { GPUAccuracy::Extreme, "gpu_accuracy"}; SwitchableSetting use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; SwitchableSetting nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; - SwitchableSetting accelerate_astc{true, "accelerate_astc"}; - SwitchableSetting async_astc{false, "async_astc"}; + SwitchableSetting accelerate_astc{ + AstcDecodeMode::CPU, AstcDecodeMode::CPU, AstcDecodeMode::CPUAsynchronous, + "accelerate_astc"}; Setting vsync_mode{VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, "use_vsync"}; SwitchableSetting use_reactive_flushing{true, "use_reactive_flushing"}; -- cgit v1.2.3 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: settings: Pool SetGlobal functions --- src/common/settings.cpp | 63 ++++--------------------------------------------- src/common/settings.h | 12 ++++++++-- 2 files changed, 14 insertions(+), 61 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 3f56afe94..e3f30f7e3 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 b8ab34f7f..61d15467d 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 -- cgit v1.2.3 From 413316560784348b8ea2684d272b974fd0428267 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:41:50 -0400 Subject: settings,core,config_sys: Remove optional type from custom_rtc, rng_seed core: Fix MSVC errors --- src/common/settings.cpp | 3 ++- src/common/settings.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index e3f30f7e3..696929479 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -62,7 +62,8 @@ void LogSettings() { LOG_INFO(Config, "yuzu Configuration:"); log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue()); - log_setting("System_RngSeed", values.rng_seed.GetValue().value_or(0)); + log_setting("System_RngSeedEnabled", values.rng_seed_enabled.GetValue()); + log_setting("System_RngSeed", values.rng_seed.GetValue()); log_setting("System_DeviceName", values.device_name.GetValue()); log_setting("System_CurrentUser", values.current_user.GetValue()); log_setting("System_LanguageIndex", values.language_index.GetValue()); diff --git a/src/common/settings.h b/src/common/settings.h index 61d15467d..999f8b5be 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -505,10 +505,12 @@ struct Values { SwitchableSetting bg_blue{0, "bg_blue"}; // System - SwitchableSetting> rng_seed{std::optional(), "rng_seed"}; + SwitchableSetting rng_seed_enabled{false, "rng_seed_enabled"}; + SwitchableSetting rng_seed{0, "rng_seed"}; Setting device_name{"Yuzu", "device_name"}; // Measured in seconds since epoch - std::optional custom_rtc; + SwitchableSetting custom_rtc_enabled{false, "custom_rtc_enabled"}; + SwitchableSetting custom_rtc{0, "custom_rtc"}; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` s64 custom_rtc_differential; -- cgit v1.2.3 From 60773194a039fced8cf2da308e1b8220d08a1636 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 5 Jun 2023 21:05:22 -0400 Subject: settings: Add a registry of settings LoadString: Sanitize input settings: Handle empty string, remove redundant category settings: Rename Input to Controls, FS to DataStorage settings: Fix Controls groups information settings: Move use_docked_mode to System (again) settings: Document settings: Add type identification function settings: Move registry into values settings: Move global_reset_registry into values settings: Separate AdvGraphics from Renderer settings: More document squash settings: Use linkage object uisettings: Move registry into settings Probably wont build without uisettings: Use settings linkage object config: Load settings with a map Uses the new all_settings vector to load settings. qt-config: Rename settings category qt config: Rename to read category config: Read/write contols category with for_each This is extremely limited due to the complexity of the Controls group, but this handles the the settings that use the interface. qt-config: Use new settings registry qt-config: Read/write advgrphics qt-config: Use settings linkage object yuzu_cmd: Load setting off of vector cmd-config: Finish settings rename config: Read controls settings group with for_each cmd/config: Move registry into values cmd: Read adv graphics cmd-config: Use settings linkage object --- src/common/settings.cpp | 52 +++- src/common/settings.h | 620 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 485 insertions(+), 187 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 696929479..59934803e 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -144,6 +144,56 @@ float Volume() { return values.volume.GetValue() / static_cast(values.volume.GetDefault()); } +const char* TranslateCategory(Category category) { + switch (category) { + case Category::Audio: + return "Audio"; + case Category::Core: + return "Core"; + case Category::Cpu: + return "Cpu"; + case Category::Renderer: + return "Renderer"; + case Category::System: + return "System"; + case Category::DataStorage: + return "Data Storage"; + case Category::Debugging: + return "Debugging"; + case Category::Miscellaneous: + return "Miscellaneous"; + case Category::Network: + return "Network"; + case Category::WebService: + return "WebService"; + case Category::AddOns: + return "DisabledAddOns"; + case Category::Controls: + return "Controls"; + case Category::Ui: + return "UI"; + case Category::UiLayout: + return "UiLayout"; + case Category::UiGameList: + return "UiGameList"; + case Category::Screenshots: + return "Screenshots"; + case Category::Shortcuts: + return "Shortcuts"; + case Category::Multiplayer: + return "Multiplayer"; + case Category::Services: + return "Services"; + case Category::Paths: + return "Paths"; + case Category::MaxEnum: + break; + case Category::AdvancedGraphics: + return "Renderer"; + } + return "Miscellaneous"; +} + void UpdateRescalingInfo() { const auto setup = values.resolution_setup.GetValue(); auto& info = values.resolution_info; @@ -212,7 +262,7 @@ void RestoreGlobalState(bool is_powered_on) { return; } - for (const auto& reset : global_reset_registry) { + for (const auto& reset : values.linkage.restore_functions) { reset(); } } diff --git a/src/common/settings.h b/src/common/settings.h index 999f8b5be..df4bcb053 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -9,7 +9,9 @@ #include #include #include +#include #include +#include #include #include @@ -104,6 +106,33 @@ enum class AstcRecompression : u32 { Bc3 = 2, }; +enum class Category : u32 { + Audio, + Core, + Cpu, + Renderer, + AdvancedGraphics, + System, + DataStorage, + Debugging, + Miscellaneous, + Network, + WebService, + AddOns, + Controls, + Ui, + UiLayout, + UiGameList, + Screenshots, + Shortcuts, + Multiplayer, + Services, + Paths, + MaxEnum, +}; + +const char* TranslateCategory(Settings::Category category); + struct ResolutionScalingInfo { u32 up_scale{1}; u32 down_shift{0}; @@ -127,15 +156,40 @@ struct ResolutionScalingInfo { } }; -static std::forward_list> global_reset_registry; +class BasicSetting { +protected: + explicit BasicSetting() = default; + +public: + virtual ~BasicSetting() = default; + + virtual Category Category() const = 0; + virtual constexpr bool Switchable() const = 0; + virtual std::string ToString() const = 0; + virtual void LoadString(const std::string& load) = 0; + virtual const std::string& GetLabel() const = 0; + virtual std::string DefaultToString() const = 0; + virtual bool Save() const = 0; + virtual std::type_index TypeId() const = 0; + virtual void SetGlobal(bool global) {} + virtual bool UsingGlobal() const { + return false; + } +}; + +class Linkage { +public: + std::map> by_category; + std::vector> restore_functions; +}; -/** 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 - * be specified for sanitization. +/** 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 be specified for sanitization. */ -template -class Setting { +template +class Setting : public BasicSetting { protected: Setting() = default; @@ -151,27 +205,36 @@ public: /** * Sets a default value, label, and setting value. * + * @param linkage Setting registry * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting + * @param category_ Category of the setting AKA INI group */ - explicit Setting(const Type& default_val, const std::string& name) + explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, + enum Category category_) requires(!ranged) - : value{default_val}, default_value{default_val}, label{name} {} + : value{default_val}, default_value{default_val}, label{name}, category{category_} { + linkage.by_category[category].push_front(this); + } virtual ~Setting() = default; /** * Sets a default value, minimum value, maximum value, and label. * + * @param linkage Setting registry * @param default_val Initial value of the setting, and default value of the setting * @param min_val Sets the minimum allowed value of the setting * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting + * @param category_ Category of the setting AKA INI group */ - explicit Setting(const Type& default_val, const Type& min_val, const Type& max_val, - const std::string& name) + explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, + const Type& max_val, const std::string& name, enum Category category_) requires(ranged) - : value{default_val}, - default_value{default_val}, maximum{max_val}, minimum{min_val}, label{name} {} + : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, + label{name}, category{category_} { + linkage.by_category[category].push_front(this); + } /** * Returns a reference to the setting's value. @@ -206,10 +269,61 @@ public: * * @returns A reference to the label */ - [[nodiscard]] const std::string& GetLabel() const { + [[nodiscard]] const std::string& GetLabel() const override { return label; } + /** + * Returns the setting's category AKA INI group. + * + * @returns The setting's category + */ + [[nodiscard]] enum Category Category() const override { + return category; + } + + /** + * Returns whether the current setting is Switchable. + * + * @returns If the setting is a SwitchableSetting + */ + [[nodiscard]] virtual constexpr bool Switchable() const override { + return false; + } + +private: + std::string ToString(const Type& value_) const { + if constexpr (std::is_same()) { + return value_; + } else if constexpr (std::is_same>()) { + return value_.has_value() ? std::to_string(*value_) : "0"; + } else if constexpr (std::is_same()) { + return value_ ? "true" : "false"; + } else { + return std::to_string(static_cast(value_)); + } + } + +public: + /** + * Converts the value of the setting to a std::string. Respects the global state if the setting + * has one. + * + * @returns The current setting as a std::string + */ + std::string ToString() const override { + return ToString(this->GetValue()); + } + + /** + * Returns the default value of the setting as a std::string. + * + * @returns The default value as a string. + */ + std::string DefaultToString() const override { + return ToString(default_value); + } + /** * Assigns a value to the setting. * @@ -232,12 +346,58 @@ public: return value; } + /** + * Converts the given value to the Setting's type of value. Uses SetValue to enter the setting, + * thus respecting its constraints. + * + * @param input The desired value + */ + void LoadString(const std::string& input) override { + if (input.empty()) { + this->SetValue(this->GetDefault()); + return; + } + try { + if constexpr (std::is_same()) { + this->SetValue(input); + } else if constexpr (std::is_same>()) { + this->SetValue(static_cast(std::stoll(input))); + } else if constexpr (std::is_same()) { + this->SetValue(input == "true"); + } else { + this->SetValue(static_cast(std::stoll(input))); + } + } catch (std::invalid_argument) { + this->SetValue(this->GetDefault()); + } + } + + /** + * Returns the save preference of the setting i.e. when saving or reading the setting from a + * frontend, whether this setting should be skipped. + * + * @returns The save preference + */ + virtual bool Save() const override { + return save; + } + + /** + * Gives us another way to identify the setting without having to go through a string. + * + * @returns the type_index of the setting's type + */ + virtual std::type_index TypeId() const override { + return std::type_index(typeid(Type)); + } + protected: - Type value{}; ///< The setting - const Type default_value{}; ///< The default value - const Type maximum{}; ///< Maximum allowed value of the setting - const Type minimum{}; ///< Minimum allowed value of the setting - const std::string label{}; ///< The setting's label + Type value{}; ///< The setting + const Type default_value{}; ///< The default value + const Type maximum{}; ///< Maximum allowed value of the setting + const Type minimum{}; ///< Minimum allowed value of the setting + const std::string label{}; ///< The setting's label + const enum Category category; ///< The setting's category AKA INI group }; /** @@ -248,35 +408,40 @@ protected: * * By default, the global setting is used. */ -template -class SwitchableSetting : virtual public Setting { +template +class SwitchableSetting : virtual public Setting { public: /** * Sets a default value, label, and setting value. * + * @param linkage Setting registry * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting + * @param category_ Category of the setting AKA INI group */ - explicit SwitchableSetting(const Type& default_val, const std::string& name) + explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, + Category category) requires(!ranged) - : Setting{default_val, name} { - global_reset_registry.push_front([this]() { this->SetGlobal(true); }); + : Setting{linkage, default_val, name, category} { + linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; /** * Sets a default value, minimum value, maximum value, and label. * + * @param linkage Setting registry * @param default_val Initial value of the setting, and default value of the setting * @param min_val Sets the minimum allowed value of the setting * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting + * @param category_ Category of the setting AKA INI group */ - explicit SwitchableSetting(const Type& default_val, const Type& min_val, const Type& max_val, - const std::string& name) + explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, + const Type& max_val, const std::string& name, Category category) requires(ranged) - : Setting{default_val, min_val, max_val, name} { - global_reset_registry.push_front([this]() { this->SetGlobal(true); }); + : Setting{linkage, default_val, min_val, max_val, name, category} { + linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } /** @@ -285,7 +450,7 @@ public: * * @param to_global Whether to use the global or custom setting. */ - void SetGlobal(bool to_global) { + void SetGlobal(bool to_global) override { use_global = to_global; } @@ -294,7 +459,7 @@ public: * * @returns The global state */ - [[nodiscard]] bool UsingGlobal() const { + [[nodiscard]] bool UsingGlobal() const override { return use_global; } @@ -333,6 +498,10 @@ public: } } + [[nodiscard]] virtual constexpr bool Switchable() const override { + return true; + } + /** * Assigns the current setting value depending on the global state. * @@ -405,211 +574,290 @@ struct TouchFromButtonMap { }; struct Values { + Linkage linkage{}; + // Audio - Setting sink_id{"auto", "output_engine"}; - Setting audio_output_device_id{"auto", "output_device"}; - Setting audio_input_device_id{"auto", "input_device"}; - Setting audio_muted{false, "audio_muted"}; - SwitchableSetting volume{100, 0, 200, "volume"}; - Setting dump_audio_commands{false, "dump_audio_commands"}; + Setting sink_id{linkage, "auto", "output_engine", Category::Audio}; + Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; + Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; + Setting audio_muted{linkage, false, "audio_muted", Category::Audio}; + SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio}; + Setting dump_audio_commands{linkage, false, "dump_audio_commands", + Category::Audio}; // Core - SwitchableSetting use_multi_core{true, "use_multi_core"}; - SwitchableSetting use_unsafe_extended_memory_layout{false, - "use_unsafe_extended_memory_layout"}; + SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; + SwitchableSetting use_unsafe_extended_memory_layout{ + linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; // Cpu - SwitchableSetting cpu_accuracy{CPUAccuracy::Auto, CPUAccuracy::Auto, - CPUAccuracy::Paranoid, "cpu_accuracy"}; + SwitchableSetting cpu_accuracy{linkage, CPUAccuracy::Auto, + CPUAccuracy::Auto, CPUAccuracy::Paranoid, + "cpu_accuracy", Category::Cpu}; // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 - Setting cpu_accuracy_first_time{true, "cpu_accuracy_first_time"}; - Setting cpu_debug_mode{false, "cpu_debug_mode"}; - - Setting cpuopt_page_tables{true, "cpuopt_page_tables"}; - Setting cpuopt_block_linking{true, "cpuopt_block_linking"}; - Setting cpuopt_return_stack_buffer{true, "cpuopt_return_stack_buffer"}; - Setting cpuopt_fast_dispatcher{true, "cpuopt_fast_dispatcher"}; - Setting cpuopt_context_elimination{true, "cpuopt_context_elimination"}; - Setting cpuopt_const_prop{true, "cpuopt_const_prop"}; - Setting cpuopt_misc_ir{true, "cpuopt_misc_ir"}; - Setting cpuopt_reduce_misalign_checks{true, "cpuopt_reduce_misalign_checks"}; - Setting cpuopt_fastmem{true, "cpuopt_fastmem"}; - Setting cpuopt_fastmem_exclusives{true, "cpuopt_fastmem_exclusives"}; - Setting cpuopt_recompile_exclusives{true, "cpuopt_recompile_exclusives"}; - Setting cpuopt_ignore_memory_aborts{true, "cpuopt_ignore_memory_aborts"}; - - SwitchableSetting cpuopt_unsafe_unfuse_fma{true, "cpuopt_unsafe_unfuse_fma"}; - SwitchableSetting cpuopt_unsafe_reduce_fp_error{true, "cpuopt_unsafe_reduce_fp_error"}; + Setting cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu}; + Setting cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::Cpu}; + + Setting cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::Cpu}; + Setting cpuopt_block_linking{linkage, true, "cpuopt_block_linking", Category::Cpu}; + Setting cpuopt_return_stack_buffer{linkage, true, "cpuopt_return_stack_buffer", + Category::Cpu}; + Setting cpuopt_fast_dispatcher{linkage, true, "cpuopt_fast_dispatcher", Category::Cpu}; + Setting cpuopt_context_elimination{linkage, true, "cpuopt_context_elimination", + Category::Cpu}; + Setting cpuopt_const_prop{linkage, true, "cpuopt_const_prop", Category::Cpu}; + Setting cpuopt_misc_ir{linkage, true, "cpuopt_misc_ir", Category::Cpu}; + Setting cpuopt_reduce_misalign_checks{linkage, true, "cpuopt_reduce_misalign_checks", + Category::Cpu}; + Setting cpuopt_fastmem{linkage, true, "cpuopt_fastmem", Category::Cpu}; + Setting cpuopt_fastmem_exclusives{linkage, true, "cpuopt_fastmem_exclusives", + Category::Cpu}; + Setting cpuopt_recompile_exclusives{linkage, true, "cpuopt_recompile_exclusives", + Category::Cpu}; + Setting cpuopt_ignore_memory_aborts{linkage, true, "cpuopt_ignore_memory_aborts", + Category::Cpu}; + + SwitchableSetting cpuopt_unsafe_unfuse_fma{linkage, true, "cpuopt_unsafe_unfuse_fma", + Category::Cpu}; + SwitchableSetting cpuopt_unsafe_reduce_fp_error{ + linkage, true, "cpuopt_unsafe_reduce_fp_error", Category::Cpu}; SwitchableSetting cpuopt_unsafe_ignore_standard_fpcr{ - true, "cpuopt_unsafe_ignore_standard_fpcr"}; - SwitchableSetting cpuopt_unsafe_inaccurate_nan{true, "cpuopt_unsafe_inaccurate_nan"}; - SwitchableSetting cpuopt_unsafe_fastmem_check{true, "cpuopt_unsafe_fastmem_check"}; + linkage, true, "cpuopt_unsafe_ignore_standard_fpcr", Category::Cpu}; + SwitchableSetting cpuopt_unsafe_inaccurate_nan{ + linkage, true, "cpuopt_unsafe_inaccurate_nan", Category::Cpu}; + SwitchableSetting cpuopt_unsafe_fastmem_check{ + linkage, true, "cpuopt_unsafe_fastmem_check", Category::Cpu}; SwitchableSetting cpuopt_unsafe_ignore_global_monitor{ - true, "cpuopt_unsafe_ignore_global_monitor"}; + linkage, true, "cpuopt_unsafe_ignore_global_monitor", Category::Cpu}; // Renderer SwitchableSetting renderer_backend{ - RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend"}; - SwitchableSetting async_presentation{false, "async_presentation"}; - SwitchableSetting renderer_force_max_clock{false, "force_max_clock"}; - Setting renderer_debug{false, "debug"}; - Setting renderer_shader_feedback{false, "shader_feedback"}; - Setting enable_nsight_aftermath{false, "nsight_aftermath"}; - Setting disable_shader_loop_safety_checks{false, "disable_shader_loop_safety_checks"}; - SwitchableSetting vulkan_device{0, "vulkan_device"}; + linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, + "backend", Category::Renderer}; + SwitchableSetting async_presentation{linkage, false, "async_presentation", + Category::AdvancedGraphics}; + SwitchableSetting renderer_force_max_clock{linkage, false, "force_max_clock", + Category::AdvancedGraphics}; + Setting renderer_debug{linkage, false, "debug", Category::Renderer}; + Setting renderer_shader_feedback{linkage, false, "shader_feedback", Category::Renderer}; + Setting enable_nsight_aftermath{linkage, false, "nsight_aftermath", Category::Renderer}; + Setting disable_shader_loop_safety_checks{ + linkage, false, "disable_shader_loop_safety_checks", Category::Renderer}; + SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer}; ResolutionScalingInfo resolution_info{}; - SwitchableSetting resolution_setup{ResolutionSetup::Res1X, "resolution_setup"}; - SwitchableSetting scaling_filter{ScalingFilter::Bilinear, "scaling_filter"}; - SwitchableSetting fsr_sharpening_slider{25, 0, 200, "fsr_sharpening_slider"}; - SwitchableSetting anti_aliasing{AntiAliasing::None, "anti_aliasing"}; + SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, + "resolution_setup", Category::Renderer}; + SwitchableSetting scaling_filter{linkage, ScalingFilter::Bilinear, + "scaling_filter", Category::Renderer}; + SwitchableSetting fsr_sharpening_slider{ + linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer}; + SwitchableSetting anti_aliasing{linkage, AntiAliasing::None, "anti_aliasing", + Category::Renderer}; // *nix platforms may have issues with the borderless windowed fullscreen mode. // Default to exclusive fullscreen on these platforms for now. - SwitchableSetting fullscreen_mode{ + SwitchableSetting fullscreen_mode{linkage, #ifdef _WIN32 - FullscreenMode::Borderless, + FullscreenMode::Borderless, #else - FullscreenMode::Exclusive, + FullscreenMode::Exclusive, #endif - FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; - SwitchableSetting aspect_ratio{0, 0, 4, "aspect_ratio"}; - SwitchableSetting max_anisotropy{0, 0, 5, "max_anisotropy"}; - SwitchableSetting use_speed_limit{true, "use_speed_limit"}; - SwitchableSetting speed_limit{100, 0, 9999, "speed_limit"}; - SwitchableSetting use_disk_shader_cache{true, "use_disk_shader_cache"}; - SwitchableSetting gpu_accuracy{GPUAccuracy::High, GPUAccuracy::Normal, - GPUAccuracy::Extreme, "gpu_accuracy"}; - SwitchableSetting use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; - SwitchableSetting nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; - SwitchableSetting accelerate_astc{ - AstcDecodeMode::CPU, AstcDecodeMode::CPU, AstcDecodeMode::CPUAsynchronous, - "accelerate_astc"}; - Setting vsync_mode{VSyncMode::FIFO, VSyncMode::Immediate, - VSyncMode::FIFORelaxed, "use_vsync"}; - SwitchableSetting use_reactive_flushing{true, "use_reactive_flushing"}; - SwitchableSetting shader_backend{ShaderBackend::GLSL, ShaderBackend::GLSL, - ShaderBackend::SPIRV, "shader_backend"}; - SwitchableSetting use_asynchronous_shaders{false, "use_asynchronous_shaders"}; - SwitchableSetting use_fast_gpu_time{true, "use_fast_gpu_time"}; - SwitchableSetting use_vulkan_driver_pipeline_cache{true, - "use_vulkan_driver_pipeline_cache"}; - SwitchableSetting enable_compute_pipelines{false, "enable_compute_pipelines"}; - SwitchableSetting astc_recompression{ - AstcRecompression::Uncompressed, AstcRecompression::Uncompressed, AstcRecompression::Bc3, - "astc_recompression"}; - SwitchableSetting use_video_framerate{false, "use_video_framerate"}; - SwitchableSetting barrier_feedback_loops{true, "barrier_feedback_loops"}; - - SwitchableSetting bg_red{0, "bg_red"}; - SwitchableSetting bg_green{0, "bg_green"}; - SwitchableSetting bg_blue{0, "bg_blue"}; + FullscreenMode::Borderless, + FullscreenMode::Exclusive, + "fullscreen_mode", + Category::Renderer}; + SwitchableSetting aspect_ratio{linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; + SwitchableSetting max_anisotropy{ + linkage, 0, 0, 5, "max_anisotropy", Category::AdvancedGraphics}; + SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", + Category::Renderer}; + SwitchableSetting speed_limit{linkage, 100, 0, + 9999, "speed_limit", Category::Renderer}; + SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", + Category::Renderer}; + SwitchableSetting gpu_accuracy{ + linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme, + "gpu_accuracy", Category::AdvancedGraphics}; + SwitchableSetting use_asynchronous_gpu_emulation{ + linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; + SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::GPU, + "nvdec_emulation", Category::Renderer}; + SwitchableSetting accelerate_astc{linkage, + AstcDecodeMode::CPU, + AstcDecodeMode::CPU, + AstcDecodeMode::CPUAsynchronous, + "accelerate_astc", + Category::Renderer}; + Setting vsync_mode{ + linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, + "use_vsync", Category::Renderer}; + SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", + Category::Renderer}; + SwitchableSetting shader_backend{ + linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, + "shader_backend", Category::Renderer}; + SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", + Category::Renderer}; + SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", + Category::AdvancedGraphics}; + SwitchableSetting use_vulkan_driver_pipeline_cache{ + linkage, true, "use_vulkan_driver_pipeline_cache", Category::AdvancedGraphics}; + SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", + Category::AdvancedGraphics}; + SwitchableSetting astc_recompression{linkage, + AstcRecompression::Uncompressed, + AstcRecompression::Uncompressed, + AstcRecompression::Bc3, + "astc_recompression", + Category::AdvancedGraphics}; + SwitchableSetting use_video_framerate{linkage, false, "use_video_framerate", + Category::AdvancedGraphics}; + SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", + Category::AdvancedGraphics}; + + SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer}; + SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer}; + SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer}; // System - SwitchableSetting rng_seed_enabled{false, "rng_seed_enabled"}; - SwitchableSetting rng_seed{0, "rng_seed"}; - Setting device_name{"Yuzu", "device_name"}; + SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System}; + SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System}; + Setting device_name{linkage, "Yuzu", "device_name", Category::System}; // Measured in seconds since epoch - SwitchableSetting custom_rtc_enabled{false, "custom_rtc_enabled"}; - SwitchableSetting custom_rtc{0, "custom_rtc"}; + Setting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", Category::System}; + Setting custom_rtc{linkage, 0, "custom_rtc", Category::System}; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` s64 custom_rtc_differential; - Setting current_user{0, "current_user"}; - SwitchableSetting language_index{1, 0, 17, "language_index"}; - SwitchableSetting region_index{1, 0, 6, "region_index"}; - SwitchableSetting time_zone_index{0, 0, 45, "time_zone_index"}; - SwitchableSetting sound_index{1, 0, 2, "sound_index"}; + Setting current_user{linkage, 0, "current_user", Category::System}; + SwitchableSetting language_index{linkage, 1, 0, 17, "language_index", + Category::System}; + SwitchableSetting region_index{linkage, 1, 0, 6, "region_index", Category::System}; + SwitchableSetting time_zone_index{linkage, 0, 0, 45, "time_zone_index", + Category::System}; + SwitchableSetting sound_index{linkage, 1, 0, 2, "sound_index", Category::System}; + + SwitchableSetting use_docked_mode{linkage, true, "use_docked_mode", Category::System}; // Controls InputSetting> players; - SwitchableSetting use_docked_mode{true, "use_docked_mode"}; - - Setting enable_raw_input{false, "enable_raw_input"}; - Setting controller_navigation{true, "controller_navigation"}; - Setting enable_joycon_driver{true, "enable_joycon_driver"}; - Setting enable_procon_driver{false, "enable_procon_driver"}; - - SwitchableSetting vibration_enabled{true, "vibration_enabled"}; - SwitchableSetting enable_accurate_vibrations{false, "enable_accurate_vibrations"}; - - SwitchableSetting motion_enabled{true, "motion_enabled"}; - Setting udp_input_servers{"127.0.0.1:26760", "udp_input_servers"}; - Setting enable_udp_controller{false, "enable_udp_controller"}; - - Setting pause_tas_on_load{true, "pause_tas_on_load"}; - Setting tas_enable{false, "tas_enable"}; - Setting tas_loop{false, "tas_loop"}; - - Setting mouse_panning{false, "mouse_panning"}; - Setting mouse_panning_x_sensitivity{50, 1, 100, "mouse_panning_x_sensitivity"}; - Setting mouse_panning_y_sensitivity{50, 1, 100, "mouse_panning_y_sensitivity"}; - Setting mouse_panning_deadzone_counterweight{20, 0, 100, - "mouse_panning_deadzone_counterweight"}; - Setting mouse_panning_decay_strength{18, 0, 100, "mouse_panning_decay_strength"}; - Setting mouse_panning_min_decay{6, 0, 100, "mouse_panning_min_decay"}; - - Setting mouse_enabled{false, "mouse_enabled"}; - Setting emulate_analog_keyboard{false, "emulate_analog_keyboard"}; - Setting keyboard_enabled{false, "keyboard_enabled"}; - - Setting debug_pad_enabled{false, "debug_pad_enabled"}; + Setting + enable_raw_input{linkage, false, "enable_raw_input", Category::Controls}; + Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; + Setting enable_joycon_driver{linkage, true, "enable_joycon_driver", Category::Controls}; + Setting enable_procon_driver{linkage, false, "enable_procon_driver", Category::Controls}; + + SwitchableSetting vibration_enabled{linkage, true, "vibration_enabled", + Category::Controls}; + SwitchableSetting enable_accurate_vibrations{linkage, false, "enable_accurate_vibrations", + Category::Controls}; + + SwitchableSetting motion_enabled{linkage, true, "motion_enabled", Category::Controls}; + Setting udp_input_servers{linkage, "127.0.0.1:26760", "udp_input_servers", + Category::Controls}; + Setting enable_udp_controller{linkage, false, "enable_udp_controller", + Category::Controls}; + + Setting pause_tas_on_load{linkage, true, "pause_tas_on_load", Category::Controls}; + Setting tas_enable{linkage, false, "tas_enable", Category::Controls}; + Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; + + Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls}; + Setting mouse_panning_sensitivity{ + linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; + Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; + + Setting mouse_panning_x_sensitivity{ + linkage, 50, 1, 100, "mouse_panning_x_sensitivity", Category::Controls}; + Setting mouse_panning_y_sensitivity{ + linkage, 50, 1, 100, "mouse_panning_y_sensitivity", Category::Controls}; + Setting mouse_panning_deadzone_counterweight{ + linkage, 20, 0, 100, "mouse_panning_deadzone_counterweight", Category::Controls}; + Setting mouse_panning_decay_strength{ + linkage, 18, 0, 100, "mouse_panning_decay_strength", Category::Controls}; + Setting mouse_panning_min_decay{ + linkage, 6, 0, 100, "mouse_panning_min_decay", Category::Controls}; + + Setting emulate_analog_keyboard{linkage, false, "emulate_analog_keyboard", + Category::Controls}; + Setting keyboard_enabled{linkage, false, "keyboard_enabled", Category::Controls}; + + Setting debug_pad_enabled{linkage, false, "debug_pad_enabled", Category::Controls}; ButtonsRaw debug_pad_buttons; AnalogsRaw debug_pad_analogs; TouchscreenInput touchscreen; - Setting touch_device{"min_x:100,min_y:50,max_x:1800,max_y:850", "touch_device"}; - Setting touch_from_button_map_index{0, "touch_from_button_map"}; + Setting touch_device{linkage, "min_x:100,min_y:50,max_x:1800,max_y:850", + "touch_device", Category::Controls}; + Setting touch_from_button_map_index{linkage, 0, "touch_from_button_map", + Category::Controls}; std::vector touch_from_button_maps; - Setting enable_ring_controller{true, "enable_ring_controller"}; + Setting enable_ring_controller{linkage, true, "enable_ring_controller", + Category::Controls}; RingconRaw ringcon_analogs; - Setting enable_ir_sensor{false, "enable_ir_sensor"}; - Setting ir_sensor_device{"auto", "ir_sensor_device"}; + Setting enable_ir_sensor{linkage, false, "enable_ir_sensor", Category::Controls}; + Setting ir_sensor_device{linkage, "auto", "ir_sensor_device", Category::Controls}; - Setting random_amiibo_id{false, "random_amiibo_id"}; + Setting random_amiibo_id{linkage, false, "random_amiibo_id", Category::Controls}; // Data Storage - Setting use_virtual_sd{true, "use_virtual_sd"}; - Setting gamecard_inserted{false, "gamecard_inserted"}; - Setting gamecard_current_game{false, "gamecard_current_game"}; - Setting gamecard_path{std::string(), "gamecard_path"}; + Setting use_virtual_sd{linkage, true, "use_virtual_sd", Category::DataStorage}; + Setting gamecard_inserted{linkage, false, "gamecard_inserted", Category::DataStorage}; + Setting gamecard_current_game{linkage, false, "gamecard_current_game", + Category::DataStorage}; + Setting gamecard_path{linkage, std::string(), "gamecard_path", + Category::DataStorage}; // Debugging bool record_frame_times; - Setting use_gdbstub{false, "use_gdbstub"}; - Setting gdbstub_port{6543, "gdbstub_port"}; - Setting program_args{std::string(), "program_args"}; - Setting dump_exefs{false, "dump_exefs"}; - Setting dump_nso{false, "dump_nso"}; - Setting dump_shaders{false, "dump_shaders"}; - Setting dump_macros{false, "dump_macros"}; - Setting enable_fs_access_log{false, "enable_fs_access_log"}; - Setting reporting_services{false, "reporting_services"}; - Setting quest_flag{false, "quest_flag"}; - Setting disable_macro_jit{false, "disable_macro_jit"}; - Setting disable_macro_hle{false, "disable_macro_hle"}; - Setting extended_logging{false, "extended_logging"}; - Setting use_debug_asserts{false, "use_debug_asserts"}; - Setting use_auto_stub{false, "use_auto_stub"}; - Setting enable_all_controllers{false, "enable_all_controllers"}; - Setting create_crash_dumps{false, "create_crash_dumps"}; - Setting perform_vulkan_check{true, "perform_vulkan_check"}; + Setting use_gdbstub{linkage, false, "use_gdbstub", Category::Debugging}; + Setting gdbstub_port{linkage, 6543, "gdbstub_port", Category::Debugging}; + Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; + Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; + Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; + Setting dump_shaders{linkage, false, "dump_shaders", Category::Debugging}; + Setting dump_macros{linkage, false, "dump_macros", Category::Debugging}; + Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; + Setting reporting_services{linkage, false, "reporting_services", + Category::Debugging}; + Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; + Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::Debugging}; + Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::Debugging}; + Setting extended_logging{linkage, false, "extended_logging", + Category::Debugging}; + Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; + Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging}; + Setting enable_all_controllers{linkage, false, "enable_all_controllers", + Category::Debugging}; + Setting create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging}; + Setting perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging}; // Miscellaneous - Setting log_filter{"*:Info", "log_filter"}; - Setting use_dev_keys{false, "use_dev_keys"}; + Setting log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous}; + Setting use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous}; // Network - Setting network_interface{std::string(), "network_interface"}; + Setting network_interface{linkage, std::string(), "network_interface", + Category::Network}; // WebService - Setting enable_telemetry{true, "enable_telemetry"}; - Setting web_api_url{"https://api.yuzu-emu.org", "web_api_url"}; - Setting yuzu_username{std::string(), "yuzu_username"}; - Setting yuzu_token{std::string(), "yuzu_token"}; + Setting enable_telemetry{linkage, true, "enable_telemetry", Category::WebService}; + Setting web_api_url{linkage, "https://api.yuzu-emu.org", "web_api_url", + Category::WebService}; + Setting yuzu_username{linkage, std::string(), "yuzu_username", + Category::WebService}; + Setting yuzu_token{linkage, std::string(), "yuzu_token", Category::WebService}; // Add-Ons std::map> disabled_addons; -- cgit v1.2.3 From a007ac6b9ccc23861f5a5c6967d535220ed794b0 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 7 May 2023 09:48:26 -0400 Subject: configure_graphics_advance: Generate UI at runtime We can iterate through the AdvancedGraphics settings and generate the UI during runtime. This doesn't help runtime efficiency, but it helps a ton in reducing the amount of work a developer needs in order to add a new setting. --- src/common/settings.h | 53 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index df4bcb053..48f86d0aa 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -20,6 +20,15 @@ namespace Settings { +enum class AnisotropyMode : u32 { + Automatic = 0, + Default = 1, + X2 = 2, + X4 = 3, + X8 = 4, + X16 = 5, +}; + enum class AstcDecodeMode : u32 { CPU = 0, GPU = 1, @@ -49,6 +58,7 @@ enum class GPUAccuracy : u32 { Normal = 0, High = 1, Extreme = 2, + MaxEnum = 3, }; enum class CPUAccuracy : u32 { @@ -166,11 +176,16 @@ public: virtual Category Category() const = 0; virtual constexpr bool Switchable() const = 0; virtual std::string ToString() const = 0; + virtual std::string ToStringGlobal() const { + return {}; + } virtual void LoadString(const std::string& load) = 0; virtual const std::string& GetLabel() const = 0; virtual std::string DefaultToString() const = 0; virtual bool Save() const = 0; virtual std::type_index TypeId() const = 0; + virtual bool IsEnum() const = 0; + virtual bool RuntimeModfiable() const = 0; virtual void SetGlobal(bool global) {} virtual bool UsingGlobal() const { return false; @@ -188,7 +203,7 @@ public: * configurations. Specifying a default value and label is required. A minimum and maximum range * can be specified for sanitization. */ -template +template class Setting : public BasicSetting { protected: Setting() = default; @@ -282,6 +297,14 @@ public: return category; } + [[nodiscard]] bool RuntimeModfiable() const override { + return runtime_modifiable; + } + + [[nodiscard]] bool IsEnum() const override { + return std::is_enum::value; + } + /** * Returns whether the current setting is Switchable. * @@ -291,7 +314,7 @@ public: return false; } -private: +protected: std::string ToString(const Type& value_) const { if constexpr (std::is_same()) { return value_; @@ -408,8 +431,8 @@ protected: * * By default, the global setting is used. */ -template -class SwitchableSetting : virtual public Setting { +template +class SwitchableSetting : virtual public Setting { public: /** * Sets a default value, label, and setting value. @@ -422,7 +445,7 @@ public: explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, Category category) requires(!ranged) - : Setting{linkage, default_val, name, category} { + : Setting{linkage, default_val, name, category} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -440,7 +463,8 @@ public: explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category) requires(ranged) - : Setting{linkage, default_val, min_val, max_val, name, category} { + : Setting{linkage, default_val, min_val, + max_val, name, category} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } @@ -502,6 +526,10 @@ public: return true; } + [[nodiscard]] virtual std::string ToStringGlobal() const override { + return this->ToString(this->value); + } + /** * Assigns the current setting value depending on the global state. * @@ -667,15 +695,16 @@ struct Values { "fullscreen_mode", Category::Renderer}; SwitchableSetting aspect_ratio{linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; - SwitchableSetting max_anisotropy{ - linkage, 0, 0, 5, "max_anisotropy", Category::AdvancedGraphics}; + SwitchableSetting max_anisotropy{ + linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, + "max_anisotropy", Category::AdvancedGraphics}; SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", Category::Renderer}; SwitchableSetting speed_limit{linkage, 100, 0, 9999, "speed_limit", Category::Renderer}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; - SwitchableSetting gpu_accuracy{ + SwitchableSetting gpu_accuracy{ linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme, "gpu_accuracy", Category::AdvancedGraphics}; SwitchableSetting use_asynchronous_gpu_emulation{ @@ -698,9 +727,9 @@ struct Values { "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::Renderer}; - SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", - Category::AdvancedGraphics}; - SwitchableSetting use_vulkan_driver_pipeline_cache{ + SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", + Category::AdvancedGraphics}; + SwitchableSetting use_vulkan_driver_pipeline_cache{ linkage, true, "use_vulkan_driver_pipeline_cache", Category::AdvancedGraphics}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::AdvancedGraphics}; -- cgit v1.2.3 From 75d7e40113c03ec6a2a83fb8cfa736a17c6862a3 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 7 May 2023 10:35:28 -0400 Subject: settings: Recategorize a bit Will help with generating config UI later. --- src/common/settings.cpp | 7 ++-- src/common/settings.h | 87 ++++++++++++++++++++++++++++--------------------- 2 files changed, 54 insertions(+), 40 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 59934803e..38a82f6f7 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -151,14 +151,19 @@ const char* TranslateCategory(Category category) { case Category::Core: return "Core"; case Category::Cpu: + case Category::CpuDebug: + case Category::CpuUnsafe: return "Cpu"; case Category::Renderer: + case Category::RendererAdvanced: + case Category::RendererDebug: return "Renderer"; case Category::System: return "System"; case Category::DataStorage: return "Data Storage"; case Category::Debugging: + case Category::DebuggingGraphics: return "Debugging"; case Category::Miscellaneous: return "Miscellaneous"; @@ -188,8 +193,6 @@ const char* TranslateCategory(Category category) { return "Paths"; case Category::MaxEnum: break; - case Category::AdvancedGraphics: - return "Renderer"; } return "Miscellaneous"; } diff --git a/src/common/settings.h b/src/common/settings.h index 48f86d0aa..70ab8d584 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -120,11 +120,15 @@ enum class Category : u32 { Audio, Core, Cpu, + CpuDebug, + CpuUnsafe, Renderer, - AdvancedGraphics, + RendererAdvanced, + RendererDebug, System, DataStorage, Debugging, + DebuggingGraphics, Miscellaneous, Network, WebService, @@ -624,53 +628,56 @@ struct Values { "cpu_accuracy", Category::Cpu}; // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 Setting cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu}; - Setting cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::Cpu}; + Setting cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::CpuDebug}; - Setting cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::Cpu}; - Setting cpuopt_block_linking{linkage, true, "cpuopt_block_linking", Category::Cpu}; + Setting cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::CpuDebug}; + Setting cpuopt_block_linking{linkage, true, "cpuopt_block_linking", Category::CpuDebug}; Setting cpuopt_return_stack_buffer{linkage, true, "cpuopt_return_stack_buffer", - Category::Cpu}; - Setting cpuopt_fast_dispatcher{linkage, true, "cpuopt_fast_dispatcher", Category::Cpu}; + Category::CpuDebug}; + Setting cpuopt_fast_dispatcher{linkage, true, "cpuopt_fast_dispatcher", + Category::CpuDebug}; Setting cpuopt_context_elimination{linkage, true, "cpuopt_context_elimination", - Category::Cpu}; - Setting cpuopt_const_prop{linkage, true, "cpuopt_const_prop", Category::Cpu}; - Setting cpuopt_misc_ir{linkage, true, "cpuopt_misc_ir", Category::Cpu}; + Category::CpuDebug}; + Setting cpuopt_const_prop{linkage, true, "cpuopt_const_prop", Category::CpuDebug}; + Setting cpuopt_misc_ir{linkage, true, "cpuopt_misc_ir", Category::CpuDebug}; Setting cpuopt_reduce_misalign_checks{linkage, true, "cpuopt_reduce_misalign_checks", - Category::Cpu}; - Setting cpuopt_fastmem{linkage, true, "cpuopt_fastmem", Category::Cpu}; + Category::CpuDebug}; + Setting cpuopt_fastmem{linkage, true, "cpuopt_fastmem", Category::CpuDebug}; Setting cpuopt_fastmem_exclusives{linkage, true, "cpuopt_fastmem_exclusives", - Category::Cpu}; + Category::CpuDebug}; Setting cpuopt_recompile_exclusives{linkage, true, "cpuopt_recompile_exclusives", - Category::Cpu}; + Category::CpuDebug}; Setting cpuopt_ignore_memory_aborts{linkage, true, "cpuopt_ignore_memory_aborts", - Category::Cpu}; + Category::CpuDebug}; SwitchableSetting cpuopt_unsafe_unfuse_fma{linkage, true, "cpuopt_unsafe_unfuse_fma", - Category::Cpu}; + Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_reduce_fp_error{ - linkage, true, "cpuopt_unsafe_reduce_fp_error", Category::Cpu}; + linkage, true, "cpuopt_unsafe_reduce_fp_error", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_ignore_standard_fpcr{ - linkage, true, "cpuopt_unsafe_ignore_standard_fpcr", Category::Cpu}; + linkage, true, "cpuopt_unsafe_ignore_standard_fpcr", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_inaccurate_nan{ - linkage, true, "cpuopt_unsafe_inaccurate_nan", Category::Cpu}; + linkage, true, "cpuopt_unsafe_inaccurate_nan", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_fastmem_check{ - linkage, true, "cpuopt_unsafe_fastmem_check", Category::Cpu}; + linkage, true, "cpuopt_unsafe_fastmem_check", Category::CpuUnsafe}; SwitchableSetting cpuopt_unsafe_ignore_global_monitor{ - linkage, true, "cpuopt_unsafe_ignore_global_monitor", Category::Cpu}; + linkage, true, "cpuopt_unsafe_ignore_global_monitor", Category::CpuUnsafe}; // Renderer SwitchableSetting renderer_backend{ linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend", Category::Renderer}; SwitchableSetting async_presentation{linkage, false, "async_presentation", - Category::AdvancedGraphics}; + Category::RendererAdvanced}; SwitchableSetting renderer_force_max_clock{linkage, false, "force_max_clock", - Category::AdvancedGraphics}; - Setting renderer_debug{linkage, false, "debug", Category::Renderer}; - Setting renderer_shader_feedback{linkage, false, "shader_feedback", Category::Renderer}; - Setting enable_nsight_aftermath{linkage, false, "nsight_aftermath", Category::Renderer}; + Category::RendererAdvanced}; + Setting renderer_debug{linkage, false, "debug", Category::RendererDebug}; + Setting renderer_shader_feedback{linkage, false, "shader_feedback", + Category::RendererDebug}; + Setting enable_nsight_aftermath{linkage, false, "nsight_aftermath", + Category::RendererDebug}; Setting disable_shader_loop_safety_checks{ - linkage, false, "disable_shader_loop_safety_checks", Category::Renderer}; + linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer}; ResolutionScalingInfo resolution_info{}; @@ -697,7 +704,7 @@ struct Values { SwitchableSetting aspect_ratio{linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; SwitchableSetting max_anisotropy{ linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, - "max_anisotropy", Category::AdvancedGraphics}; + "max_anisotropy", Category::RendererAdvanced}; SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", Category::Renderer}; SwitchableSetting speed_limit{linkage, 100, 0, @@ -706,7 +713,7 @@ struct Values { Category::Renderer}; SwitchableSetting gpu_accuracy{ linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme, - "gpu_accuracy", Category::AdvancedGraphics}; + "gpu_accuracy", Category::RendererAdvanced}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::GPU, @@ -728,21 +735,21 @@ struct Values { SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::Renderer}; SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", - Category::AdvancedGraphics}; + Category::RendererAdvanced}; SwitchableSetting use_vulkan_driver_pipeline_cache{ - linkage, true, "use_vulkan_driver_pipeline_cache", Category::AdvancedGraphics}; + linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", - Category::AdvancedGraphics}; + Category::RendererAdvanced}; SwitchableSetting astc_recompression{linkage, AstcRecompression::Uncompressed, AstcRecompression::Uncompressed, AstcRecompression::Bc3, "astc_recompression", - Category::AdvancedGraphics}; + Category::RendererAdvanced}; SwitchableSetting use_video_framerate{linkage, false, "use_video_framerate", - Category::AdvancedGraphics}; + Category::RendererAdvanced}; SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", - Category::AdvancedGraphics}; + Category::RendererAdvanced}; SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer}; SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer}; @@ -855,14 +862,18 @@ struct Values { Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; - Setting dump_shaders{linkage, false, "dump_shaders", Category::Debugging}; - Setting dump_macros{linkage, false, "dump_macros", Category::Debugging}; + Setting dump_shaders{linkage, false, "dump_shaders", + Category::DebuggingGraphics}; + Setting dump_macros{linkage, false, "dump_macros", + Category::DebuggingGraphics}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; Setting reporting_services{linkage, false, "reporting_services", Category::Debugging}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; - Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::Debugging}; - Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::Debugging}; + Setting disable_macro_jit{linkage, false, "disable_macro_jit", + Category::DebuggingGraphics}; + Setting disable_macro_hle{linkage, false, "disable_macro_hle", + Category::DebuggingGraphics}; Setting extended_logging{linkage, false, "extended_logging", Category::Debugging}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; -- cgit v1.2.3 From f8435d676f0073dee4d2ea87c84767a53911fbe6 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 7 May 2023 12:03:40 -0400 Subject: configure_graphics: Partial runtime implementation --- src/common/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 70ab8d584..8f02fa9af 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -733,7 +733,7 @@ struct Values { linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", - Category::Renderer}; + Category::RendererAdvanced}; SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", Category::RendererAdvanced}; SwitchableSetting use_vulkan_driver_pipeline_cache{ -- cgit v1.2.3 From bafd569b4768d3888798db8b8e71359b4b844579 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 7 May 2023 12:51:12 -0400 Subject: settings,uisettings: Add IDs to settings --- src/common/settings.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 8f02fa9af..69777421e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -191,6 +191,7 @@ public: virtual bool IsEnum() const = 0; virtual bool RuntimeModfiable() const = 0; virtual void SetGlobal(bool global) {} + virtual u32 Id() const = 0; virtual bool UsingGlobal() const { return false; } @@ -200,6 +201,7 @@ class Linkage { public: std::map> by_category; std::vector> restore_functions; + u32 count; }; /** The Setting class is a simple resource manager. It defines a label and default value @@ -232,8 +234,10 @@ public: explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, enum Category category_) requires(!ranged) - : value{default_val}, default_value{default_val}, label{name}, category{category_} { + : value{default_val}, + default_value{default_val}, label{name}, category{category_}, id{linkage.count} { linkage.by_category[category].push_front(this); + linkage.count++; } virtual ~Setting() = default; @@ -251,8 +255,9 @@ public: const Type& max_val, const std::string& name, enum Category category_) requires(ranged) : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, - label{name}, category{category_} { + label{name}, category{category_}, id{linkage.count} { linkage.by_category[category].push_front(this); + linkage.count++; } /** @@ -418,6 +423,10 @@ public: return std::type_index(typeid(Type)); } + virtual u32 Id() const override { + return id; + } + protected: Type value{}; ///< The setting const Type default_value{}; ///< The default value @@ -425,6 +434,7 @@ protected: const Type minimum{}; ///< Minimum allowed value of the setting const std::string label{}; ///< The setting's label const enum Category category; ///< The setting's category AKA INI group + const u32 id; }; /** @@ -728,7 +738,7 @@ struct Values { linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, "use_vsync", Category::Renderer}; SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", - Category::Renderer}; + Category::RendererAdvanced}; SwitchableSetting shader_backend{ linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, "shader_backend", Category::Renderer}; -- cgit v1.2.3 From cfb63c68dbdc2c8add45cddb2cedf371059af6c4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 7 May 2023 13:28:52 -0400 Subject: shared_translation: Finish using int ids --- src/common/settings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 69777421e..a90fc87a7 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -191,7 +191,7 @@ public: virtual bool IsEnum() const = 0; virtual bool RuntimeModfiable() const = 0; virtual void SetGlobal(bool global) {} - virtual u32 Id() const = 0; + virtual constexpr u32 Id() const = 0; virtual bool UsingGlobal() const { return false; } @@ -423,7 +423,7 @@ public: return std::type_index(typeid(Type)); } - virtual u32 Id() const override { + virtual constexpr u32 Id() const override { return id; } -- cgit v1.2.3 From a4de202cbd5abdf46c48663874e34bdd028b6df5 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 7 May 2023 17:41:30 -0400 Subject: settings: Add anisotropy mode enum --- src/common/settings.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index a90fc87a7..1c26081c9 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -116,6 +116,14 @@ enum class AstcRecompression : u32 { Bc3 = 2, }; +enum class AspectRatio : u32 { + R16_9, + R4_3, + R21_9, + R16_10, + Stretch, +}; + enum class Category : u32 { Audio, Core, -- cgit v1.2.3 From 3a7a5edceaec30b0c34c492724068a8dc20eb181 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 8 May 2023 10:03:40 -0400 Subject: settings: Define base renderer runtime modifiable settings --- src/common/settings.h | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 1c26081c9..2879237cc 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -701,32 +701,33 @@ struct Values { ResolutionScalingInfo resolution_info{}; SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{linkage, ScalingFilter::Bilinear, - "scaling_filter", Category::Renderer}; - SwitchableSetting fsr_sharpening_slider{ + SwitchableSetting scaling_filter{ + linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer}; + SwitchableSetting fsr_sharpening_slider{ linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer}; - SwitchableSetting anti_aliasing{linkage, AntiAliasing::None, "anti_aliasing", - Category::Renderer}; + SwitchableSetting anti_aliasing{ + linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer}; // *nix platforms may have issues with the borderless windowed fullscreen mode. // Default to exclusive fullscreen on these platforms for now. - SwitchableSetting fullscreen_mode{linkage, + SwitchableSetting fullscreen_mode{linkage, #ifdef _WIN32 - FullscreenMode::Borderless, + FullscreenMode::Borderless, #else - FullscreenMode::Exclusive, + FullscreenMode::Exclusive, #endif - FullscreenMode::Borderless, - FullscreenMode::Exclusive, - "fullscreen_mode", - Category::Renderer}; - SwitchableSetting aspect_ratio{linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; + FullscreenMode::Borderless, + FullscreenMode::Exclusive, + "fullscreen_mode", + Category::Renderer}; + SwitchableSetting aspect_ratio{ + linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; SwitchableSetting max_anisotropy{ linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, "max_anisotropy", Category::RendererAdvanced}; - SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", - Category::Renderer}; - SwitchableSetting speed_limit{linkage, 100, 0, - 9999, "speed_limit", Category::Renderer}; + SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", + Category::Renderer}; + SwitchableSetting speed_limit{ + linkage, 100, 0, 9999, "speed_limit", Category::Renderer}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; SwitchableSetting gpu_accuracy{ @@ -742,7 +743,7 @@ struct Values { AstcDecodeMode::CPUAsynchronous, "accelerate_astc", Category::Renderer}; - Setting vsync_mode{ + Setting vsync_mode{ linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, "use_vsync", Category::Renderer}; SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", @@ -769,9 +770,9 @@ struct Values { SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", Category::RendererAdvanced}; - SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer}; - SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer}; - SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer}; + SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer}; + SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer}; + SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer}; // System SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System}; -- cgit v1.2.3 From d35577d3ed0bfc56ddf85a2e8b163d9d02bec809 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 8 May 2023 17:33:10 -0400 Subject: configuration: Implement slider --- src/common/settings.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 2879237cc..4ca8299b3 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -200,6 +200,8 @@ public: virtual bool RuntimeModfiable() const = 0; virtual void SetGlobal(bool global) {} virtual constexpr u32 Id() const = 0; + virtual std::string MinVal() const = 0; + virtual std::string MaxVal() const = 0; virtual bool UsingGlobal() const { return false; } @@ -336,7 +338,7 @@ protected: if constexpr (std::is_same()) { return value_; } else if constexpr (std::is_same>()) { - return value_.has_value() ? std::to_string(*value_) : "0"; + return value_.has_value() ? std::to_string(*value_) : "none"; } else if constexpr (std::is_same()) { return value_ ? "true" : "false"; } else { @@ -401,7 +403,7 @@ public: if constexpr (std::is_same()) { this->SetValue(input); } else if constexpr (std::is_same>()) { - this->SetValue(static_cast(std::stoll(input))); + this->SetValue(static_cast(std::stoul(input))); } else if constexpr (std::is_same()) { this->SetValue(input == "true"); } else { @@ -435,6 +437,13 @@ public: return id; } + virtual std::string MinVal() const override { + return this->ToString(minimum); + } + virtual std::string MaxVal() const override { + return this->ToString(maximum); + } + protected: Type value{}; ///< The setting const Type default_value{}; ///< The default value -- cgit v1.2.3 From 464aad52cd644bdc32ca4eb35b0ce669c3b30c4f Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 01:35:25 -0400 Subject: settings: Add UiGeneral class --- src/common/settings.cpp | 4 ++++ src/common/settings.h | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 38a82f6f7..b7a0c063f 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -144,6 +144,9 @@ float Volume() { return values.volume.GetValue() / static_cast(values.volume.GetDefault()); } +Linkage::Linkage() = default; +Linkage::~Linkage() = default; + const char* TranslateCategory(Category category) { switch (category) { case Category::Audio: @@ -176,6 +179,7 @@ const char* TranslateCategory(Category category) { case Category::Controls: return "Controls"; case Category::Ui: + case Category::UiGeneral: return "UI"; case Category::UiLayout: return "UiLayout"; diff --git a/src/common/settings.h b/src/common/settings.h index 4ca8299b3..e60105059 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -143,6 +143,7 @@ enum class Category : u32 { AddOns, Controls, Ui, + UiGeneral, UiLayout, UiGameList, Screenshots, @@ -209,8 +210,10 @@ public: class Linkage { public: - std::map> by_category; - std::vector> restore_functions; + explicit Linkage(); + ~Linkage(); + std::map> by_category{}; + std::vector> restore_functions{}; u32 count; }; -- cgit v1.2.3 From cdb5dea26959001f9cf7448fcdb612475045a313 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 16:21:24 -0400 Subject: settings: Move runtime and save to parameters These don't need to be whole new types. --- src/common/settings.h | 148 +++++++++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 63 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index e60105059..fdadb06a1 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -222,7 +222,7 @@ public: * configurations. Specifying a default value and label is required. A minimum and maximum range * can be specified for sanitization. */ -template +template class Setting : public BasicSetting { protected: Setting() = default; @@ -245,10 +245,10 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_) + enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : value{default_val}, - default_value{default_val}, label{name}, category{category_}, id{linkage.count} { + : value{default_val}, default_value{default_val}, label{name}, category{category_}, + id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -265,10 +265,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, enum Category category_) + const Type& max_val, const std::string& name, enum Category category_, + bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, - label{name}, category{category_}, id{linkage.count} { + label{name}, category{category_}, id{linkage.count}, save{save_}, + runtime_modifiable{runtime_modifiable_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -455,6 +457,8 @@ protected: const std::string label{}; ///< The setting's label const enum Category category; ///< The setting's category AKA INI group const u32 id; + bool save; + bool runtime_modifiable; }; /** @@ -465,8 +469,8 @@ protected: * * By default, the global setting is used. */ -template -class SwitchableSetting : virtual public Setting { +template +class SwitchableSetting : virtual public Setting { public: /** * Sets a default value, label, and setting value. @@ -477,9 +481,9 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category) + Category category, bool save = true, bool runtime_modifiable = false) requires(!ranged) - : Setting{linkage, default_val, name, category} { + : Setting{linkage, default_val, name, category, save, runtime_modifiable} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -495,10 +499,11 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, Category category) + const Type& max_val, const std::string& name, Category category, + bool save = true, bool runtime_modifiable = false) requires(ranged) - : Setting{linkage, default_val, min_val, - max_val, name, category} { + : Setting{linkage, default_val, min_val, max_val, + name, category, save, runtime_modifiable} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } @@ -642,10 +647,10 @@ struct Values { Setting sink_id{linkage, "auto", "output_engine", Category::Audio}; Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; - Setting audio_muted{linkage, false, "audio_muted", Category::Audio}; + Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio}; - Setting dump_audio_commands{linkage, false, "dump_audio_commands", - Category::Audio}; + Setting dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio, + false}; // Core SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; @@ -713,38 +718,51 @@ struct Values { ResolutionScalingInfo resolution_info{}; SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{ - linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer}; - SwitchableSetting fsr_sharpening_slider{ - linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer}; - SwitchableSetting anti_aliasing{ - linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer}; + SwitchableSetting scaling_filter{ + linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; + SwitchableSetting fsr_sharpening_slider{ + linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; + SwitchableSetting anti_aliasing{ + linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; // *nix platforms may have issues with the borderless windowed fullscreen mode. // Default to exclusive fullscreen on these platforms for now. - SwitchableSetting fullscreen_mode{linkage, + SwitchableSetting fullscreen_mode{linkage, #ifdef _WIN32 - FullscreenMode::Borderless, + FullscreenMode::Borderless, #else - FullscreenMode::Exclusive, + FullscreenMode::Exclusive, #endif - FullscreenMode::Borderless, - FullscreenMode::Exclusive, - "fullscreen_mode", - Category::Renderer}; - SwitchableSetting aspect_ratio{ - linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; + FullscreenMode::Borderless, + FullscreenMode::Exclusive, + "fullscreen_mode", + Category::Renderer, + true, + true}; + SwitchableSetting aspect_ratio{linkage, + AspectRatio::R16_9, + AspectRatio::R16_9, + AspectRatio::Stretch, + "aspect_ratio", + Category::Renderer, + true, + true}; SwitchableSetting max_anisotropy{ linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, "max_anisotropy", Category::RendererAdvanced}; - SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", - Category::Renderer}; - SwitchableSetting speed_limit{ - linkage, 100, 0, 9999, "speed_limit", Category::Renderer}; + SwitchableSetting use_speed_limit{ + linkage, true, "use_speed_limit", Category::Renderer, false, true}; + SwitchableSetting speed_limit{ + linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; - SwitchableSetting gpu_accuracy{ - linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme, - "gpu_accuracy", Category::RendererAdvanced}; + SwitchableSetting gpu_accuracy{linkage, + GPUAccuracy::High, + GPUAccuracy::Normal, + GPUAccuracy::Extreme, + "gpu_accuracy", + Category::RendererAdvanced, + true, + true}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::GPU, @@ -755,9 +773,14 @@ struct Values { AstcDecodeMode::CPUAsynchronous, "accelerate_astc", Category::Renderer}; - Setting vsync_mode{ - linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, - "use_vsync", Category::Renderer}; + Setting vsync_mode{linkage, + VSyncMode::FIFO, + VSyncMode::Immediate, + VSyncMode::FIFORelaxed, + "use_vsync", + Category::Renderer, + true, + true}; SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", Category::RendererAdvanced}; SwitchableSetting shader_backend{ @@ -765,10 +788,10 @@ struct Values { "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; - SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", - Category::RendererAdvanced}; - SwitchableSetting use_vulkan_driver_pipeline_cache{ - linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced}; + SwitchableSetting use_fast_gpu_time{ + linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, true, true}; + SwitchableSetting use_vulkan_driver_pipeline_cache{ + linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::RendererAdvanced}; SwitchableSetting astc_recompression{linkage, @@ -782,9 +805,9 @@ struct Values { SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", Category::RendererAdvanced}; - SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer}; - SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer}; - SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer}; + SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer, true, true}; + SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer, true, true}; + SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; // System SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System}; @@ -809,15 +832,14 @@ struct Values { // Controls InputSetting> players; - Setting enable_raw_input{linkage, false, "enable_raw_input", Category::Controls, // Only read/write enable_raw_input on Windows platforms #ifdef _WIN32 - true + true #else - false + false #endif - > - enable_raw_input{linkage, false, "enable_raw_input", Category::Controls}; + }; Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; Setting enable_joycon_driver{linkage, true, "enable_joycon_driver", Category::Controls}; Setting enable_procon_driver{linkage, false, "enable_procon_driver", Category::Controls}; @@ -837,7 +859,7 @@ struct Values { Setting tas_enable{linkage, false, "tas_enable", Category::Controls}; Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; - Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls}; + Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls, false}; Setting mouse_panning_sensitivity{ linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; @@ -893,22 +915,22 @@ struct Values { Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; - Setting dump_shaders{linkage, false, "dump_shaders", - Category::DebuggingGraphics}; - Setting dump_macros{linkage, false, "dump_macros", - Category::DebuggingGraphics}; + Setting dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics, + false}; + Setting dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics, + false}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; - Setting reporting_services{linkage, false, "reporting_services", - Category::Debugging}; + Setting reporting_services{linkage, false, "reporting_services", + Category::Debugging, false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::DebuggingGraphics}; - Setting extended_logging{linkage, false, "extended_logging", - Category::Debugging}; + Setting extended_logging{linkage, false, "extended_logging", Category::Debugging, + false}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; - Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging}; + Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false}; Setting enable_all_controllers{linkage, false, "enable_all_controllers", Category::Debugging}; Setting create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging}; -- cgit v1.2.3 From 8e151460265f04c7bf4a981b5f97f252a0444c27 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 10 May 2023 17:57:25 -0400 Subject: configure_system: Implement with for loop --- src/common/settings.cpp | 1 + src/common/settings.h | 114 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 103 insertions(+), 12 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index b7a0c063f..605fe7f86 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -162,6 +162,7 @@ const char* TranslateCategory(Category category) { case Category::RendererDebug: return "Renderer"; case Category::System: + case Category::SystemAudio: return "System"; case Category::DataStorage: return "Data Storage"; diff --git a/src/common/settings.h b/src/common/settings.h index fdadb06a1..1f95bd7d5 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -20,6 +20,86 @@ namespace Settings { +enum class Language : u32 { + Japanese, + EnglishAmerican, + French, + German, + Italian, + Spanish, + Chinese, + Korean, + Dutch, + Portuguese, + Russian, + Taiwanese, + EnglishBritish, + FrenchCanadian, + SpanishLatin, + ChineseSimplified, + ChineseTraditional, + PortugueseBrazilian, +}; + +enum class Region : u32 { + Japan, + USA, + Europe, + Australia, + China, + Korea, + Taiwan, +}; + +enum class TimeZone : u32 { + Auto, + Default, + CET, + CST6CDT, + Cuba, + EET, + Egypt, + Eire, + EST, + EST5EDT, + GB, + GBEire, + GMT, + GMTPlusZero, + GMTMinusZero, + GMTZero, + Greenwich, + Hongkong, + HST, + Iceland, + Iran, + Israel, + Jamaica, + Japan, + Kwajalein, + Libya, + MET, + MST, + MST7MDT, + Navajo, + NZ, + NZCHAT, + Poland, + Portugal, + PRC, + PST8PDT, + ROC, + ROK, + Singapore, + Turkey, + UCT, + Universal, + UTC, + W_SU, + WET, + Zulu, +}; + enum class AnisotropyMode : u32 { Automatic = 0, Default = 1, @@ -134,6 +214,7 @@ enum class Category : u32 { RendererAdvanced, RendererDebug, System, + SystemAudio, DataStorage, Debugging, DebuggingGraphics, @@ -810,22 +891,31 @@ struct Values { SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; // System - SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System}; - SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System}; - Setting device_name{linkage, "Yuzu", "device_name", Category::System}; + SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", + Category::System, true, true}; + SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, true, true}; + Setting device_name{linkage, "Yuzu", "device_name", Category::System, true, true}; // Measured in seconds since epoch - Setting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", Category::System}; - Setting custom_rtc{linkage, 0, "custom_rtc", Category::System}; + SwitchableSetting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", + Category::System, true, true}; + SwitchableSetting custom_rtc{linkage, 0, "custom_rtc", Category::System, true, true}; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` s64 custom_rtc_differential; Setting current_user{linkage, 0, "current_user", Category::System}; - SwitchableSetting language_index{linkage, 1, 0, 17, "language_index", - Category::System}; - SwitchableSetting region_index{linkage, 1, 0, 6, "region_index", Category::System}; - SwitchableSetting time_zone_index{linkage, 0, 0, 45, "time_zone_index", - Category::System}; - SwitchableSetting sound_index{linkage, 1, 0, 2, "sound_index", Category::System}; + SwitchableSetting language_index{linkage, + Language::EnglishAmerican, + Language::Japanese, + Language::PortugueseBrazilian, + "language_index", + Category::System}; + SwitchableSetting region_index{linkage, Region::USA, Region::Japan, + Region::Taiwan, "region_index", Category::System}; + SwitchableSetting time_zone_index{linkage, TimeZone::Auto, + TimeZone::Auto, TimeZone::Zulu, + "time_zone_index", Category::System}; + SwitchableSetting sound_index{ + linkage, 1, 0, 2, "sound_index", Category::SystemAudio}; SwitchableSetting use_docked_mode{linkage, true, "use_docked_mode", Category::System}; @@ -837,7 +927,7 @@ struct Values { #ifdef _WIN32 true #else - false + false #endif }; Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; -- cgit v1.2.3 From 4c4bc134a90a248435786b1dff4f514d1c9c4464 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 16:53:01 -0400 Subject: settings, uisettings: Initialize linkage counter --- src/common/settings.cpp | 2 +- src/common/settings.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 605fe7f86..c8651925e 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -144,7 +144,7 @@ float Volume() { return values.volume.GetValue() / static_cast(values.volume.GetDefault()); } -Linkage::Linkage() = default; +Linkage::Linkage(u32 initial_count) : count{initial_count} {} Linkage::~Linkage() = default; const char* TranslateCategory(Category category) { diff --git a/src/common/settings.h b/src/common/settings.h index 1f95bd7d5..51708706b 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -291,7 +291,7 @@ public: class Linkage { public: - explicit Linkage(); + explicit Linkage(u32 initial_count = 0); ~Linkage(); std::map> by_category{}; std::vector> restore_functions{}; -- cgit v1.2.3 From 88d3de4e85751b32faa577345a828994575d2eb1 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 6 Jun 2023 01:31:43 -0400 Subject: settings: Split enums to new file --- src/common/CMakeLists.txt | 1 + src/common/settings.h | 189 +---------------------------------- src/common/settings_enums.h | 237 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+), 186 deletions(-) create mode 100644 src/common/settings_enums.h (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3adf13a3f..5902dd617 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -110,6 +110,7 @@ add_library(common STATIC scratch_buffer.h settings.cpp settings.h + settings_enums.h settings_input.cpp settings_input.h socket_types.h diff --git a/src/common/settings.h b/src/common/settings.h index 51708706b..0ac5078c6 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -16,194 +16,11 @@ #include #include "common/common_types.h" +#include "common/settings_enums.h" #include "common/settings_input.h" namespace Settings { -enum class Language : u32 { - Japanese, - EnglishAmerican, - French, - German, - Italian, - Spanish, - Chinese, - Korean, - Dutch, - Portuguese, - Russian, - Taiwanese, - EnglishBritish, - FrenchCanadian, - SpanishLatin, - ChineseSimplified, - ChineseTraditional, - PortugueseBrazilian, -}; - -enum class Region : u32 { - Japan, - USA, - Europe, - Australia, - China, - Korea, - Taiwan, -}; - -enum class TimeZone : u32 { - Auto, - Default, - CET, - CST6CDT, - Cuba, - EET, - Egypt, - Eire, - EST, - EST5EDT, - GB, - GBEire, - GMT, - GMTPlusZero, - GMTMinusZero, - GMTZero, - Greenwich, - Hongkong, - HST, - Iceland, - Iran, - Israel, - Jamaica, - Japan, - Kwajalein, - Libya, - MET, - MST, - MST7MDT, - Navajo, - NZ, - NZCHAT, - Poland, - Portugal, - PRC, - PST8PDT, - ROC, - ROK, - Singapore, - Turkey, - UCT, - Universal, - UTC, - W_SU, - WET, - Zulu, -}; - -enum class AnisotropyMode : u32 { - Automatic = 0, - Default = 1, - X2 = 2, - X4 = 3, - X8 = 4, - X16 = 5, -}; - -enum class AstcDecodeMode : u32 { - CPU = 0, - GPU = 1, - CPUAsynchronous = 2, -}; - -enum class VSyncMode : u32 { - Immediate = 0, - Mailbox = 1, - FIFO = 2, - FIFORelaxed = 3, -}; - -enum class RendererBackend : u32 { - OpenGL = 0, - Vulkan = 1, - Null = 2, -}; - -enum class ShaderBackend : u32 { - GLSL = 0, - GLASM = 1, - SPIRV = 2, -}; - -enum class GPUAccuracy : u32 { - Normal = 0, - High = 1, - Extreme = 2, - MaxEnum = 3, -}; - -enum class CPUAccuracy : u32 { - Auto = 0, - Accurate = 1, - Unsafe = 2, - Paranoid = 3, -}; - -enum class FullscreenMode : u32 { - Borderless = 0, - Exclusive = 1, -}; - -enum class NvdecEmulation : u32 { - Off = 0, - CPU = 1, - GPU = 2, -}; - -enum class ResolutionSetup : u32 { - Res1_2X = 0, - Res3_4X = 1, - Res1X = 2, - Res3_2X = 3, - Res2X = 4, - Res3X = 5, - Res4X = 6, - Res5X = 7, - Res6X = 8, - Res7X = 9, - Res8X = 10, -}; - -enum class ScalingFilter : u32 { - NearestNeighbor = 0, - Bilinear = 1, - Bicubic = 2, - Gaussian = 3, - ScaleForce = 4, - Fsr = 5, - LastFilter = Fsr, -}; - -enum class AntiAliasing : u32 { - None = 0, - Fxaa = 1, - Smaa = 2, - LastAA = Smaa, -}; - -enum class AstcRecompression : u32 { - Uncompressed = 0, - Bc1 = 1, - Bc3 = 2, -}; - -enum class AspectRatio : u32 { - R16_9, - R4_3, - R21_9, - R16_10, - Stretch, -}; - enum class Category : u32 { Audio, Core, @@ -278,7 +95,7 @@ public: virtual std::string DefaultToString() const = 0; virtual bool Save() const = 0; virtual std::type_index TypeId() const = 0; - virtual bool IsEnum() const = 0; + virtual constexpr bool IsEnum() const = 0; virtual bool RuntimeModfiable() const = 0; virtual void SetGlobal(bool global) {} virtual constexpr u32 Id() const = 0; @@ -406,7 +223,7 @@ public: return runtime_modifiable; } - [[nodiscard]] bool IsEnum() const override { + [[nodiscard]] constexpr bool IsEnum() const override { return std::is_enum::value; } diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h new file mode 100644 index 000000000..f48fb7bd4 --- /dev/null +++ b/src/common/settings_enums.h @@ -0,0 +1,237 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include +#include "common/common_types.h" + +namespace Settings { + +enum class AudioEngine : u32 { + Auto, + Cubeb, + Sdl2, + Null, +}; + +enum class AudioMode : u32 { + Mono, + Stereo, + Surround, +}; + +enum class Language : u32 { + Japanese, + EnglishAmerican, + French, + German, + Italian, + Spanish, + Chinese, + Korean, + Dutch, + Portuguese, + Russian, + Taiwanese, + EnglishBritish, + FrenchCanadian, + SpanishLatin, + ChineseSimplified, + ChineseTraditional, + PortugueseBrazilian, +}; + +enum class Region : u32 { + Japan, + USA, + Europe, + Australia, + China, + Korea, + Taiwan, +}; + +enum class TimeZone : u32 { + Auto, + Default, + CET, + CST6CDT, + Cuba, + EET, + Egypt, + Eire, + EST, + EST5EDT, + GB, + GBEire, + GMT, + GMTPlusZero, + GMTMinusZero, + GMTZero, + Greenwich, + Hongkong, + HST, + Iceland, + Iran, + Israel, + Jamaica, + Japan, + Kwajalein, + Libya, + MET, + MST, + MST7MDT, + Navajo, + NZ, + NZCHAT, + Poland, + Portugal, + PRC, + PST8PDT, + ROC, + ROK, + Singapore, + Turkey, + UCT, + Universal, + UTC, + W_SU, + WET, + Zulu, +}; + +enum class AnisotropyMode : u32 { + Automatic = 0, + Default = 1, + X2 = 2, + X4 = 3, + X8 = 4, + X16 = 5, +}; + +enum class AstcDecodeMode : u32 { + CPU = 0, + GPU = 1, + CPUAsynchronous = 2, +}; + +enum class AstcRecompression : u32 { + Uncompressed = 0, + Bc1 = 1, + Bc3 = 2, +}; + +enum class VSyncMode : u32 { + Immediate = 0, + Mailbox = 1, + FIFO = 2, + FIFORelaxed = 3, +}; + +enum class RendererBackend : u32 { + OpenGL = 0, + Vulkan = 1, + Null = 2, +}; + +enum class ShaderBackend : u32 { + GLSL = 0, + GLASM = 1, + SPIRV = 2, +}; + +enum class GPUAccuracy : u32 { + Normal = 0, + High = 1, + Extreme = 2, + MaxEnum = 3, +}; + +enum class CPUAccuracy : u32 { + Auto = 0, + Accurate = 1, + Unsafe = 2, + Paranoid = 3, +}; + +enum class FullscreenMode : u32 { + Borderless = 0, + Exclusive = 1, +}; + +enum class NvdecEmulation : u32 { + Off = 0, + CPU = 1, + GPU = 2, +}; + +enum class ResolutionSetup : u32 { + Res1_2X = 0, + Res3_4X = 1, + Res1X = 2, + Res3_2X = 3, + Res2X = 4, + Res3X = 5, + Res4X = 6, + Res5X = 7, + Res6X = 8, + Res7X = 9, + Res8X = 10, +}; + +enum class ScalingFilter : u32 { + NearestNeighbor = 0, + Bilinear = 1, + Bicubic = 2, + Gaussian = 3, + ScaleForce = 4, + Fsr = 5, + LastFilter = Fsr, +}; + +enum class AntiAliasing : u32 { + None = 0, + Fxaa = 1, + Smaa = 2, + LastAA = Smaa, +}; + +enum class AspectRatio : u32 { + R16_9, + R4_3, + R21_9, + R16_10, + Stretch, +}; + +static std::map> translations = { + {typeid(AudioEngine), + { + {"auto", static_cast(AudioEngine::Auto)}, + {"cubeb", static_cast(AudioEngine::Cubeb)}, + {"sdl2", static_cast(AudioEngine::Sdl2)}, + {"null", static_cast(AudioEngine::Null)}, + }}}; + +static std::string empty_string{}; + +template +const std::string& TranslateEnum(Type id) { + auto& group = translations.at(typeid(Type)); + for (auto& [name, value] : group) { + if (static_cast(value) == id) { + return name; + } + } + return empty_string; +} + +template +static Type ToEnum(const std::string& text) { + return static_cast(translations.at(typeid(Type)).at(text)); +} +} // namespace Settings -- cgit v1.2.3 From 432f68ad29df7a368ba375d75d667c954e9c80b9 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 17:54:22 -0400 Subject: configure_audio: Implement ui generation Needs a considerable amount of management specific to some of the comoboboxes due to the audio engine configuration. general: Partial audio config implmentation configure_audio: Implement ui generation Needs a considerable amount of management specific to some of the comoboboxes due to the audio engine configuration. general: Partial audio config implmentation settings: Make audio settings as enums --- src/common/settings.cpp | 2 +- src/common/settings.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index c8651925e..8bfda5667 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -90,7 +90,7 @@ void LogSettings() { log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue()); log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); - log_setting("Audio_OutputEngine", values.sink_id.GetValue()); + log_setting("Audio_OutputEngine", Settings::TranslateEnum(values.sink_id.GetValue())); log_setting("Audio_OutputDevice", values.audio_output_device_id.GetValue()); log_setting("Audio_InputDevice", values.audio_input_device_id.GetValue()); log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue()); diff --git a/src/common/settings.h b/src/common/settings.h index 0ac5078c6..d4b41a162 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -244,6 +244,8 @@ protected: return value_.has_value() ? std::to_string(*value_) : "none"; } else if constexpr (std::is_same()) { return value_ ? "true" : "false"; + } else if (std::is_same()) { + return TranslateEnum(value_); } else { return std::to_string(static_cast(value_)); } @@ -309,6 +311,8 @@ public: this->SetValue(static_cast(std::stoul(input))); } else if constexpr (std::is_same()) { this->SetValue(input == "true"); + } else if constexpr (std::is_same()) { + this->SetValue(ToEnum(input)); } else { this->SetValue(static_cast(std::stoll(input))); } @@ -542,7 +546,7 @@ struct Values { Linkage linkage{}; // Audio - Setting sink_id{linkage, "auto", "output_engine", Category::Audio}; + Setting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio}; Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; @@ -731,8 +735,9 @@ struct Values { SwitchableSetting time_zone_index{linkage, TimeZone::Auto, TimeZone::Auto, TimeZone::Zulu, "time_zone_index", Category::System}; - SwitchableSetting sound_index{ - linkage, 1, 0, 2, "sound_index", Category::SystemAudio}; + SwitchableSetting sound_index{linkage, AudioMode::Stereo, + AudioMode::Mono, AudioMode::Surround, + "sound_index", Category::SystemAudio}; SwitchableSetting use_docked_mode{linkage, true, "use_docked_mode", Category::System}; -- cgit v1.2.3 From 3281ea935ff66cef6fbfa1b83564fb4ac96918cc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 16:30:39 -0700 Subject: settings: Make volume runtime-configurable --- src/common/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index d4b41a162..a9ce113ef 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -550,7 +550,7 @@ struct Values { Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; - SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio}; + SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio, true, true}; Setting dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio, false}; -- cgit v1.2.3 From d146dd9d123a999e40307a93403239b81b04bffc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:52:23 -0400 Subject: settings,general: Rename non-confirming enums --- src/common/settings.cpp | 6 +++--- src/common/settings.h | 40 ++++++++++++++++++++++++---------------- src/common/settings_enums.h | 37 ++++++++++++++++++------------------- 3 files changed, 45 insertions(+), 38 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 8bfda5667..0a8729b5a 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -122,12 +122,12 @@ void SetConfiguringGlobal(bool is_global) { } bool IsGPULevelExtreme() { - return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme; + return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme; } bool IsGPULevelHigh() { - return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme || - values.gpu_accuracy.GetValue() == GPUAccuracy::High; + return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme || + values.gpu_accuracy.GetValue() == GpuAccuracy::High; } bool IsFastmemEnabled() { diff --git a/src/common/settings.h b/src/common/settings.h index a9ce113ef..141408d3e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -91,6 +91,7 @@ public: return {}; } virtual void LoadString(const std::string& load) = 0; + virtual std::string Canonicalize() const = 0; virtual const std::string& GetLabel() const = 0; virtual std::string DefaultToString() const = 0; virtual bool Save() const = 0; @@ -102,7 +103,7 @@ public: virtual std::string MinVal() const = 0; virtual std::string MaxVal() const = 0; virtual bool UsingGlobal() const { - return false; + return true; } }; @@ -245,7 +246,7 @@ protected: } else if constexpr (std::is_same()) { return value_ ? "true" : "false"; } else if (std::is_same()) { - return TranslateEnum(value_); + return CanonicalizeEnum(value_); } else { return std::to_string(static_cast(value_)); } @@ -321,6 +322,13 @@ public: } } + [[nodiscard]] std::string constexpr Canonicalize() const override { + if constexpr (std::is_enum::value) { + return CanonicalizeEnum(this->GetValue()); + } + return ToString(this->GetValue()); + } + /** * Returns the save preference of the setting i.e. when saving or reading the setting from a * frontend, whether this setting should be skipped. @@ -560,8 +568,8 @@ struct Values { linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; // Cpu - SwitchableSetting cpu_accuracy{linkage, CPUAccuracy::Auto, - CPUAccuracy::Auto, CPUAccuracy::Paranoid, + SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, + CpuAccuracy::Auto, CpuAccuracy::Paranoid, "cpu_accuracy", Category::Cpu}; // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 Setting cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu}; @@ -657,28 +665,28 @@ struct Values { linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; - SwitchableSetting gpu_accuracy{linkage, - GPUAccuracy::High, - GPUAccuracy::Normal, - GPUAccuracy::Extreme, + SwitchableSetting gpu_accuracy{linkage, + GpuAccuracy::High, + GpuAccuracy::Normal, + GpuAccuracy::Extreme, "gpu_accuracy", Category::RendererAdvanced, true, true}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; - SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::GPU, + SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, "nvdec_emulation", Category::Renderer}; SwitchableSetting accelerate_astc{linkage, - AstcDecodeMode::CPU, - AstcDecodeMode::CPU, - AstcDecodeMode::CPUAsynchronous, + AstcDecodeMode::Cpu, + AstcDecodeMode::Cpu, + AstcDecodeMode::CpuAsynchronous, "accelerate_astc", Category::Renderer}; Setting vsync_mode{linkage, - VSyncMode::FIFO, + VSyncMode::Fifo, VSyncMode::Immediate, - VSyncMode::FIFORelaxed, + VSyncMode::FifoRelaxed, "use_vsync", Category::Renderer, true, @@ -686,7 +694,7 @@ struct Values { SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", Category::RendererAdvanced}; SwitchableSetting shader_backend{ - linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, + linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; @@ -730,7 +738,7 @@ struct Values { Language::PortugueseBrazilian, "language_index", Category::System}; - SwitchableSetting region_index{linkage, Region::USA, Region::Japan, + SwitchableSetting region_index{linkage, Region::Usa, Region::Japan, Region::Taiwan, "region_index", Category::System}; SwitchableSetting time_zone_index{linkage, TimeZone::Auto, TimeZone::Auto, TimeZone::Zulu, diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f48fb7bd4..6cd2ac28b 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -47,7 +47,7 @@ enum class Language : u32 { enum class Region : u32 { Japan, - USA, + Usa, Europe, Australia, China, @@ -114,9 +114,9 @@ enum class AnisotropyMode : u32 { }; enum class AstcDecodeMode : u32 { - CPU = 0, - GPU = 1, - CPUAsynchronous = 2, + Cpu = 0, + Gpu = 1, + CpuAsynchronous = 2, }; enum class AstcRecompression : u32 { @@ -128,8 +128,8 @@ enum class AstcRecompression : u32 { enum class VSyncMode : u32 { Immediate = 0, Mailbox = 1, - FIFO = 2, - FIFORelaxed = 3, + Fifo = 2, + FifoRelaxed = 3, }; enum class RendererBackend : u32 { @@ -139,19 +139,18 @@ enum class RendererBackend : u32 { }; enum class ShaderBackend : u32 { - GLSL = 0, - GLASM = 1, - SPIRV = 2, + Glsl = 0, + Glasm = 1, + SpirV = 2, }; -enum class GPUAccuracy : u32 { +enum class GpuAccuracy : u32 { Normal = 0, High = 1, Extreme = 2, - MaxEnum = 3, }; -enum class CPUAccuracy : u32 { +enum class CpuAccuracy : u32 { Auto = 0, Accurate = 1, Unsafe = 2, @@ -165,8 +164,8 @@ enum class FullscreenMode : u32 { enum class NvdecEmulation : u32 { Off = 0, - CPU = 1, - GPU = 2, + Cpu = 1, + Gpu = 2, }; enum class ResolutionSetup : u32 { @@ -220,18 +219,18 @@ static std::map> translations = { static std::string empty_string{}; template -const std::string& TranslateEnum(Type id) { - auto& group = translations.at(typeid(Type)); +const std::string& CanonicalizeEnum(Type id) { + auto& group = canonicalizations.at(typeid(Type)); for (auto& [name, value] : group) { if (static_cast(value) == id) { return name; } } - return empty_string; + return invalid_string; } template -static Type ToEnum(const std::string& text) { - return static_cast(translations.at(typeid(Type)).at(text)); +static Type ToEnum(const std::string& canonicalization) { + return static_cast(canonicalizations.at(typeid(Type)).at(canonicalization)); } } // namespace Settings -- cgit v1.2.3 From 8c17a945f71b8532b0a4c3903b00a09d99ff0d6c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:53:05 -0400 Subject: settings_enums: Cannonicalize settings names Gives every option of the enums a string literal via a macro. --- src/common/settings_enums.h | 165 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 6cd2ac28b..d820bc48e 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -207,16 +207,177 @@ enum class AspectRatio : u32 { Stretch, }; -static std::map> translations = { +#define X(ENUM, NAME) \ + { (#NAME), static_cast(ENUM::NAME) } + +static std::map> canonicalizations = { {typeid(AudioEngine), { {"auto", static_cast(AudioEngine::Auto)}, {"cubeb", static_cast(AudioEngine::Cubeb)}, {"sdl2", static_cast(AudioEngine::Sdl2)}, {"null", static_cast(AudioEngine::Null)}, + }}, + {typeid(AudioMode), + { + X(AudioMode, Mono), + X(AudioMode, Stereo), + X(AudioMode, Surround), + }}, + {typeid(Language), + { + X(Language, Japanese), + X(Language, EnglishAmerican), + X(Language, French), + X(Language, German), + X(Language, Italian), + X(Language, Spanish), + X(Language, Chinese), + X(Language, Korean), + X(Language, Dutch), + X(Language, Portuguese), + X(Language, Russian), + X(Language, Taiwanese), + X(Language, EnglishBritish), + X(Language, FrenchCanadian), + X(Language, SpanishLatin), + X(Language, ChineseSimplified), + X(Language, ChineseTraditional), + X(Language, PortugueseBrazilian), + }}, + {typeid(Region), + { + X(Region, Japan), + X(Region, Usa), + X(Region, Europe), + X(Region, Australia), + X(Region, China), + X(Region, Korea), + X(Region, Taiwan), + }}, + {typeid(TimeZone), + { + X(TimeZone, Auto), X(TimeZone, Default), X(TimeZone, CET), + X(TimeZone, CST6CDT), X(TimeZone, Cuba), X(TimeZone, EET), + X(TimeZone, Egypt), X(TimeZone, Eire), X(TimeZone, EST5EDT), + X(TimeZone, GB), X(TimeZone, GBEire), X(TimeZone, GMT), + X(TimeZone, GMTPlusZero), X(TimeZone, GMTMinusZero), X(TimeZone, GMTZero), + X(TimeZone, Greenwich), X(TimeZone, Hongkong), X(TimeZone, HST), + X(TimeZone, Iceland), X(TimeZone, Iran), X(TimeZone, Israel), + X(TimeZone, Jamaica), X(TimeZone, Japan), X(TimeZone, Kwajalein), + X(TimeZone, Libya), X(TimeZone, MET), X(TimeZone, MST), + X(TimeZone, MST7MDT), X(TimeZone, Navajo), X(TimeZone, NZ), + X(TimeZone, NZCHAT), X(TimeZone, Poland), X(TimeZone, Portugal), + X(TimeZone, PRC), X(TimeZone, ROC), X(TimeZone, ROK), + X(TimeZone, Singapore), X(TimeZone, Turkey), X(TimeZone, UCT), + X(TimeZone, Universal), X(TimeZone, UTC), X(TimeZone, W_SU), + X(TimeZone, WET), X(TimeZone, Zulu), + }}, + {typeid(AnisotropyMode), + { + X(AnisotropyMode, Automatic), + X(AnisotropyMode, Default), + X(AnisotropyMode, X2), + X(AnisotropyMode, X4), + X(AnisotropyMode, X8), + X(AnisotropyMode, X16), + }}, + {typeid(AstcDecodeMode), + { + X(AstcDecodeMode, Cpu), + X(AstcDecodeMode, Gpu), + X(AstcDecodeMode, CpuAsynchronous), + }}, + {typeid(AstcRecompression), + { + X(AstcRecompression, Uncompressed), + X(AstcRecompression, Bc1), + X(AstcRecompression, Bc3), + }}, + {typeid(VSyncMode), + { + X(VSyncMode, Immediate), + X(VSyncMode, Mailbox), + X(VSyncMode, Fifo), + X(VSyncMode, FifoRelaxed), + }}, + {typeid(RendererBackend), + { + X(RendererBackend, OpenGL), + X(RendererBackend, Vulkan), + X(RendererBackend, Null), + }}, + {typeid(ShaderBackend), + { + X(ShaderBackend, Glsl), + X(ShaderBackend, Glasm), + X(ShaderBackend, SpirV), + }}, + {typeid(GpuAccuracy), + { + X(GpuAccuracy, Normal), + X(GpuAccuracy, High), + X(GpuAccuracy, Extreme), + }}, + {typeid(CpuAccuracy), + { + X(CpuAccuracy, Auto), + X(CpuAccuracy, Accurate), + X(CpuAccuracy, Unsafe), + X(CpuAccuracy, Paranoid), + }}, + {typeid(FullscreenMode), + { + X(FullscreenMode, Borderless), + X(FullscreenMode, Exclusive), + }}, + {typeid(NvdecEmulation), + { + X(NvdecEmulation, Off), + X(NvdecEmulation, Cpu), + X(NvdecEmulation, Gpu), + }}, + {typeid(ResolutionSetup), + { + X(ResolutionSetup, Res1_2X), + X(ResolutionSetup, Res3_4X), + X(ResolutionSetup, Res1X), + X(ResolutionSetup, Res3_2X), + X(ResolutionSetup, Res2X), + X(ResolutionSetup, Res3X), + X(ResolutionSetup, Res4X), + X(ResolutionSetup, Res5X), + X(ResolutionSetup, Res6X), + X(ResolutionSetup, Res7X), + X(ResolutionSetup, Res8X), + }}, + {typeid(ScalingFilter), + { + X(ScalingFilter, NearestNeighbor), + X(ScalingFilter, Bilinear), + X(ScalingFilter, Bicubic), + X(ScalingFilter, Gaussian), + X(ScalingFilter, ScaleForce), + X(ScalingFilter, Fsr), + }}, + {typeid(AntiAliasing), + { + X(AntiAliasing, None), + X(AntiAliasing, Fxaa), + X(AntiAliasing, Smaa), + }}, + {typeid(AspectRatio), + { + X(AspectRatio, R16_9), + X(AspectRatio, R4_3), + X(AspectRatio, R21_9), + X(AspectRatio, R16_10), + X(AspectRatio, Stretch), }}}; -static std::string empty_string{}; +#undef X + +static std::string invalid_string{"(invalid setting)"}; template const std::string& CanonicalizeEnum(Type id) { -- cgit v1.2.3 From 78b270937367b813ef27a019e1a7a3728e3f9d55 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:53:57 -0400 Subject: settings: Report all contained settings values Also adds a couple characters that denotes the state of the setting. M for modified, or not default. C for custom, in context of per-game settings. --- src/common/settings.cpp | 64 +++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 45 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 0a8729b5a..84e90f893 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -61,56 +61,30 @@ void LogSettings() { }; LOG_INFO(Config, "yuzu Configuration:"); - log_setting("Controls_UseDockedMode", values.use_docked_mode.GetValue()); - log_setting("System_RngSeedEnabled", values.rng_seed_enabled.GetValue()); - log_setting("System_RngSeed", values.rng_seed.GetValue()); - log_setting("System_DeviceName", values.device_name.GetValue()); - log_setting("System_CurrentUser", values.current_user.GetValue()); - log_setting("System_LanguageIndex", values.language_index.GetValue()); - log_setting("System_RegionIndex", values.region_index.GetValue()); - log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); - log_setting("System_UnsafeMemoryLayout", values.use_unsafe_extended_memory_layout.GetValue()); - log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); - log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); - log_setting("Renderer_UseResolutionScaling", values.resolution_setup.GetValue()); - log_setting("Renderer_ScalingFilter", values.scaling_filter.GetValue()); - log_setting("Renderer_FSRSlider", values.fsr_sharpening_slider.GetValue()); - log_setting("Renderer_AntiAliasing", values.anti_aliasing.GetValue()); - log_setting("Renderer_UseSpeedLimit", values.use_speed_limit.GetValue()); - log_setting("Renderer_SpeedLimit", values.speed_limit.GetValue()); - log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); - log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue()); - log_setting("Renderer_UseAsynchronousGpuEmulation", - values.use_asynchronous_gpu_emulation.GetValue()); - log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue()); - log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue()); - log_setting("Renderer_AstcRecompression", values.astc_recompression.GetValue()); - log_setting("Renderer_UseVsync", values.vsync_mode.GetValue()); - log_setting("Renderer_UseReactiveFlushing", values.use_reactive_flushing.GetValue()); - log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue()); - log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); - log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); - log_setting("Audio_OutputEngine", Settings::TranslateEnum(values.sink_id.GetValue())); - log_setting("Audio_OutputDevice", values.audio_output_device_id.GetValue()); - log_setting("Audio_InputDevice", values.audio_input_device_id.GetValue()); - log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue()); + for (auto& [category, settings] : values.linkage.by_category) { + settings.sort([](const BasicSetting* a, const BasicSetting* b) { + return a->GetLabel() < b->GetLabel(); + }); + + for (const auto& setting : settings) { + if (setting->Id() == values.yuzu_token.Id()) { + // Hide the token secret, which could be used to share patreon builds + continue; + } + + std::string name = fmt::format( + "{:c}{:c} {}.{}", setting->ToString() == setting->DefaultToString() ? '-' : 'M', + setting->UsingGlobal() ? '-' : 'C', TranslateCategory(category), + setting->GetLabel()); + + log_setting(name, setting->Canonicalize()); + } + } log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir)); log_path("DataStorage_ConfigDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir)); log_path("DataStorage_LoadDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir)); log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir)); log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir)); - log_setting("Debugging_ProgramArgs", values.program_args.GetValue()); - log_setting("Debugging_GDBStub", values.use_gdbstub.GetValue()); - log_setting("Input_EnableMotion", values.motion_enabled.GetValue()); - log_setting("Input_EnableVibration", values.vibration_enabled.GetValue()); - log_setting("Input_EnableTouch", values.touchscreen.enabled); - log_setting("Input_EnableMouse", values.mouse_enabled.GetValue()); - log_setting("Input_EnableKeyboard", values.keyboard_enabled.GetValue()); - log_setting("Input_EnableRingController", values.enable_ring_controller.GetValue()); - log_setting("Input_EnableIrSensor", values.enable_ir_sensor.GetValue()); - log_setting("Input_EnableCustomJoycon", values.enable_joycon_driver.GetValue()); - log_setting("Input_EnableCustomProController", values.enable_procon_driver.GetValue()); - log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue()); } bool IsConfiguringGlobal() { -- cgit v1.2.3 From 163f229d2641426a163356c877ecd5b8b7555558 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 17:24:29 -0400 Subject: settings: Reorder Groups graphics audio and system settings together in a way that reflects the frontend. This also just conceptually groups them more nicely than they were. --- src/common/settings.h | 153 +++++++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 75 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 141408d3e..f6e977e96 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -557,8 +557,11 @@ struct Values { Setting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio}; Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; - Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; + SwitchableSetting sound_index{linkage, AudioMode::Stereo, + AudioMode::Mono, AudioMode::Surround, + "sound_index", Category::SystemAudio}; SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio, true, true}; + Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; Setting dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio, false}; @@ -612,28 +615,35 @@ struct Values { SwitchableSetting renderer_backend{ linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend", Category::Renderer}; - SwitchableSetting async_presentation{linkage, false, "async_presentation", - Category::RendererAdvanced}; - SwitchableSetting renderer_force_max_clock{linkage, false, "force_max_clock", - Category::RendererAdvanced}; - Setting renderer_debug{linkage, false, "debug", Category::RendererDebug}; - Setting renderer_shader_feedback{linkage, false, "shader_feedback", - Category::RendererDebug}; - Setting enable_nsight_aftermath{linkage, false, "nsight_aftermath", - Category::RendererDebug}; - Setting disable_shader_loop_safety_checks{ - linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; + SwitchableSetting shader_backend{ + linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, + "shader_backend", Category::Renderer}; SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer}; - ResolutionScalingInfo resolution_info{}; - SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, - "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{ - linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; - SwitchableSetting fsr_sharpening_slider{ - linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; - SwitchableSetting anti_aliasing{ - linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; + SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", + Category::Renderer}; + SwitchableSetting use_asynchronous_gpu_emulation{ + linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; + SwitchableSetting use_speed_limit{ + linkage, true, "use_speed_limit", Category::Renderer, false, true}; + SwitchableSetting speed_limit{ + linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; + SwitchableSetting accelerate_astc{linkage, + AstcDecodeMode::Cpu, + AstcDecodeMode::Cpu, + AstcDecodeMode::CpuAsynchronous, + "accelerate_astc", + Category::Renderer}; + Setting vsync_mode{linkage, + VSyncMode::Fifo, + VSyncMode::Immediate, + VSyncMode::FifoRelaxed, + "use_vsync", + Category::Renderer, + true, + true}; + SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, + "nvdec_emulation", Category::Renderer}; // *nix platforms may have issues with the borderless windowed fullscreen mode. // Default to exclusive fullscreen on these platforms for now. SwitchableSetting fullscreen_mode{linkage, @@ -656,15 +666,21 @@ struct Values { Category::Renderer, true, true}; - SwitchableSetting max_anisotropy{ - linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, - "max_anisotropy", Category::RendererAdvanced}; - SwitchableSetting use_speed_limit{ - linkage, true, "use_speed_limit", Category::Renderer, false, true}; - SwitchableSetting speed_limit{ - linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; - SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", - Category::Renderer}; + + ResolutionScalingInfo resolution_info{}; + SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, + "resolution_setup", Category::Renderer}; + SwitchableSetting scaling_filter{ + linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; + SwitchableSetting anti_aliasing{ + linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; + SwitchableSetting fsr_sharpening_slider{ + linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; + + SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer, true, true}; + SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer, true, true}; + SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; + SwitchableSetting gpu_accuracy{linkage, GpuAccuracy::High, GpuAccuracy::Normal, @@ -673,29 +689,21 @@ struct Values { Category::RendererAdvanced, true, true}; - SwitchableSetting use_asynchronous_gpu_emulation{ - linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; - SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, - "nvdec_emulation", Category::Renderer}; - SwitchableSetting accelerate_astc{linkage, - AstcDecodeMode::Cpu, - AstcDecodeMode::Cpu, - AstcDecodeMode::CpuAsynchronous, - "accelerate_astc", - Category::Renderer}; - Setting vsync_mode{linkage, - VSyncMode::Fifo, - VSyncMode::Immediate, - VSyncMode::FifoRelaxed, - "use_vsync", - Category::Renderer, - true, - true}; + SwitchableSetting max_anisotropy{ + linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, + "max_anisotropy", Category::RendererAdvanced}; + SwitchableSetting astc_recompression{linkage, + AstcRecompression::Uncompressed, + AstcRecompression::Uncompressed, + AstcRecompression::Bc3, + "astc_recompression", + Category::RendererAdvanced}; + SwitchableSetting async_presentation{linkage, false, "async_presentation", + Category::RendererAdvanced}; + SwitchableSetting renderer_force_max_clock{linkage, false, "force_max_clock", + Category::RendererAdvanced}; SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", Category::RendererAdvanced}; - SwitchableSetting shader_backend{ - linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, - "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; SwitchableSetting use_fast_gpu_time{ @@ -704,34 +712,20 @@ struct Values { linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::RendererAdvanced}; - SwitchableSetting astc_recompression{linkage, - AstcRecompression::Uncompressed, - AstcRecompression::Uncompressed, - AstcRecompression::Bc3, - "astc_recompression", - Category::RendererAdvanced}; SwitchableSetting use_video_framerate{linkage, false, "use_video_framerate", Category::RendererAdvanced}; SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", Category::RendererAdvanced}; - SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer, true, true}; - SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer, true, true}; - SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; + Setting renderer_debug{linkage, false, "debug", Category::RendererDebug}; + Setting renderer_shader_feedback{linkage, false, "shader_feedback", + Category::RendererDebug}; + Setting enable_nsight_aftermath{linkage, false, "nsight_aftermath", + Category::RendererDebug}; + Setting disable_shader_loop_safety_checks{ + linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; // System - SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", - Category::System, true, true}; - SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, true, true}; - Setting device_name{linkage, "Yuzu", "device_name", Category::System, true, true}; - // Measured in seconds since epoch - SwitchableSetting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", - Category::System, true, true}; - SwitchableSetting custom_rtc{linkage, 0, "custom_rtc", Category::System, true, true}; - // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` - s64 custom_rtc_differential; - - Setting current_user{linkage, 0, "current_user", Category::System}; SwitchableSetting language_index{linkage, Language::EnglishAmerican, Language::Japanese, @@ -743,9 +737,18 @@ struct Values { SwitchableSetting time_zone_index{linkage, TimeZone::Auto, TimeZone::Auto, TimeZone::Zulu, "time_zone_index", Category::System}; - SwitchableSetting sound_index{linkage, AudioMode::Stereo, - AudioMode::Mono, AudioMode::Surround, - "sound_index", Category::SystemAudio}; + // Measured in seconds since epoch + SwitchableSetting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", + Category::System, true, true}; + SwitchableSetting custom_rtc{linkage, 0, "custom_rtc", Category::System, true, true}; + // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` + s64 custom_rtc_differential; + SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", + Category::System, true, true}; + SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, true, true}; + Setting device_name{linkage, "Yuzu", "device_name", Category::System, true, true}; + + Setting current_user{linkage, 0, "current_user", Category::System}; SwitchableSetting use_docked_mode{linkage, true, "use_docked_mode", Category::System}; -- cgit v1.2.3 From b86171d2b58e3f37e27d6d362548be5560c44764 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 19:40:04 -0400 Subject: settings: yuzu is not capitalized why is it capitalized stop no bad --- src/common/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index f6e977e96..384a8ecb6 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -746,7 +746,7 @@ struct Values { SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System, true, true}; SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, true, true}; - Setting device_name{linkage, "Yuzu", "device_name", Category::System, true, true}; + Setting device_name{linkage, "yuzu", "device_name", Category::System, true, true}; Setting current_user{linkage, 0, "current_user", Category::System}; -- cgit v1.2.3 From 2fba913d0bc022085a0de8848ced02f38e48cd54 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:35:45 -0400 Subject: settings_enums: Add const type where needed --- src/common/settings_enums.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index d820bc48e..2710f136d 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -210,7 +210,7 @@ enum class AspectRatio : u32 { #define X(ENUM, NAME) \ { (#NAME), static_cast(ENUM::NAME) } -static std::map> canonicalizations = { +static const std::map> canonicalizations = { {typeid(AudioEngine), { {"auto", static_cast(AudioEngine::Auto)}, @@ -377,7 +377,7 @@ static std::map> canonicalizations = #undef X -static std::string invalid_string{"(invalid setting)"}; +static const std::string invalid_string{"(invalid setting)"}; template const std::string& CanonicalizeEnum(Type id) { -- cgit v1.2.3 From 0193add060ecc591ca27d029916823911df5d503 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:44:03 -0400 Subject: general: Add typeinfo where needed Using typeid without including typeinfo first produces an ill-formed program. --- src/common/settings.h | 1 + src/common/settings_enums.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 384a8ecb6..29dad27fc 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 2710f136d..f3d76b927 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "common/common_types.h" namespace Settings { -- cgit v1.2.3 From 02265f19d996f7266da7c4cba5c9d93ab3727f9f Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:39:47 -0400 Subject: settings: Remove redundant false literals --- src/common/settings.h | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 29dad27fc..ec0686120 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -625,8 +625,8 @@ struct Values { Category::Renderer}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; - SwitchableSetting use_speed_limit{ - linkage, true, "use_speed_limit", Category::Renderer, false, true}; + SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", Category::Renderer, + false, true}; SwitchableSetting speed_limit{ linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; SwitchableSetting accelerate_astc{linkage, @@ -671,9 +671,9 @@ struct Values { ResolutionScalingInfo resolution_info{}; SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{ + SwitchableSetting scaling_filter{ linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; - SwitchableSetting anti_aliasing{ + SwitchableSetting anti_aliasing{ linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; SwitchableSetting fsr_sharpening_slider{ linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; @@ -707,9 +707,9 @@ struct Values { Category::RendererAdvanced}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; - SwitchableSetting use_fast_gpu_time{ + SwitchableSetting use_fast_gpu_time{ linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, true, true}; - SwitchableSetting use_vulkan_driver_pipeline_cache{ + SwitchableSetting use_vulkan_driver_pipeline_cache{ linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::RendererAdvanced}; @@ -756,12 +756,12 @@ struct Values { // Controls InputSetting> players; - Setting enable_raw_input{linkage, false, "enable_raw_input", Category::Controls, + Setting enable_raw_input{linkage, false, "enable_raw_input", Category::Controls, // Only read/write enable_raw_input on Windows platforms #ifdef _WIN32 - true + true #else - false + false #endif }; Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; @@ -783,7 +783,7 @@ struct Values { Setting tas_enable{linkage, false, "tas_enable", Category::Controls}; Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; - Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls, false}; + Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls, false}; Setting mouse_panning_sensitivity{ linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; @@ -839,22 +839,19 @@ struct Values { Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; - Setting dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics, - false}; - Setting dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics, - false}; + Setting dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics, false}; + Setting dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics, false}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; - Setting reporting_services{linkage, false, "reporting_services", - Category::Debugging, false}; + Setting reporting_services{linkage, false, "reporting_services", Category::Debugging, + false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::DebuggingGraphics}; - Setting extended_logging{linkage, false, "extended_logging", Category::Debugging, - false}; + Setting extended_logging{linkage, false, "extended_logging", Category::Debugging, false}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; - Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false}; + Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false}; Setting enable_all_controllers{linkage, false, "enable_all_controllers", Category::Debugging}; Setting create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging}; -- cgit v1.2.3 From 04d4b6ab802a1238eaca6c0a16d1a739503b81d9 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:40:39 -0400 Subject: (ui,)settings: Use explicit instantiation Reduces compile times a tad on clang. --- src/common/CMakeLists.txt | 2 + src/common/settings.cpp | 52 +++++ src/common/settings.h | 513 ++++-------------------------------------- src/common/settings_common.h | 78 +++++++ src/common/settings_setting.h | 413 ++++++++++++++++++++++++++++++++++ 5 files changed, 587 insertions(+), 471 deletions(-) create mode 100644 src/common/settings_common.h create mode 100644 src/common/settings_setting.h (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 5902dd617..3c8368bb2 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -110,9 +110,11 @@ add_library(common STATIC scratch_buffer.h settings.cpp settings.h + settings_common.h settings_enums.h settings_input.cpp settings_input.h + settings_setting.h socket_types.h spin_lock.cpp spin_lock.h diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 84e90f893..10cdea844 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -7,10 +7,17 @@ #include #include #endif +#include +#include +#include +#include #include #include +#include +#include #include "common/assert.h" +#include "common/fs/fs_util.h" #include "common/fs/path_util.h" #include "common/logging/log.h" #include "common/settings.h" @@ -18,6 +25,43 @@ namespace Settings { +#define SETTING(TYPE, RANGED) template class Setting +#define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting + +SETTING(AudioEngine, false); +SETTING(bool, false); +SETTING(int, false); +SETTING(std::string, false); +SETTING(u16, false); +SWITCHABLE(AnisotropyMode, true); +SWITCHABLE(AntiAliasing, false); +SWITCHABLE(AspectRatio, true); +SWITCHABLE(AstcDecodeMode, true); +SWITCHABLE(AstcRecompression, true); +SWITCHABLE(AudioMode, true); +SWITCHABLE(CpuAccuracy, true); +SWITCHABLE(FullscreenMode, true); +SWITCHABLE(GpuAccuracy, true); +SWITCHABLE(Language, true); +SWITCHABLE(NvdecEmulation, false); +SWITCHABLE(Region, true); +SWITCHABLE(RendererBackend, true); +SWITCHABLE(ScalingFilter, false); +SWITCHABLE(ShaderBackend, true); +SWITCHABLE(TimeZone, true); +SETTING(VSyncMode, true); +SWITCHABLE(bool, false); +SWITCHABLE(int, false); +SWITCHABLE(int, true); +SWITCHABLE(s64, false); +SWITCHABLE(u16, true); +SWITCHABLE(u32, false); +SWITCHABLE(u8, false); +SWITCHABLE(u8, true); + +#undef SETTING +#undef SWITCHABLE + Values values; static bool configuring_global = true; @@ -238,6 +282,14 @@ void UpdateRescalingInfo() { info.active = info.up_scale != 1 || info.down_shift != 0; } +std::string BasicSetting::ToStringGlobal() const { + return {}; +} + +bool BasicSetting::UsingGlobal() const { + return true; +} + void RestoreGlobalState(bool is_powered_on) { // If a game is running, DO NOT restore the global settings state if (is_powered_on) { diff --git a/src/common/settings.h b/src/common/settings.h index ec0686120..e03233eaf 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -5,54 +5,21 @@ #include #include -#include -#include #include -#include +#include #include #include -#include -#include #include #include #include "common/common_types.h" +#include "common/settings_common.h" #include "common/settings_enums.h" #include "common/settings_input.h" +#include "common/settings_setting.h" namespace Settings { -enum class Category : u32 { - Audio, - Core, - Cpu, - CpuDebug, - CpuUnsafe, - Renderer, - RendererAdvanced, - RendererDebug, - System, - SystemAudio, - DataStorage, - Debugging, - DebuggingGraphics, - Miscellaneous, - Network, - WebService, - AddOns, - Controls, - Ui, - UiGeneral, - UiLayout, - UiGameList, - Screenshots, - Shortcuts, - Multiplayer, - Services, - Paths, - MaxEnum, -}; - const char* TranslateCategory(Settings::Category category); struct ResolutionScalingInfo { @@ -78,441 +45,45 @@ struct ResolutionScalingInfo { } }; -class BasicSetting { -protected: - explicit BasicSetting() = default; - -public: - virtual ~BasicSetting() = default; - - virtual Category Category() const = 0; - virtual constexpr bool Switchable() const = 0; - virtual std::string ToString() const = 0; - virtual std::string ToStringGlobal() const { - return {}; - } - virtual void LoadString(const std::string& load) = 0; - virtual std::string Canonicalize() const = 0; - virtual const std::string& GetLabel() const = 0; - virtual std::string DefaultToString() const = 0; - virtual bool Save() const = 0; - virtual std::type_index TypeId() const = 0; - virtual constexpr bool IsEnum() const = 0; - virtual bool RuntimeModfiable() const = 0; - virtual void SetGlobal(bool global) {} - virtual constexpr u32 Id() const = 0; - virtual std::string MinVal() const = 0; - virtual std::string MaxVal() const = 0; - virtual bool UsingGlobal() const { - return true; - } -}; - -class Linkage { -public: - explicit Linkage(u32 initial_count = 0); - ~Linkage(); - std::map> by_category{}; - std::vector> restore_functions{}; - u32 count; -}; - -/** 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 be specified for sanitization. - */ -template -class Setting : public BasicSetting { -protected: - Setting() = default; - - /** - * Only sets the setting to the given initializer, leaving the other members to their default - * initializers. - * - * @param global_val Initial value of the setting - */ - explicit Setting(const Type& val) : value{val} {} - -public: - /** - * Sets a default value, label, and setting value. - * - * @param linkage Setting registry - * @param default_val Initial value of the setting, and default value of the setting - * @param name Label for the setting - * @param category_ Category of the setting AKA INI group - */ - explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) - requires(!ranged) - : value{default_val}, default_value{default_val}, label{name}, category{category_}, - id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} { - linkage.by_category[category].push_front(this); - linkage.count++; - } - virtual ~Setting() = default; - - /** - * Sets a default value, minimum value, maximum value, and label. - * - * @param linkage Setting registry - * @param default_val Initial value of the setting, and default value of the setting - * @param min_val Sets the minimum allowed value of the setting - * @param max_val Sets the maximum allowed value of the setting - * @param name Label for the setting - * @param category_ Category of the setting AKA INI group - */ - explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, enum Category category_, - bool save_ = true, bool runtime_modifiable_ = false) - requires(ranged) - : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, - label{name}, category{category_}, id{linkage.count}, save{save_}, - runtime_modifiable{runtime_modifiable_} { - linkage.by_category[category].push_front(this); - linkage.count++; - } - - /** - * Returns a reference to the setting's value. - * - * @returns A reference to the setting - */ - [[nodiscard]] virtual const Type& GetValue() const { - return value; - } - - /** - * Sets the setting to the given value. - * - * @param val The desired value - */ - virtual void SetValue(const Type& val) { - Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; - std::swap(value, temp); - } - - /** - * Returns the value that this setting was created with. - * - * @returns A reference to the default value - */ - [[nodiscard]] const Type& GetDefault() const { - return default_value; - } - - /** - * Returns the label this setting was created with. - * - * @returns A reference to the label - */ - [[nodiscard]] const std::string& GetLabel() const override { - return label; - } - - /** - * Returns the setting's category AKA INI group. - * - * @returns The setting's category - */ - [[nodiscard]] enum Category Category() const override { - return category; - } - - [[nodiscard]] bool RuntimeModfiable() const override { - return runtime_modifiable; - } - - [[nodiscard]] constexpr bool IsEnum() const override { - return std::is_enum::value; - } - - /** - * Returns whether the current setting is Switchable. - * - * @returns If the setting is a SwitchableSetting - */ - [[nodiscard]] virtual constexpr bool Switchable() const override { - return false; - } - -protected: - std::string ToString(const Type& value_) const { - if constexpr (std::is_same()) { - return value_; - } else if constexpr (std::is_same>()) { - return value_.has_value() ? std::to_string(*value_) : "none"; - } else if constexpr (std::is_same()) { - return value_ ? "true" : "false"; - } else if (std::is_same()) { - return CanonicalizeEnum(value_); - } else { - return std::to_string(static_cast(value_)); - } - } - -public: - /** - * Converts the value of the setting to a std::string. Respects the global state if the setting - * has one. - * - * @returns The current setting as a std::string - */ - std::string ToString() const override { - return ToString(this->GetValue()); - } - - /** - * Returns the default value of the setting as a std::string. - * - * @returns The default value as a string. - */ - std::string DefaultToString() const override { - return ToString(default_value); - } - - /** - * Assigns a value to the setting. - * - * @param val The desired setting value - * - * @returns A reference to the setting - */ - virtual const Type& operator=(const Type& val) { - Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; - std::swap(value, temp); - return value; - } - - /** - * Returns a reference to the setting. - * - * @returns A reference to the setting - */ - explicit virtual operator const Type&() const { - return value; - } - - /** - * Converts the given value to the Setting's type of value. Uses SetValue to enter the setting, - * thus respecting its constraints. - * - * @param input The desired value - */ - void LoadString(const std::string& input) override { - if (input.empty()) { - this->SetValue(this->GetDefault()); - return; - } - try { - if constexpr (std::is_same()) { - this->SetValue(input); - } else if constexpr (std::is_same>()) { - this->SetValue(static_cast(std::stoul(input))); - } else if constexpr (std::is_same()) { - this->SetValue(input == "true"); - } else if constexpr (std::is_same()) { - this->SetValue(ToEnum(input)); - } else { - this->SetValue(static_cast(std::stoll(input))); - } - } catch (std::invalid_argument) { - this->SetValue(this->GetDefault()); - } - } - - [[nodiscard]] std::string constexpr Canonicalize() const override { - if constexpr (std::is_enum::value) { - return CanonicalizeEnum(this->GetValue()); - } - return ToString(this->GetValue()); - } - - /** - * Returns the save preference of the setting i.e. when saving or reading the setting from a - * frontend, whether this setting should be skipped. - * - * @returns The save preference - */ - virtual bool Save() const override { - return save; - } - - /** - * Gives us another way to identify the setting without having to go through a string. - * - * @returns the type_index of the setting's type - */ - virtual std::type_index TypeId() const override { - return std::type_index(typeid(Type)); - } - - virtual constexpr u32 Id() const override { - return id; - } - - virtual std::string MinVal() const override { - return this->ToString(minimum); - } - virtual std::string MaxVal() const override { - return this->ToString(maximum); - } - -protected: - Type value{}; ///< The setting - const Type default_value{}; ///< The default value - const Type maximum{}; ///< Maximum allowed value of the setting - const Type minimum{}; ///< Minimum allowed value of the setting - const std::string label{}; ///< The setting's label - const enum Category category; ///< The setting's category AKA INI group - const u32 id; - bool save; - bool runtime_modifiable; -}; - -/** - * The SwitchableSetting class is a slightly more complex version of the Setting class. This adds a - * custom setting to switch to when a guest application specifically requires it. The effect is that - * other components of the emulator can access the setting's intended value without any need for the - * component to ask whether the custom or global setting is needed at the moment. - * - * By default, the global setting is used. - */ -template -class SwitchableSetting : virtual public Setting { -public: - /** - * Sets a default value, label, and setting value. - * - * @param linkage Setting registry - * @param default_val Initial value of the setting, and default value of the setting - * @param name Label for the setting - * @param category_ Category of the setting AKA INI group - */ - explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category, bool save = true, bool runtime_modifiable = false) - requires(!ranged) - : Setting{linkage, default_val, name, category, save, runtime_modifiable} { - linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); - } - virtual ~SwitchableSetting() = default; - - /** - * Sets a default value, minimum value, maximum value, and label. - * - * @param linkage Setting registry - * @param default_val Initial value of the setting, and default value of the setting - * @param min_val Sets the minimum allowed value of the setting - * @param max_val Sets the maximum allowed value of the setting - * @param name Label for the setting - * @param category_ Category of the setting AKA INI group - */ - explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, Category category, - bool save = true, bool runtime_modifiable = false) - requires(ranged) - : Setting{linkage, default_val, min_val, max_val, - name, category, save, runtime_modifiable} { - linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); - } - - /** - * Tells this setting to represent either the global or custom setting when other member - * functions are used. - * - * @param to_global Whether to use the global or custom setting. - */ - void SetGlobal(bool to_global) override { - use_global = to_global; - } - - /** - * Returns whether this setting is using the global setting or not. - * - * @returns The global state - */ - [[nodiscard]] bool UsingGlobal() const override { - return use_global; - } - - /** - * Returns either the global or custom setting depending on the values of this setting's global - * state or if the global value was specifically requested. - * - * @param need_global Request global value regardless of setting's state; defaults to false - * - * @returns The required value of the setting - */ - [[nodiscard]] virtual const Type& GetValue() const override { - if (use_global) { - return this->value; - } - return custom; - } - [[nodiscard]] virtual const Type& GetValue(bool need_global) const { - if (use_global || need_global) { - return this->value; - } - return custom; - } - - /** - * Sets the current setting value depending on the global state. - * - * @param val The new value - */ - void SetValue(const Type& val) override { - Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; - if (use_global) { - std::swap(this->value, temp); - } else { - std::swap(custom, temp); - } - } - - [[nodiscard]] virtual constexpr bool Switchable() const override { - return true; - } - - [[nodiscard]] virtual std::string ToStringGlobal() const override { - return this->ToString(this->value); - } - - /** - * Assigns the current setting value depending on the global state. - * - * @param val The new value - * - * @returns A reference to the current setting value - */ - const Type& operator=(const Type& val) override { - Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; - if (use_global) { - std::swap(this->value, temp); - return this->value; - } - std::swap(custom, temp); - return custom; - } - - /** - * Returns the current setting value depending on the global state. - * - * @returns A reference to the current setting value - */ - virtual explicit operator const Type&() const override { - if (use_global) { - return this->value; - } - return custom; - } - -protected: - bool use_global{true}; ///< The setting's global state - Type custom{}; ///< The custom value of the setting -}; +// Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work +#define SETTING(TYPE, RANGED) extern template class Setting +#define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting + +SETTING(AudioEngine, false); +SETTING(bool, false); +SETTING(int, false); +SETTING(s32, false); +SETTING(std::string, false); +SETTING(std::string, false); +SETTING(u16, false); +SWITCHABLE(AnisotropyMode, true); +SWITCHABLE(AntiAliasing, false); +SWITCHABLE(AspectRatio, true); +SWITCHABLE(AstcDecodeMode, true); +SWITCHABLE(AstcRecompression, true); +SWITCHABLE(AudioMode, true); +SWITCHABLE(CpuAccuracy, true); +SWITCHABLE(FullscreenMode, true); +SWITCHABLE(GpuAccuracy, true); +SWITCHABLE(Language, true); +SWITCHABLE(NvdecEmulation, false); +SWITCHABLE(Region, true); +SWITCHABLE(RendererBackend, true); +SWITCHABLE(ScalingFilter, false); +SWITCHABLE(ShaderBackend, true); +SWITCHABLE(TimeZone, true); +SETTING(VSyncMode, true); +SWITCHABLE(bool, false); +SWITCHABLE(int, false); +SWITCHABLE(int, true); +SWITCHABLE(s64, false); +SWITCHABLE(u16, true); +SWITCHABLE(u32, false); +SWITCHABLE(u8, false); +SWITCHABLE(u8, true); + +#undef SETTING +#undef SWITCHABLE /** * The InputSetting class allows for getting a reference to either the global or custom members. diff --git a/src/common/settings_common.h b/src/common/settings_common.h new file mode 100644 index 000000000..93fddeba6 --- /dev/null +++ b/src/common/settings_common.h @@ -0,0 +1,78 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "common/common_types.h" + +namespace Settings { + +enum class Category : u32 { + Audio, + Core, + Cpu, + CpuDebug, + CpuUnsafe, + Renderer, + RendererAdvanced, + RendererDebug, + System, + SystemAudio, + DataStorage, + Debugging, + DebuggingGraphics, + Miscellaneous, + Network, + WebService, + AddOns, + Controls, + Ui, + UiGeneral, + UiLayout, + UiGameList, + Screenshots, + Shortcuts, + Multiplayer, + Services, + Paths, + MaxEnum, +}; + +class BasicSetting { +protected: + explicit BasicSetting() = default; + +public: + virtual ~BasicSetting() = default; + + virtual Category Category() const = 0; + virtual constexpr bool Switchable() const = 0; + virtual std::string ToString() const = 0; + virtual std::string ToStringGlobal() const; + virtual void LoadString(const std::string& load) = 0; + virtual std::string Canonicalize() const = 0; + virtual const std::string& GetLabel() const = 0; + virtual std::string DefaultToString() const = 0; + virtual bool Save() const = 0; + virtual std::type_index TypeId() const = 0; + virtual constexpr bool IsEnum() const = 0; + virtual bool RuntimeModfiable() const = 0; + virtual void SetGlobal(bool global) {} + virtual constexpr u32 Id() const = 0; + virtual std::string MinVal() const = 0; + virtual std::string MaxVal() const = 0; + virtual bool UsingGlobal() const; +}; + +class Linkage { +public: + explicit Linkage(u32 initial_count = 0); + ~Linkage(); + std::map> by_category{}; + std::vector> restore_functions{}; + u32 count; +}; + +} // namespace Settings diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h new file mode 100644 index 000000000..f226e38d4 --- /dev/null +++ b/src/common/settings_setting.h @@ -0,0 +1,413 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "common/common_types.h" +#include "common/settings_common.h" +#include "common/settings_enums.h" + +namespace Settings { + +/** 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 be specified for sanitization. + */ +template +class Setting : public BasicSetting { +protected: + Setting() = default; + + /** + * Only sets the setting to the given initializer, leaving the other members to their default + * initializers. + * + * @param global_val Initial value of the setting + */ + explicit Setting(const Type& val) + : value{val}, + default_value{}, maximum{}, minimum{}, label{}, category{Category::Miscellaneous}, id{} {} + +public: + /** + * Sets a default value, label, and setting value. + * + * @param linkage Setting registry + * @param default_val Initial value of the setting, and default value of the setting + * @param name Label for the setting + * @param category_ Category of the setting AKA INI group + */ + explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, + enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) + requires(!ranged) + : value{default_val}, default_value{default_val}, label{name}, category{category_}, + id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} { + linkage.by_category[category].push_front(this); + linkage.count++; + } + virtual ~Setting() = default; + + /** + * Sets a default value, minimum value, maximum value, and label. + * + * @param linkage Setting registry + * @param default_val Initial value of the setting, and default value of the setting + * @param min_val Sets the minimum allowed value of the setting + * @param max_val Sets the maximum allowed value of the setting + * @param name Label for the setting + * @param category_ Category of the setting AKA INI group + */ + explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, + const Type& max_val, const std::string& name, enum Category category_, + bool save_ = true, bool runtime_modifiable_ = false) + requires(ranged) + : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, + label{name}, category{category_}, id{linkage.count}, save{save_}, + runtime_modifiable{runtime_modifiable_} { + linkage.by_category[category].push_front(this); + linkage.count++; + } + + /** + * Returns a reference to the setting's value. + * + * @returns A reference to the setting + */ + [[nodiscard]] virtual const Type& GetValue() const { + return value; + } + + /** + * Sets the setting to the given value. + * + * @param val The desired value + */ + virtual void SetValue(const Type& val) { + Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; + std::swap(value, temp); + } + + /** + * Returns the value that this setting was created with. + * + * @returns A reference to the default value + */ + [[nodiscard]] const Type& GetDefault() const { + return default_value; + } + + /** + * Returns the label this setting was created with. + * + * @returns A reference to the label + */ + [[nodiscard]] const std::string& GetLabel() const override { + return label; + } + + /** + * Returns the setting's category AKA INI group. + * + * @returns The setting's category + */ + [[nodiscard]] enum Category Category() const override { + return category; + } + + [[nodiscard]] bool RuntimeModfiable() const override { + return runtime_modifiable; + } + + [[nodiscard]] constexpr bool IsEnum() const override { + return std::is_enum::value; + } + + /** + * Returns whether the current setting is Switchable. + * + * @returns If the setting is a SwitchableSetting + */ + [[nodiscard]] virtual constexpr bool Switchable() const override { + return false; + } + +protected: + std::string ToString(const Type& value_) const { + if constexpr (std::is_same()) { + return value_; + } else if constexpr (std::is_same>()) { + return value_.has_value() ? std::to_string(*value_) : "none"; + } else if constexpr (std::is_same()) { + return value_ ? "true" : "false"; + } else if (std::is_same()) { + return CanonicalizeEnum(value_); + } else { + return std::to_string(static_cast(value_)); + } + } + +public: + /** + * Converts the value of the setting to a std::string. Respects the global state if the setting + * has one. + * + * @returns The current setting as a std::string + */ + std::string ToString() const override { + return ToString(this->GetValue()); + } + + /** + * Returns the default value of the setting as a std::string. + * + * @returns The default value as a string. + */ + std::string DefaultToString() const override { + return ToString(default_value); + } + + /** + * Assigns a value to the setting. + * + * @param val The desired setting value + * + * @returns A reference to the setting + */ + virtual const Type& operator=(const Type& val) { + Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; + std::swap(value, temp); + return value; + } + + /** + * Returns a reference to the setting. + * + * @returns A reference to the setting + */ + explicit virtual operator const Type&() const { + return value; + } + + /** + * Converts the given value to the Setting's type of value. Uses SetValue to enter the setting, + * thus respecting its constraints. + * + * @param input The desired value + */ + void LoadString(const std::string& input) override { + if (input.empty()) { + this->SetValue(this->GetDefault()); + return; + } + try { + if constexpr (std::is_same()) { + this->SetValue(input); + } else if constexpr (std::is_same>()) { + this->SetValue(static_cast(std::stoul(input))); + } else if constexpr (std::is_same()) { + this->SetValue(input == "true"); + } else if constexpr (std::is_same()) { + this->SetValue(ToEnum(input)); + } else { + this->SetValue(static_cast(std::stoll(input))); + } + } catch (std::invalid_argument) { + this->SetValue(this->GetDefault()); + } + } + + [[nodiscard]] std::string constexpr Canonicalize() const override { + if constexpr (std::is_enum::value) { + return CanonicalizeEnum(this->GetValue()); + } + return ToString(this->GetValue()); + } + + /** + * Returns the save preference of the setting i.e. when saving or reading the setting from a + * frontend, whether this setting should be skipped. + * + * @returns The save preference + */ + virtual bool Save() const override { + return save; + } + + /** + * Gives us another way to identify the setting without having to go through a string. + * + * @returns the type_index of the setting's type + */ + virtual std::type_index TypeId() const override { + return std::type_index(typeid(Type)); + } + + virtual constexpr u32 Id() const override { + return id; + } + + virtual std::string MinVal() const override { + return this->ToString(minimum); + } + virtual std::string MaxVal() const override { + return this->ToString(maximum); + } + +protected: + Type value{}; ///< The setting + const Type default_value{}; ///< The default value + const Type maximum{}; ///< Maximum allowed value of the setting + const Type minimum{}; ///< Minimum allowed value of the setting + const std::string label{}; ///< The setting's label + const enum Category category; ///< The setting's category AKA INI group + const u32 id; + bool save; + bool runtime_modifiable; +}; + +/** + * The SwitchableSetting class is a slightly more complex version of the Setting class. This adds a + * custom setting to switch to when a guest application specifically requires it. The effect is that + * other components of the emulator can access the setting's intended value without any need for the + * component to ask whether the custom or global setting is needed at the moment. + * + * By default, the global setting is used. + */ +template +class SwitchableSetting : virtual public Setting { +public: + /** + * Sets a default value, label, and setting value. + * + * @param linkage Setting registry + * @param default_val Initial value of the setting, and default value of the setting + * @param name Label for the setting + * @param category_ Category of the setting AKA INI group + */ + explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, + Category category, bool save = true, bool runtime_modifiable = false) + requires(!ranged) + : Setting{linkage, default_val, name, category, save, runtime_modifiable} { + linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); + } + virtual ~SwitchableSetting() = default; + + /** + * Sets a default value, minimum value, maximum value, and label. + * + * @param linkage Setting registry + * @param default_val Initial value of the setting, and default value of the setting + * @param min_val Sets the minimum allowed value of the setting + * @param max_val Sets the maximum allowed value of the setting + * @param name Label for the setting + * @param category_ Category of the setting AKA INI group + */ + explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, + const Type& max_val, const std::string& name, Category category, + bool save = true, bool runtime_modifiable = false) + requires(ranged) + : Setting{linkage, default_val, min_val, max_val, + name, category, save, runtime_modifiable} { + linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); + } + + /** + * Tells this setting to represent either the global or custom setting when other member + * functions are used. + * + * @param to_global Whether to use the global or custom setting. + */ + void SetGlobal(bool to_global) override { + use_global = to_global; + } + + /** + * Returns whether this setting is using the global setting or not. + * + * @returns The global state + */ + [[nodiscard]] bool UsingGlobal() const override { + return use_global; + } + + /** + * Returns either the global or custom setting depending on the values of this setting's global + * state or if the global value was specifically requested. + * + * @param need_global Request global value regardless of setting's state; defaults to false + * + * @returns The required value of the setting + */ + [[nodiscard]] virtual const Type& GetValue() const override { + if (use_global) { + return this->value; + } + return custom; + } + [[nodiscard]] virtual const Type& GetValue(bool need_global) const { + if (use_global || need_global) { + return this->value; + } + return custom; + } + + /** + * Sets the current setting value depending on the global state. + * + * @param val The new value + */ + void SetValue(const Type& val) override { + Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; + if (use_global) { + std::swap(this->value, temp); + } else { + std::swap(custom, temp); + } + } + + [[nodiscard]] virtual constexpr bool Switchable() const override { + return true; + } + + [[nodiscard]] virtual std::string ToStringGlobal() const override { + return this->ToString(this->value); + } + + /** + * Assigns the current setting value depending on the global state. + * + * @param val The new value + * + * @returns A reference to the current setting value + */ + const Type& operator=(const Type& val) override { + Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; + if (use_global) { + std::swap(this->value, temp); + return this->value; + } + std::swap(custom, temp); + return custom; + } + + /** + * Returns the current setting value depending on the global state. + * + * @returns A reference to the current setting value + */ + virtual explicit operator const Type&() const override { + if (use_global) { + return this->value; + } + return custom; + } + +protected: + bool use_global{true}; ///< The setting's global state + Type custom{}; ///< The custom value of the setting +}; + +} // namespace Settings -- cgit v1.2.3 From 4903f40efe7b0c193309708ea01bd6abea8bac16 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 11 Jun 2023 00:41:14 -0400 Subject: settings_setting: Fix errors ToString didn't have a constexpr if statement where needed. Canonicalize missed an else, causing unreachable code error on MSVC. --- src/common/settings_setting.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index f226e38d4..99a4bad01 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -142,7 +142,7 @@ protected: return value_.has_value() ? std::to_string(*value_) : "none"; } else if constexpr (std::is_same()) { return value_ ? "true" : "false"; - } else if (std::is_same()) { + } else if constexpr (std::is_same()) { return CanonicalizeEnum(value_); } else { return std::to_string(static_cast(value_)); @@ -222,8 +222,9 @@ public: [[nodiscard]] std::string constexpr Canonicalize() const override { if constexpr (std::is_enum::value) { return CanonicalizeEnum(this->GetValue()); + } else { + return ToString(this->GetValue()); } - return ToString(this->GetValue()); } /** -- cgit v1.2.3 From 11e7e1b8cec5a665bdc6c9e702f83ad6ea35dd6b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 12 Jun 2023 17:05:30 -0400 Subject: settings: Move some simple data to BasicSetting Reduces the need for the compiler to duplicate this code, by about 100KB executable size. --- src/common/CMakeLists.txt | 2 + src/common/settings.cpp | 8 ---- src/common/settings_common.cpp | 45 ++++++++++++++++++++ src/common/settings_common.h | 96 +++++++++++++++++++++++++++++++----------- src/common/settings_setting.h | 86 +++++-------------------------------- 5 files changed, 129 insertions(+), 108 deletions(-) create mode 100644 src/common/settings_common.cpp (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3c8368bb2..09e7e673e 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -110,6 +110,7 @@ add_library(common STATIC scratch_buffer.h settings.cpp settings.h + settings_common.cpp settings_common.h settings_enums.h settings_input.cpp @@ -199,6 +200,7 @@ if (MSVC) else() target_compile_options(common PRIVATE $<$:-fsized-deallocation> + $<$:-Werror=unreachable-code-aggressive> ) endif() diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 10cdea844..d98dd2925 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -282,14 +282,6 @@ void UpdateRescalingInfo() { info.active = info.up_scale != 1 || info.down_shift != 0; } -std::string BasicSetting::ToStringGlobal() const { - return {}; -} - -bool BasicSetting::UsingGlobal() const { - return true; -} - void RestoreGlobalState(bool is_powered_on) { // If a game is running, DO NOT restore the global settings state if (is_powered_on) { diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp new file mode 100644 index 000000000..a7ce99515 --- /dev/null +++ b/src/common/settings_common.cpp @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include "common/settings_common.h" + +namespace Settings { + +BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, + bool save_, bool runtime_modifiable_) + : label{name}, category{category_}, id{linkage.count}, save{save_}, runtime_modifiable{ + runtime_modifiable_} { + linkage.by_category[category].push_front(this); + linkage.count++; +} + +BasicSetting::~BasicSetting() = default; + +std::string BasicSetting::ToStringGlobal() const { + return this->ToString(); +} + +bool BasicSetting::UsingGlobal() const { + return true; +} + +void BasicSetting::SetGlobal(bool global) {} + +bool BasicSetting::Save() const { + return save; +} + +bool BasicSetting::RuntimeModfiable() const { + return runtime_modifiable; +} + +Category BasicSetting::Category() const { + return category; +} + +const std::string& BasicSetting::GetLabel() const { + return label; +} + +} // namespace Settings diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 93fddeba6..81d59115d 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include @@ -40,31 +43,7 @@ enum class Category : u32 { MaxEnum, }; -class BasicSetting { -protected: - explicit BasicSetting() = default; - -public: - virtual ~BasicSetting() = default; - - virtual Category Category() const = 0; - virtual constexpr bool Switchable() const = 0; - virtual std::string ToString() const = 0; - virtual std::string ToStringGlobal() const; - virtual void LoadString(const std::string& load) = 0; - virtual std::string Canonicalize() const = 0; - virtual const std::string& GetLabel() const = 0; - virtual std::string DefaultToString() const = 0; - virtual bool Save() const = 0; - virtual std::type_index TypeId() const = 0; - virtual constexpr bool IsEnum() const = 0; - virtual bool RuntimeModfiable() const = 0; - virtual void SetGlobal(bool global) {} - virtual constexpr u32 Id() const = 0; - virtual std::string MinVal() const = 0; - virtual std::string MaxVal() const = 0; - virtual bool UsingGlobal() const; -}; +class BasicSetting; class Linkage { public: @@ -75,4 +54,71 @@ public: u32 count; }; +class BasicSetting { +protected: + explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, + bool save_, bool runtime_modifiable_); + +public: + virtual ~BasicSetting(); + + /* Data retrieval */ + + [[nodiscard]] virtual std::string ToString() const = 0; + [[nodiscard]] virtual std::string ToStringGlobal() const; + [[nodiscard]] virtual std::string DefaultToString() const = 0; + [[nodiscard]] virtual std::string MinVal() const = 0; + [[nodiscard]] virtual std::string MaxVal() const = 0; + virtual void LoadString(const std::string& load) = 0; + [[nodiscard]] virtual std::string Canonicalize() const = 0; + + /* Identification */ + + [[nodiscard]] virtual std::type_index TypeId() const = 0; + [[nodiscard]] virtual constexpr bool IsEnum() const = 0; + /** + * Returns whether the current setting is Switchable. + * + * @returns If the setting is a SwitchableSetting + */ + [[nodiscard]] virtual constexpr bool Switchable() const { + return false; + } + /** + * Returns the save preference of the setting i.e. when saving or reading the setting from a + * frontend, whether this setting should be skipped. + * + * @returns The save preference + */ + [[nodiscard]] bool Save() const; + [[nodiscard]] bool RuntimeModfiable() const; + [[nodiscard]] constexpr u32 Id() const { + return id; + } + /** + * Returns the setting's category AKA INI group. + * + * @returns The setting's category + */ + [[nodiscard]] Category Category() const; + /** + * Returns the label this setting was created with. + * + * @returns A reference to the label + */ + [[nodiscard]] const std::string& GetLabel() const; + + /* Switchable settings */ + + virtual void SetGlobal(bool global); + [[nodiscard]] virtual bool UsingGlobal() const; + +private: + const std::string label; ///< The setting's label + const enum Category category; ///< The setting's category AKA INI group + const u32 id; + const bool save; + const bool runtime_modifiable; +}; + } // namespace Settings diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 99a4bad01..1ca3acf18 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include @@ -21,16 +24,6 @@ class Setting : public BasicSetting { protected: Setting() = default; - /** - * Only sets the setting to the given initializer, leaving the other members to their default - * initializers. - * - * @param global_val Initial value of the setting - */ - explicit Setting(const Type& val) - : value{val}, - default_value{}, maximum{}, minimum{}, label{}, category{Category::Miscellaneous}, id{} {} - public: /** * Sets a default value, label, and setting value. @@ -43,11 +36,8 @@ public: explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : value{default_val}, default_value{default_val}, label{name}, category{category_}, - id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} { - linkage.by_category[category].push_front(this); - linkage.count++; - } + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val}, + default_value{default_val} {} virtual ~Setting() = default; /** @@ -64,12 +54,8 @@ public: const Type& max_val, const std::string& name, enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) - : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, - label{name}, category{category_}, id{linkage.count}, save{save_}, - runtime_modifiable{runtime_modifiable_} { - linkage.by_category[category].push_front(this); - linkage.count++; - } + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val}, + default_value{default_val}, maximum{max_val}, minimum{min_val} {} /** * Returns a reference to the setting's value. @@ -99,41 +85,10 @@ public: return default_value; } - /** - * Returns the label this setting was created with. - * - * @returns A reference to the label - */ - [[nodiscard]] const std::string& GetLabel() const override { - return label; - } - - /** - * Returns the setting's category AKA INI group. - * - * @returns The setting's category - */ - [[nodiscard]] enum Category Category() const override { - return category; - } - - [[nodiscard]] bool RuntimeModfiable() const override { - return runtime_modifiable; - } - [[nodiscard]] constexpr bool IsEnum() const override { return std::is_enum::value; } - /** - * Returns whether the current setting is Switchable. - * - * @returns If the setting is a SwitchableSetting - */ - [[nodiscard]] virtual constexpr bool Switchable() const override { - return false; - } - protected: std::string ToString(const Type& value_) const { if constexpr (std::is_same()) { @@ -227,16 +182,6 @@ public: } } - /** - * Returns the save preference of the setting i.e. when saving or reading the setting from a - * frontend, whether this setting should be skipped. - * - * @returns The save preference - */ - virtual bool Save() const override { - return save; - } - /** * Gives us another way to identify the setting without having to go through a string. * @@ -246,10 +191,6 @@ public: return std::type_index(typeid(Type)); } - virtual constexpr u32 Id() const override { - return id; - } - virtual std::string MinVal() const override { return this->ToString(minimum); } @@ -258,15 +199,10 @@ public: } protected: - Type value{}; ///< The setting - const Type default_value{}; ///< The default value - const Type maximum{}; ///< Maximum allowed value of the setting - const Type minimum{}; ///< Minimum allowed value of the setting - const std::string label{}; ///< The setting's label - const enum Category category; ///< The setting's category AKA INI group - const u32 id; - bool save; - bool runtime_modifiable; + Type value{}; ///< The setting + const Type default_value{}; ///< The default value + const Type maximum{}; ///< Maximum allowed value of the setting + const Type minimum{}; ///< Minimum allowed value of the setting }; /** -- cgit v1.2.3 From b4f2ad3ff5c49549bc72997360c31d0662a97439 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:37:41 -0400 Subject: settings: Move IsConfiguringGlobal to settings_common --- src/common/settings.cpp | 9 --------- src/common/settings.h | 3 --- src/common/settings_common.cpp | 10 ++++++++++ src/common/settings_common.h | 3 +++ 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index d98dd2925..a1cc76a38 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -63,7 +63,6 @@ SWITCHABLE(u8, true); #undef SWITCHABLE Values values; -static bool configuring_global = true; std::string GetTimeZoneString() { const auto time_zone_index = static_cast(values.time_zone_index.GetValue()); @@ -131,14 +130,6 @@ void LogSettings() { log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir)); } -bool IsConfiguringGlobal() { - return configuring_global; -} - -void SetConfiguringGlobal(bool is_global) { - configuring_global = is_global; -} - bool IsGPULevelExtreme() { return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme; } diff --git a/src/common/settings.h b/src/common/settings.h index e03233eaf..afda3ccaf 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -450,9 +450,6 @@ struct Values { extern Values values; -bool IsConfiguringGlobal(); -void SetConfiguringGlobal(bool is_global); - bool IsGPULevelExtreme(); bool IsGPULevelHigh(); diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index a7ce99515..fb42991fa 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -42,4 +42,14 @@ const std::string& BasicSetting::GetLabel() const { return label; } +static bool configuring_global = true; + +bool IsConfiguringGlobal() { + return configuring_global; +} + +void SetConfiguringGlobal(bool is_global) { + configuring_global = is_global; +} + } // namespace Settings diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 81d59115d..9d1044a19 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -43,6 +43,9 @@ enum class Category : u32 { MaxEnum, }; +bool IsConfiguringGlobal(); +void SetConfiguringGlobal(bool is_global); + class BasicSetting; class Linkage { -- cgit v1.2.3 From 27e53990ed7100159cc08fd8470a9faecd011cbe Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:37:54 -0400 Subject: settings: Document BasicSetting, add Ranged --- src/common/settings_common.h | 115 ++++++++++++++++++++++++++++++++++++++---- src/common/settings_setting.h | 4 ++ 2 files changed, 110 insertions(+), 9 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 9d1044a19..4d6d3021e 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -57,6 +57,10 @@ public: u32 count; }; +/** + * BasicSetting is an abstract class that only keeps track of metadata. The string methods are + * available to get data values out. + */ class BasicSetting { protected: explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, @@ -65,45 +69,117 @@ protected: public: virtual ~BasicSetting(); - /* Data retrieval */ + /* + * Data retrieval + */ + /** + * Returns a string representation of the internal data. If the Setting is Switchable, it + * respects the internal global state: it is based on GetValue(). + * + * @returns A string representation of the internal data. + */ [[nodiscard]] virtual std::string ToString() const = 0; + + /** + * Returns a string representation of the global version of internal data. If the Setting is + * not Switchable, it behaves like ToString. + * + * @returns A string representation of the global version of internal data. + */ [[nodiscard]] virtual std::string ToStringGlobal() const; + + /** + * @returns A string representation of the Setting's default value. + */ [[nodiscard]] virtual std::string DefaultToString() const = 0; + + /** + * Returns a string representation of the minimum value of the setting. If the Setting is not + * ranged, the string represents the default initialization of the data type. + * + * @returns A string representation of the minimum value of the setting. + */ [[nodiscard]] virtual std::string MinVal() const = 0; + + /** + * Returns a string representation of the maximum value of the setting. If the Setting is not + * ranged, the string represents the default initialization of the data type. + * + * @returns A string representation of the maximum value of the setting. + */ [[nodiscard]] virtual std::string MaxVal() const = 0; + + /** + * Takes a string input, converts it to the internal data type if necessary, and then runs + * SetValue with it. + * + * @param load String of the input data. + */ virtual void LoadString(const std::string& load) = 0; + + /** + * Returns a string representation of the data. If the data is an enum, it returns a string of + * the enum value. If the internal data type is not an enum, this is equivalent to ToString. + * + * e.g. renderer_backend.Canonicalize() == "OpenGL" + * + * @returns Canonicalized string representation of the internal data + */ [[nodiscard]] virtual std::string Canonicalize() const = 0; - /* Identification */ + /* + * Metadata + */ + /** + * @returns A unique identifier for the Setting's internal data type. + */ [[nodiscard]] virtual std::type_index TypeId() const = 0; + + /** + * Returns true if the Setting's internal data type is an enum. + * + * @returns True if the Setting's internal data type is an enum + */ [[nodiscard]] virtual constexpr bool IsEnum() const = 0; + /** - * Returns whether the current setting is Switchable. + * Returns true if the current setting is Switchable. * * @returns If the setting is a SwitchableSetting */ [[nodiscard]] virtual constexpr bool Switchable() const { return false; } + /** - * Returns the save preference of the setting i.e. when saving or reading the setting from a - * frontend, whether this setting should be skipped. + * Returns true to suggest that a frontend can read or write the setting to a configuration + * file. * * @returns The save preference */ [[nodiscard]] bool Save() const; + + /** + * @returns true if the current setting can be changed while the guest is running. + */ [[nodiscard]] bool RuntimeModfiable() const; + + /** + * @returns A unique number corresponding to the setting. + */ [[nodiscard]] constexpr u32 Id() const { return id; } + /** * Returns the setting's category AKA INI group. * * @returns The setting's category */ [[nodiscard]] Category Category() const; + /** * Returns the label this setting was created with. * @@ -111,17 +187,38 @@ public: */ [[nodiscard]] const std::string& GetLabel() const; - /* Switchable settings */ + /** + * @returns If the Setting checks input values for valid ranges. + */ + [[nodiscard]] virtual constexpr bool Ranged() const = 0; + + /* + * Switchable settings + */ + /** + * Sets a setting's global state. True means use the normal setting, false to use a custom + * value. Has no effect if the Setting is not Switchable. + * + * @param global The desired state + */ virtual void SetGlobal(bool global); + + /** + * Returns true if the setting is using the normal setting value. Always true if the setting is + * not Switchable. + * + * @returns The Setting's global state + */ [[nodiscard]] virtual bool UsingGlobal() const; private: const std::string label; ///< The setting's label const enum Category category; ///< The setting's category AKA INI group - const u32 id; - const bool save; - const bool runtime_modifiable; + const u32 id; ///< Unique integer for the setting + const bool save; ///< Suggests if the setting should be saved and read to a frontend config + const bool + runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running }; } // namespace Settings diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 1ca3acf18..658b6328d 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -198,6 +198,10 @@ public: return this->ToString(maximum); } + constexpr bool Ranged() const override { + return ranged; + } + protected: Type value{}; ///< The setting const Type default_value{}; ///< The default value -- cgit v1.2.3 From a0883526d6a104404404ead384788adb767c88d5 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:45:51 -0400 Subject: settings: Delete cpu_accuracy_first_time Almost a 2 year old migration setting now --- src/common/settings.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index afda3ccaf..e510036b4 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -146,8 +146,6 @@ struct Values { SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, CpuAccuracy::Auto, CpuAccuracy::Paranoid, "cpu_accuracy", Category::Cpu}; - // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 - Setting cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu}; Setting cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::CpuDebug}; Setting cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::CpuDebug}; -- cgit v1.2.3 From ee32b177823b9b8499c9fd188a571884f00cf655 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Jun 2023 03:52:41 -0400 Subject: common,yuzu-qt: GCC warning silences Fixes -Wshadow, -Wdeprecated, and catch by copy rather than by ref. --- src/common/settings_common.h | 2 +- src/common/settings_setting.h | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 4d6d3021e..2b5c72f41 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -178,7 +178,7 @@ public: * * @returns The setting's category */ - [[nodiscard]] Category Category() const; + [[nodiscard]] enum Category Category() const; /** * Returns the label this setting was created with. diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 658b6328d..f803e4e6e 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -169,7 +170,7 @@ public: } else { this->SetValue(static_cast(std::stoll(input))); } - } catch (std::invalid_argument) { + } catch (std::invalid_argument& e) { this->SetValue(this->GetDefault()); } } @@ -229,9 +230,10 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category, bool save = true, bool runtime_modifiable = false) + Category category_, bool save_ = true, + bool runtime_modifiable_ = false) requires(!ranged) - : Setting{linkage, default_val, name, category, save, runtime_modifiable} { + : Setting{linkage, default_val, name, category_, save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -247,11 +249,11 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, Category category, - bool save = true, bool runtime_modifiable = false) + const Type& max_val, const std::string& name, Category category_, + bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) : Setting{linkage, default_val, min_val, max_val, - name, category, save, runtime_modifiable} { + name, category_, save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } -- cgit v1.2.3 From c97cbd089b371ed07234c66633f105862462826a Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Jun 2023 17:58:07 -0400 Subject: settings_setting: Fix MSVC error --- src/common/settings_setting.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index f803e4e6e..a0a05da54 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -170,7 +170,7 @@ public: } else { this->SetValue(static_cast(std::stoll(input))); } - } catch (std::invalid_argument& e) { + } catch (std::invalid_argument&) { this->SetValue(this->GetDefault()); } } -- cgit v1.2.3 From 3f0cc544cf7184adacec22aedd81f6d796bbea31 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Jun 2023 19:57:14 -0400 Subject: common,yuzu-qt: Avoid explicit instantiation on old clang Clang versions < 15 have compile issues with explicit instantiation. Disable it for these versions. --- src/common/CMakeLists.txt | 11 ++++++++--- src/common/settings.cpp | 2 ++ src/common/settings.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 09e7e673e..cf05ae364 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -197,10 +197,15 @@ if (MSVC) /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data /we4800 # Implicit conversion from 'type' to bool. Possible information loss ) -else() +endif() + +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(common PRIVATE - $<$:-fsized-deallocation> - $<$:-Werror=unreachable-code-aggressive> + -fsized-deallocation + -Werror=unreachable-code-aggressive + ) + target_compile_definitions(common PRIVATE + $<$,15>:_CANNOT_EXPLICITLY_INSTANTIATE> ) endif() diff --git a/src/common/settings.cpp b/src/common/settings.cpp index a1cc76a38..f4eb2d2fb 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -25,6 +25,7 @@ namespace Settings { +#ifndef _CANNOT_EXPLICITLY_INSTANTIATE #define SETTING(TYPE, RANGED) template class Setting #define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting @@ -61,6 +62,7 @@ SWITCHABLE(u8, true); #undef SETTING #undef SWITCHABLE +#endif Values values; diff --git a/src/common/settings.h b/src/common/settings.h index e510036b4..35fa4cf3d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -45,6 +45,7 @@ struct ResolutionScalingInfo { } }; +#ifndef _CANNOT_EXPLICITLY_INSTANTIATE // Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work #define SETTING(TYPE, RANGED) extern template class Setting #define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting @@ -84,6 +85,7 @@ SWITCHABLE(u8, true); #undef SETTING #undef SWITCHABLE +#endif /** * The InputSetting class allows for getting a reference to either the global or custom members. -- cgit v1.2.3 From 3a7705e7744305bc788b948e9893b0b504a662df Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:41:15 -0400 Subject: settings: Move speed_limit to core --- src/common/settings.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 35fa4cf3d..c9fe6f045 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -143,6 +143,10 @@ struct Values { SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; SwitchableSetting use_unsafe_extended_memory_layout{ linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; + SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", + Category::Core, false, true}; + SwitchableSetting speed_limit{linkage, 100, 0, 9999, "speed_limit", + Category::Core, true, true}; // Cpu SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, @@ -196,10 +200,6 @@ struct Values { Category::Renderer}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; - SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", Category::Renderer, - false, true}; - SwitchableSetting speed_limit{ - linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; SwitchableSetting accelerate_astc{linkage, AstcDecodeMode::Cpu, AstcDecodeMode::Cpu, -- cgit v1.2.3 From fdbeb841682b89d4c9fb112786e716f5fac9540c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 19:26:12 -0400 Subject: settings,uisettings: Remove leading underscore --- src/common/CMakeLists.txt | 2 +- src/common/settings.cpp | 2 +- src/common/settings.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index cf05ae364..e205055e6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -205,7 +205,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") -Werror=unreachable-code-aggressive ) target_compile_definitions(common PRIVATE - $<$,15>:_CANNOT_EXPLICITLY_INSTANTIATE> + $<$,15>:CANNOT_EXPLICITLY_INSTANTIATE> ) endif() diff --git a/src/common/settings.cpp b/src/common/settings.cpp index f4eb2d2fb..d9948dde8 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -25,7 +25,7 @@ namespace Settings { -#ifndef _CANNOT_EXPLICITLY_INSTANTIATE +#ifndef CANNOT_EXPLICITLY_INSTANTIATE #define SETTING(TYPE, RANGED) template class Setting #define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting diff --git a/src/common/settings.h b/src/common/settings.h index c9fe6f045..0ae71dd1b 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -45,7 +45,7 @@ struct ResolutionScalingInfo { } }; -#ifndef _CANNOT_EXPLICITLY_INSTANTIATE +#ifndef CANNOT_EXPLICITLY_INSTANTIATE // Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work #define SETTING(TYPE, RANGED) extern template class Setting #define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting -- cgit v1.2.3 From 7ffbffe170326eb8e21fa96e5374ba6b68370db6 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:25:39 -0400 Subject: settings_enums: More aggressively use macros This lets us define an enum and all the textual representations of its values in one swing. All for the price of some ugly macros. --- src/common/settings_enums.h | 500 +++++++++++++------------------------------- 1 file changed, 149 insertions(+), 351 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f3d76b927..71515257a 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -3,15 +3,72 @@ #pragma once -#include #include -#include -#include -#include +#include +#include #include "common/common_types.h" namespace Settings { +template +struct Canonicalization { + static constexpr std::vector> Get(); +}; + +#define PAIR_45(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) +#define PAIR_44(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_45(N, __VA_ARGS__)) +#define PAIR_43(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_44(N, __VA_ARGS__)) +#define PAIR_42(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_43(N, __VA_ARGS__)) +#define PAIR_41(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_42(N, __VA_ARGS__)) +#define PAIR_40(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_41(N, __VA_ARGS__)) +#define PAIR_39(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_40(N, __VA_ARGS__)) +#define PAIR_38(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_39(N, __VA_ARGS__)) +#define PAIR_37(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_38(N, __VA_ARGS__)) +#define PAIR_36(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_37(N, __VA_ARGS__)) +#define PAIR_35(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_36(N, __VA_ARGS__)) +#define PAIR_34(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_35(N, __VA_ARGS__)) +#define PAIR_33(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_34(N, __VA_ARGS__)) +#define PAIR_32(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_33(N, __VA_ARGS__)) +#define PAIR_31(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_32(N, __VA_ARGS__)) +#define PAIR_30(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_31(N, __VA_ARGS__)) +#define PAIR_29(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_30(N, __VA_ARGS__)) +#define PAIR_28(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_29(N, __VA_ARGS__)) +#define PAIR_27(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_28(N, __VA_ARGS__)) +#define PAIR_26(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_27(N, __VA_ARGS__)) +#define PAIR_25(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_26(N, __VA_ARGS__)) +#define PAIR_24(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_25(N, __VA_ARGS__)) +#define PAIR_23(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_24(N, __VA_ARGS__)) +#define PAIR_22(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_23(N, __VA_ARGS__)) +#define PAIR_21(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_22(N, __VA_ARGS__)) +#define PAIR_20(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_21(N, __VA_ARGS__)) +#define PAIR_19(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_20(N, __VA_ARGS__)) +#define PAIR_18(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_19(N, __VA_ARGS__)) +#define PAIR_17(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_18(N, __VA_ARGS__)) +#define PAIR_16(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_17(N, __VA_ARGS__)) +#define PAIR_15(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_16(N, __VA_ARGS__)) +#define PAIR_14(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_15(N, __VA_ARGS__)) +#define PAIR_13(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_14(N, __VA_ARGS__)) +#define PAIR_12(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_13(N, __VA_ARGS__)) +#define PAIR_11(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_12(N, __VA_ARGS__)) +#define PAIR_10(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_11(N, __VA_ARGS__)) +#define PAIR_9(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_10(N, __VA_ARGS__)) +#define PAIR_8(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_9(N, __VA_ARGS__)) +#define PAIR_7(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_8(N, __VA_ARGS__)) +#define PAIR_6(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_7(N, __VA_ARGS__)) +#define PAIR_5(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_6(N, __VA_ARGS__)) +#define PAIR_4(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_5(N, __VA_ARGS__)) +#define PAIR_3(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_4(N, __VA_ARGS__)) +#define PAIR_2(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_3(N, __VA_ARGS__)) +#define PAIR_1(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_2(N, __VA_ARGS__)) +#define PAIR(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_1(N, __VA_ARGS__)) + +#define ENUM(NAME, ...) \ + enum class NAME : u32 { __VA_ARGS__ }; \ + template <> \ + constexpr std::vector> Canonicalization::Get() { \ + return {PAIR(NAME, __VA_ARGS__)}; \ + } + enum class AudioEngine : u32 { Auto, Cubeb, @@ -19,380 +76,121 @@ enum class AudioEngine : u32 { Null, }; -enum class AudioMode : u32 { - Mono, - Stereo, - Surround, -}; +template <> +constexpr std::vector> Canonicalization::Get() { + return { + {"auto", static_cast(AudioEngine::Auto)}, + {"cubeb", static_cast(AudioEngine::Cubeb)}, + {"sdl2", static_cast(AudioEngine::Sdl2)}, + {"null", static_cast(AudioEngine::Null)}, + }; +} -enum class Language : u32 { - Japanese, - EnglishAmerican, - French, - German, - Italian, - Spanish, - Chinese, - Korean, - Dutch, - Portuguese, - Russian, - Taiwanese, - EnglishBritish, - FrenchCanadian, - SpanishLatin, - ChineseSimplified, - ChineseTraditional, - PortugueseBrazilian, -}; +ENUM(AudioMode, Mono, Stereo, Surround); -enum class Region : u32 { - Japan, - Usa, - Europe, - Australia, - China, - Korea, - Taiwan, -}; +ENUM(Language, Japanese, EnglishAmerican, French, German, Italian, Spanish, Chinese, Korean, Dutch, + Portuguese, Russian, Taiwanese, EnglishBritish, FrenchCanadian, SpanishLatin, + ChineseSimplified, ChineseTraditional, PortugueseBrazilian); -enum class TimeZone : u32 { - Auto, - Default, - CET, - CST6CDT, - Cuba, - EET, - Egypt, - Eire, - EST, - EST5EDT, - GB, - GBEire, - GMT, - GMTPlusZero, - GMTMinusZero, - GMTZero, - Greenwich, - Hongkong, - HST, - Iceland, - Iran, - Israel, - Jamaica, - Japan, - Kwajalein, - Libya, - MET, - MST, - MST7MDT, - Navajo, - NZ, - NZCHAT, - Poland, - Portugal, - PRC, - PST8PDT, - ROC, - ROK, - Singapore, - Turkey, - UCT, - Universal, - UTC, - W_SU, - WET, - Zulu, -}; +ENUM(Region, Japan, Usa, Europe, Australia, China, Korea, Taiwan); -enum class AnisotropyMode : u32 { - Automatic = 0, - Default = 1, - X2 = 2, - X4 = 3, - X8 = 4, - X16 = 5, -}; +ENUM(TimeZone, Auto, Default, CET, CST6CDT, Cuba, EET, Egypt, Eire, EST, EST5EDT, GB, GBEire, GMT, + GMTPlusZero, GMTMinusZero, GMTZero, Greenwich, Hongkong, HST, Iceland, Iran, Israel, Jamaica, + Japan, Kwajalein, Libya, MET, MST, MST7MDT, Navajo, NZ, NZCHAT, Poland, Portugal, PRC, PST8PDT, + ROC, ROK, Singapore, Turkey, UCT, Universal, UTC, W_SU, WET, Zulu); -enum class AstcDecodeMode : u32 { - Cpu = 0, - Gpu = 1, - CpuAsynchronous = 2, -}; +ENUM(AnisotropyMode, Automatic, Default, X2, X4, X8, X16); -enum class AstcRecompression : u32 { - Uncompressed = 0, - Bc1 = 1, - Bc3 = 2, -}; +ENUM(AstcDecodeMode, Cpu, Gpu, CpuAsynchronous); -enum class VSyncMode : u32 { - Immediate = 0, - Mailbox = 1, - Fifo = 2, - FifoRelaxed = 3, -}; +ENUM(AstcRecompression, Uncompressed, Bc1, Bc3); -enum class RendererBackend : u32 { - OpenGL = 0, - Vulkan = 1, - Null = 2, -}; +ENUM(VSyncMode, Immediate, Mailbox, Fifo, FifoRelaxed); -enum class ShaderBackend : u32 { - Glsl = 0, - Glasm = 1, - SpirV = 2, -}; +ENUM(RendererBackend, OpenGL, Vulkan, Null); -enum class GpuAccuracy : u32 { - Normal = 0, - High = 1, - Extreme = 2, -}; +ENUM(ShaderBackend, Glsl, Glasm, SpirV); -enum class CpuAccuracy : u32 { - Auto = 0, - Accurate = 1, - Unsafe = 2, - Paranoid = 3, -}; - -enum class FullscreenMode : u32 { - Borderless = 0, - Exclusive = 1, -}; - -enum class NvdecEmulation : u32 { - Off = 0, - Cpu = 1, - Gpu = 2, -}; - -enum class ResolutionSetup : u32 { - Res1_2X = 0, - Res3_4X = 1, - Res1X = 2, - Res3_2X = 3, - Res2X = 4, - Res3X = 5, - Res4X = 6, - Res5X = 7, - Res6X = 8, - Res7X = 9, - Res8X = 10, -}; +ENUM(GpuAccuracy, Normal, High, Extreme); -enum class ScalingFilter : u32 { - NearestNeighbor = 0, - Bilinear = 1, - Bicubic = 2, - Gaussian = 3, - ScaleForce = 4, - Fsr = 5, - LastFilter = Fsr, -}; +ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid); -enum class AntiAliasing : u32 { - None = 0, - Fxaa = 1, - Smaa = 2, - LastAA = Smaa, -}; +ENUM(FullscreenMode, Borderless, Exclusive); -enum class AspectRatio : u32 { - R16_9, - R4_3, - R21_9, - R16_10, - Stretch, -}; +ENUM(NvdecEmulation, Off, Cpu, Gpu); -#define X(ENUM, NAME) \ - { (#NAME), static_cast(ENUM::NAME) } +ENUM(ResolutionSetup, Res1_2X, Res3_4X, Res1X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, Res7X, + Res8X); -static const std::map> canonicalizations = { - {typeid(AudioEngine), - { - {"auto", static_cast(AudioEngine::Auto)}, - {"cubeb", static_cast(AudioEngine::Cubeb)}, - {"sdl2", static_cast(AudioEngine::Sdl2)}, - {"null", static_cast(AudioEngine::Null)}, - }}, - {typeid(AudioMode), - { - X(AudioMode, Mono), - X(AudioMode, Stereo), - X(AudioMode, Surround), - }}, - {typeid(Language), - { - X(Language, Japanese), - X(Language, EnglishAmerican), - X(Language, French), - X(Language, German), - X(Language, Italian), - X(Language, Spanish), - X(Language, Chinese), - X(Language, Korean), - X(Language, Dutch), - X(Language, Portuguese), - X(Language, Russian), - X(Language, Taiwanese), - X(Language, EnglishBritish), - X(Language, FrenchCanadian), - X(Language, SpanishLatin), - X(Language, ChineseSimplified), - X(Language, ChineseTraditional), - X(Language, PortugueseBrazilian), - }}, - {typeid(Region), - { - X(Region, Japan), - X(Region, Usa), - X(Region, Europe), - X(Region, Australia), - X(Region, China), - X(Region, Korea), - X(Region, Taiwan), - }}, - {typeid(TimeZone), - { - X(TimeZone, Auto), X(TimeZone, Default), X(TimeZone, CET), - X(TimeZone, CST6CDT), X(TimeZone, Cuba), X(TimeZone, EET), - X(TimeZone, Egypt), X(TimeZone, Eire), X(TimeZone, EST5EDT), - X(TimeZone, GB), X(TimeZone, GBEire), X(TimeZone, GMT), - X(TimeZone, GMTPlusZero), X(TimeZone, GMTMinusZero), X(TimeZone, GMTZero), - X(TimeZone, Greenwich), X(TimeZone, Hongkong), X(TimeZone, HST), - X(TimeZone, Iceland), X(TimeZone, Iran), X(TimeZone, Israel), - X(TimeZone, Jamaica), X(TimeZone, Japan), X(TimeZone, Kwajalein), - X(TimeZone, Libya), X(TimeZone, MET), X(TimeZone, MST), - X(TimeZone, MST7MDT), X(TimeZone, Navajo), X(TimeZone, NZ), - X(TimeZone, NZCHAT), X(TimeZone, Poland), X(TimeZone, Portugal), - X(TimeZone, PRC), X(TimeZone, ROC), X(TimeZone, ROK), - X(TimeZone, Singapore), X(TimeZone, Turkey), X(TimeZone, UCT), - X(TimeZone, Universal), X(TimeZone, UTC), X(TimeZone, W_SU), - X(TimeZone, WET), X(TimeZone, Zulu), - }}, - {typeid(AnisotropyMode), - { - X(AnisotropyMode, Automatic), - X(AnisotropyMode, Default), - X(AnisotropyMode, X2), - X(AnisotropyMode, X4), - X(AnisotropyMode, X8), - X(AnisotropyMode, X16), - }}, - {typeid(AstcDecodeMode), - { - X(AstcDecodeMode, Cpu), - X(AstcDecodeMode, Gpu), - X(AstcDecodeMode, CpuAsynchronous), - }}, - {typeid(AstcRecompression), - { - X(AstcRecompression, Uncompressed), - X(AstcRecompression, Bc1), - X(AstcRecompression, Bc3), - }}, - {typeid(VSyncMode), - { - X(VSyncMode, Immediate), - X(VSyncMode, Mailbox), - X(VSyncMode, Fifo), - X(VSyncMode, FifoRelaxed), - }}, - {typeid(RendererBackend), - { - X(RendererBackend, OpenGL), - X(RendererBackend, Vulkan), - X(RendererBackend, Null), - }}, - {typeid(ShaderBackend), - { - X(ShaderBackend, Glsl), - X(ShaderBackend, Glasm), - X(ShaderBackend, SpirV), - }}, - {typeid(GpuAccuracy), - { - X(GpuAccuracy, Normal), - X(GpuAccuracy, High), - X(GpuAccuracy, Extreme), - }}, - {typeid(CpuAccuracy), - { - X(CpuAccuracy, Auto), - X(CpuAccuracy, Accurate), - X(CpuAccuracy, Unsafe), - X(CpuAccuracy, Paranoid), - }}, - {typeid(FullscreenMode), - { - X(FullscreenMode, Borderless), - X(FullscreenMode, Exclusive), - }}, - {typeid(NvdecEmulation), - { - X(NvdecEmulation, Off), - X(NvdecEmulation, Cpu), - X(NvdecEmulation, Gpu), - }}, - {typeid(ResolutionSetup), - { - X(ResolutionSetup, Res1_2X), - X(ResolutionSetup, Res3_4X), - X(ResolutionSetup, Res1X), - X(ResolutionSetup, Res3_2X), - X(ResolutionSetup, Res2X), - X(ResolutionSetup, Res3X), - X(ResolutionSetup, Res4X), - X(ResolutionSetup, Res5X), - X(ResolutionSetup, Res6X), - X(ResolutionSetup, Res7X), - X(ResolutionSetup, Res8X), - }}, - {typeid(ScalingFilter), - { - X(ScalingFilter, NearestNeighbor), - X(ScalingFilter, Bilinear), - X(ScalingFilter, Bicubic), - X(ScalingFilter, Gaussian), - X(ScalingFilter, ScaleForce), - X(ScalingFilter, Fsr), - }}, - {typeid(AntiAliasing), - { - X(AntiAliasing, None), - X(AntiAliasing, Fxaa), - X(AntiAliasing, Smaa), - }}, - {typeid(AspectRatio), - { - X(AspectRatio, R16_9), - X(AspectRatio, R4_3), - X(AspectRatio, R21_9), - X(AspectRatio, R16_10), - X(AspectRatio, Stretch), - }}}; +ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, LastFilter); -#undef X +ENUM(AntiAliasing, None, Fxaa, Smaa, LastAA); -static const std::string invalid_string{"(invalid setting)"}; +ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); template -const std::string& CanonicalizeEnum(Type id) { - auto& group = canonicalizations.at(typeid(Type)); +constexpr std::string CanonicalizeEnum(Type id) { + const auto group = Canonicalization::Get(); for (auto& [name, value] : group) { if (static_cast(value) == id) { return name; } } - return invalid_string; + return "unknown"; } template -static Type ToEnum(const std::string& canonicalization) { - return static_cast(canonicalizations.at(typeid(Type)).at(canonicalization)); +constexpr Type ToEnum(const std::string& canonicalization) { + const auto group = Canonicalization::Get(); + for (auto& [name, value] : group) { + if (name == canonicalization) { + return static_cast(value); + } + } + return {}; } } // namespace Settings + +#undef ENUM +#undef PAIR +#undef PAIR_1 +#undef PAIR_2 +#undef PAIR_3 +#undef PAIR_4 +#undef PAIR_5 +#undef PAIR_6 +#undef PAIR_7 +#undef PAIR_8 +#undef PAIR_9 +#undef PAIR_10 +#undef PAIR_12 +#undef PAIR_13 +#undef PAIR_14 +#undef PAIR_15 +#undef PAIR_16 +#undef PAIR_17 +#undef PAIR_18 +#undef PAIR_19 +#undef PAIR_20 +#undef PAIR_22 +#undef PAIR_23 +#undef PAIR_24 +#undef PAIR_25 +#undef PAIR_26 +#undef PAIR_27 +#undef PAIR_28 +#undef PAIR_29 +#undef PAIR_30 +#undef PAIR_32 +#undef PAIR_33 +#undef PAIR_34 +#undef PAIR_35 +#undef PAIR_36 +#undef PAIR_37 +#undef PAIR_38 +#undef PAIR_39 +#undef PAIR_40 +#undef PAIR_42 +#undef PAIR_43 +#undef PAIR_44 +#undef PAIR_45 -- cgit v1.2.3 From 8366736b67d6febe278b6599badf4e945599bc30 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:29:07 -0400 Subject: settings,opengl,yuzu-qt: Fix AA, Filter maximums The new enum macros don't support setting values directly. For LastAA and LastFilter, this means we need a simpler approach to loop around the toggle in the frontend... --- src/common/settings_enums.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 71515257a..cc5c929cf 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -122,9 +122,9 @@ ENUM(NvdecEmulation, Off, Cpu, Gpu); ENUM(ResolutionSetup, Res1_2X, Res3_4X, Res1X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, Res7X, Res8X); -ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, LastFilter); +ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, MaxEnum); -ENUM(AntiAliasing, None, Fxaa, Smaa, LastAA); +ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum); ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); -- cgit v1.2.3 From 8b28aa45b99cc6f6c9399bbe421460de67088cff Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:34:03 -0400 Subject: settings,translation: Fix time zone enum Renames enum values to conform to naming convention. --- src/common/settings_enums.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index cc5c929cf..c380e409e 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -94,10 +94,10 @@ ENUM(Language, Japanese, EnglishAmerican, French, German, Italian, Spanish, Chin ENUM(Region, Japan, Usa, Europe, Australia, China, Korea, Taiwan); -ENUM(TimeZone, Auto, Default, CET, CST6CDT, Cuba, EET, Egypt, Eire, EST, EST5EDT, GB, GBEire, GMT, - GMTPlusZero, GMTMinusZero, GMTZero, Greenwich, Hongkong, HST, Iceland, Iran, Israel, Jamaica, - Japan, Kwajalein, Libya, MET, MST, MST7MDT, Navajo, NZ, NZCHAT, Poland, Portugal, PRC, PST8PDT, - ROC, ROK, Singapore, Turkey, UCT, Universal, UTC, W_SU, WET, Zulu); +ENUM(TimeZone, Auto, Default, Cet, Cst6Cdt, Cuba, Eet, Egypt, Eire, Est, Est5Edt, Gb, GbEire, Gmt, + GmtPlusZero, GmtMinusZero, GmtZero, Greenwich, Hongkong, Hst, Iceland, Iran, Israel, Jamaica, + Japan, Kwajalein, Libya, Met, Mst, Mst7Mdt, Navajo, Nz, NzChat, Poland, Portugal, Prc, Pst8Pdt, + Roc, Rok, Singapore, Turkey, Uct, Universal, Utc, WSu, Wet, Zulu); ENUM(AnisotropyMode, Automatic, Default, X2, X4, X8, X16); -- cgit v1.2.3 From b2438f1fb7d083ffe8c8afdc30e9c612631d6ace Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 03:23:36 -0400 Subject: settings: Define specializations for settings Suggests to a frontend how to represent each setting. --- src/common/settings.h | 136 ++++++++++++++++++++++++++--------------- src/common/settings_common.cpp | 11 +++- src/common/settings_common.h | 20 +++++- src/common/settings_setting.h | 27 +++++--- 4 files changed, 130 insertions(+), 64 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 0ae71dd1b..c78dd85c8 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -128,25 +128,31 @@ struct Values { Linkage linkage{}; // Audio - Setting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio}; - Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; - Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; + Setting sink_id{linkage, AudioEngine::Auto, "output_engine", Category::Audio, + Specialization::RuntimeList}; + Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio, + Specialization::RuntimeList}; + Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio, + Specialization::RuntimeList}; SwitchableSetting sound_index{linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, "sound_index", Category::SystemAudio}; - SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio, true, true}; - Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; - Setting dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio, - false}; + SwitchableSetting volume{ + linkage, 100, 0, 200, "volume", Category::Audio, Specialization::Scalar, true, true}; + Setting audio_muted{ + linkage, false, "audio_muted", Category::Audio, Specialization::Default, false}; + Setting dump_audio_commands{ + linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; // Core SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; SwitchableSetting use_unsafe_extended_memory_layout{ linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; - SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", - Category::Core, false, true}; - SwitchableSetting speed_limit{linkage, 100, 0, 9999, "speed_limit", - Category::Core, true, true}; + SwitchableSetting use_speed_limit{ + linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, false, true}; + SwitchableSetting speed_limit{ + linkage, 100, 0, 9999, "speed_limit", Category::Core, Specialization::Countable, + true, true}; // Cpu SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, @@ -192,9 +198,10 @@ struct Values { linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend", Category::Renderer}; SwitchableSetting shader_backend{ - linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, - "shader_backend", Category::Renderer}; - SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer}; + linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, + "shader_backend", Category::Renderer, Specialization::RuntimeList}; + SwitchableSetting vulkan_device{linkage, 0, "vulkan_device", Category::Renderer, + Specialization::RuntimeList}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; @@ -206,14 +213,10 @@ struct Values { AstcDecodeMode::CpuAsynchronous, "accelerate_astc", Category::Renderer}; - Setting vsync_mode{linkage, - VSyncMode::Fifo, - VSyncMode::Immediate, - VSyncMode::FifoRelaxed, - "use_vsync", - Category::Renderer, - true, - true}; + Setting vsync_mode{ + linkage, VSyncMode::Fifo, VSyncMode::Immediate, VSyncMode::FifoRelaxed, + "use_vsync", Category::Renderer, Specialization::RuntimeList, true, + true}; SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, "nvdec_emulation", Category::Renderer}; // *nix platforms may have issues with the borderless windowed fullscreen mode. @@ -228,6 +231,7 @@ struct Values { FullscreenMode::Exclusive, "fullscreen_mode", Category::Renderer, + Specialization::Default, true, true}; SwitchableSetting aspect_ratio{linkage, @@ -236,22 +240,37 @@ struct Values { AspectRatio::Stretch, "aspect_ratio", Category::Renderer, + Specialization::Default, true, true}; ResolutionScalingInfo resolution_info{}; SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{ - linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; - SwitchableSetting anti_aliasing{ - linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; + SwitchableSetting scaling_filter{linkage, + ScalingFilter::Bilinear, + "scaling_filter", + Category::Renderer, + Specialization::Default, + true, + true}; + SwitchableSetting anti_aliasing{linkage, + AntiAliasing::None, + "anti_aliasing", + Category::Renderer, + Specialization::Default, + true, + true}; SwitchableSetting fsr_sharpening_slider{ - linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; + linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, Specialization::Scalar, + true, true}; - SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer, true, true}; - SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer, true, true}; - SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; + SwitchableSetting bg_red{ + linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true}; + SwitchableSetting bg_green{ + linkage, 0, "bg_green", Category::Renderer, Specialization::Default, true, true}; + SwitchableSetting bg_blue{ + linkage, 0, "bg_blue", Category::Renderer, Specialization::Default, true, true}; SwitchableSetting gpu_accuracy{linkage, GpuAccuracy::High, @@ -259,6 +278,7 @@ struct Values { GpuAccuracy::Extreme, "gpu_accuracy", Category::RendererAdvanced, + Specialization::Default, true, true}; SwitchableSetting max_anisotropy{ @@ -279,9 +299,15 @@ struct Values { SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; SwitchableSetting use_fast_gpu_time{ - linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, true, true}; - SwitchableSetting use_vulkan_driver_pipeline_cache{ - linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true}; + linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, Specialization::Default, + true, true}; + SwitchableSetting use_vulkan_driver_pipeline_cache{linkage, + true, + "use_vulkan_driver_pipeline_cache", + Category::RendererAdvanced, + Specialization::Default, + true, + true}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::RendererAdvanced}; SwitchableSetting use_video_framerate{linkage, false, "use_video_framerate", @@ -310,15 +336,18 @@ struct Values { TimeZone::Auto, TimeZone::Zulu, "time_zone_index", Category::System}; // Measured in seconds since epoch - SwitchableSetting custom_rtc_enabled{linkage, false, "custom_rtc_enabled", - Category::System, true, true}; - SwitchableSetting custom_rtc{linkage, 0, "custom_rtc", Category::System, true, true}; + SwitchableSetting custom_rtc_enabled{ + linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; + SwitchableSetting custom_rtc{ + linkage, 0, "custom_rtc", Category::System, Specialization::Time, true, true}; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` s64 custom_rtc_differential; - SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", - Category::System, true, true}; - SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, true, true}; - Setting device_name{linkage, "yuzu", "device_name", Category::System, true, true}; + SwitchableSetting rng_seed_enabled{ + linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; + SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, Specialization::Hex, + true, true}; + Setting device_name{ + linkage, "yuzu", "device_name", Category::System, Specialization::Default, true, true}; Setting current_user{linkage, 0, "current_user", Category::System}; @@ -327,12 +356,13 @@ struct Values { // Controls InputSetting> players; - Setting enable_raw_input{linkage, false, "enable_raw_input", Category::Controls, + Setting enable_raw_input{ + linkage, false, "enable_raw_input", Category::Controls, Specialization::Default, // Only read/write enable_raw_input on Windows platforms #ifdef _WIN32 - true + true #else - false + false #endif }; Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; @@ -354,7 +384,8 @@ struct Values { Setting tas_enable{linkage, false, "tas_enable", Category::Controls}; Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; - Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls, false}; + Setting mouse_panning{ + linkage, false, "mouse_panning", Category::Controls, Specialization::Default, false}; Setting mouse_panning_sensitivity{ linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; @@ -410,19 +441,24 @@ struct Values { Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; - Setting dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics, false}; - Setting dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics, false}; + Setting dump_shaders{ + linkage, false, "dump_shaders", Category::DebuggingGraphics, Specialization::Default, + false}; + Setting dump_macros{ + linkage, false, "dump_macros", Category::DebuggingGraphics, Specialization::Default, false}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; - Setting reporting_services{linkage, false, "reporting_services", Category::Debugging, - false}; + Setting reporting_services{ + linkage, false, "reporting_services", Category::Debugging, Specialization::Default, false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::DebuggingGraphics}; - Setting extended_logging{linkage, false, "extended_logging", Category::Debugging, false}; + Setting extended_logging{ + linkage, false, "extended_logging", Category::Debugging, Specialization::Default, false}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; - Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false}; + Setting use_auto_stub{ + linkage, false, "use_auto_stub", Category::Debugging, Specialization::Default, false}; Setting enable_all_controllers{linkage, false, "enable_all_controllers", Category::Debugging}; Setting create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging}; diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index fb42991fa..3e86c7347 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -7,9 +7,10 @@ namespace Settings { BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_) - : label{name}, category{category_}, id{linkage.count}, save{save_}, runtime_modifiable{ - runtime_modifiable_} { + bool save_, bool runtime_modifiable_, + enum Specialization specialization_) + : label{name}, category{category_}, id{linkage.count}, save{save_}, + runtime_modifiable{runtime_modifiable_}, specialization{specialization_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -38,6 +39,10 @@ Category BasicSetting::Category() const { return category; } +Specialization BasicSetting::Specialization() const { + return specialization; +} + const std::string& BasicSetting::GetLabel() const { return label; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 2b5c72f41..664c807f1 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -43,6 +43,17 @@ enum class Category : u32 { MaxEnum, }; +enum class Specialization : u32 { + Default, + Time, + Hex, + List, + RuntimeList, + Scalar, + Countable, + Paired, +}; + bool IsConfiguringGlobal(); void SetConfiguringGlobal(bool is_global); @@ -64,7 +75,7 @@ public: class BasicSetting { protected: explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_); + bool save_, bool runtime_modifiable_, Specialization spec); public: virtual ~BasicSetting(); @@ -180,6 +191,11 @@ public: */ [[nodiscard]] enum Category Category() const; + /** + * @returns Extra metadata for data representation in frontend implementations. + */ + [[nodiscard]] enum Specialization Specialization() const; + /** * Returns the label this setting was created with. * @@ -219,6 +235,8 @@ private: const bool save; ///< Suggests if the setting should be saved and read to a frontend config const bool runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running + const enum Specialization + specialization; ///< Extra data to identify representation of a setting }; } // namespace Settings diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index a0a05da54..9805a5b5d 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -35,10 +35,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) + enum Category category_, + enum Specialization specialization = Specialization::Default, + bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val}, - default_value{default_val} {} + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), + value{default_val}, default_value{default_val} {} virtual ~Setting() = default; /** @@ -53,10 +55,11 @@ public: */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, enum Category category_, + enum Specialization specialization = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val}, - default_value{default_val}, maximum{max_val}, minimum{min_val} {} + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), + value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val} {} /** * Returns a reference to the setting's value. @@ -230,10 +233,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category_, bool save_ = true, - bool runtime_modifiable_ = false) + Category category_, + enum Specialization specialization = Specialization::Default, + bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : Setting{linkage, default_val, name, category_, save_, runtime_modifiable_} { + : Setting{linkage, default_val, name, category_, specialization, + save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -250,10 +255,12 @@ public: */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category_, + enum Specialization specialization = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) - : Setting{linkage, default_val, min_val, max_val, - name, category_, save_, runtime_modifiable_} { + : Setting{linkage, default_val, min_val, + max_val, name, category_, + specialization, save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } -- cgit v1.2.3 From 7f708e8d77fb6237407f49246622dbe1b445d536 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 04:32:13 -0400 Subject: settings: Define paired settings settings_common: Remove unused optional --- src/common/settings.h | 21 +++++++++++++++------ src/common/settings_common.cpp | 9 +++++++-- src/common/settings_common.h | 11 +++++++++-- src/common/settings_setting.h | 29 ++++++++++++++++++----------- 4 files changed, 49 insertions(+), 21 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index c78dd85c8..b87301d4e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -150,9 +150,16 @@ struct Values { linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; SwitchableSetting use_speed_limit{ linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, false, true}; - SwitchableSetting speed_limit{ - linkage, 100, 0, 9999, "speed_limit", Category::Core, Specialization::Countable, - true, true}; + SwitchableSetting speed_limit{linkage, + 100, + 0, + 9999, + "speed_limit", + Category::Core, + Specialization::Countable, + true, + true, + &use_speed_limit}; // Cpu SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, @@ -339,13 +346,15 @@ struct Values { SwitchableSetting custom_rtc_enabled{ linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; SwitchableSetting custom_rtc{ - linkage, 0, "custom_rtc", Category::System, Specialization::Time, true, true}; + linkage, 0, "custom_rtc", Category::System, Specialization::Time, + true, true, &custom_rtc_enabled}; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` s64 custom_rtc_differential; SwitchableSetting rng_seed_enabled{ linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; - SwitchableSetting rng_seed{linkage, 0, "rng_seed", Category::System, Specialization::Hex, - true, true}; + SwitchableSetting rng_seed{ + linkage, 0, "rng_seed", Category::System, Specialization::Hex, + true, true, &rng_seed_enabled}; Setting device_name{ linkage, "yuzu", "device_name", Category::System, Specialization::Default, true, true}; diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 3e86c7347..53d4548f5 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -8,9 +8,10 @@ namespace Settings { BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, bool save_, bool runtime_modifiable_, - enum Specialization specialization_) + enum Specialization specialization_, BasicSetting* other_setting_) : label{name}, category{category_}, id{linkage.count}, save{save_}, - runtime_modifiable{runtime_modifiable_}, specialization{specialization_} { + runtime_modifiable{runtime_modifiable_}, specialization{specialization_}, + other_setting{other_setting_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -43,6 +44,10 @@ Specialization BasicSetting::Specialization() const { return specialization; } +BasicSetting* BasicSetting::PairedSetting() const { + return other_setting; +} + const std::string& BasicSetting::GetLabel() const { return label; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 664c807f1..ad005ca4e 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -75,7 +75,8 @@ public: class BasicSetting { protected: explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_, Specialization spec); + bool save_, bool runtime_modifiable_, Specialization spec, + BasicSetting* other_setting); public: virtual ~BasicSetting(); @@ -196,6 +197,11 @@ public: */ [[nodiscard]] enum Specialization Specialization() const; + /** + * @returns Another BasicSetting if one is paired, or nullptr otherwise. + */ + [[nodiscard]] BasicSetting* PairedSetting() const; + /** * Returns the label this setting was created with. * @@ -236,7 +242,8 @@ private: const bool runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running const enum Specialization - specialization; ///< Extra data to identify representation of a setting + specialization; ///< Extra data to identify representation of a setting + BasicSetting* const other_setting; ///< A paired setting }; } // namespace Settings diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 9805a5b5d..dd91250a1 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -37,9 +37,11 @@ public: explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, enum Category category_, enum Specialization specialization = Specialization::Default, - bool save_ = true, bool runtime_modifiable_ = false) + bool save_ = true, bool runtime_modifiable_ = false, + BasicSetting* other_setting = nullptr) requires(!ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, + other_setting), value{default_val}, default_value{default_val} {} virtual ~Setting() = default; @@ -56,9 +58,11 @@ public: explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, enum Category category_, enum Specialization specialization = Specialization::Default, - bool save_ = true, bool runtime_modifiable_ = false) + bool save_ = true, bool runtime_modifiable_ = false, + BasicSetting* other_setting = nullptr) requires(ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, + other_setting), value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val} {} /** @@ -235,10 +239,12 @@ public: explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, Category category_, enum Specialization specialization = Specialization::Default, - bool save_ = true, bool runtime_modifiable_ = false) + bool save_ = true, bool runtime_modifiable_ = false, + BasicSetting* other_setting = nullptr) requires(!ranged) - : Setting{linkage, default_val, name, category_, specialization, - save_, runtime_modifiable_} { + : Setting{ + linkage, default_val, name, category_, specialization, + save_, runtime_modifiable_, other_setting} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -256,11 +262,12 @@ public: explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category_, enum Specialization specialization = Specialization::Default, - bool save_ = true, bool runtime_modifiable_ = false) + bool save_ = true, bool runtime_modifiable_ = false, + BasicSetting* other_setting = nullptr) requires(ranged) - : Setting{linkage, default_val, min_val, - max_val, name, category_, - specialization, save_, runtime_modifiable_} { + : Setting{ + linkage, default_val, min_val, max_val, name, category_, specialization, + save_, runtime_modifiable_, other_setting} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } -- cgit v1.2.3 From 926f3e3d3e6ff57633d2d44085f02754ffe1c988 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 05:04:21 -0400 Subject: settings,configuration: Add a default suffix --- src/common/settings.h | 26 ++++++++++++++++++++------ src/common/settings_common.cpp | 6 +++--- src/common/settings_common.h | 33 +++++++++++++++++++-------------- src/common/settings_setting.h | 15 ++++++--------- 4 files changed, 48 insertions(+), 32 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index b87301d4e..c4339cb1f 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -137,8 +137,15 @@ struct Values { SwitchableSetting sound_index{linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, "sound_index", Category::SystemAudio}; - SwitchableSetting volume{ - linkage, 100, 0, 200, "volume", Category::Audio, Specialization::Scalar, true, true}; + SwitchableSetting volume{linkage, + 100, + 0, + 200, + "volume", + Category::Audio, + Specialization::Scalar | Specialization::Percentage, + true, + true}; Setting audio_muted{ linkage, false, "audio_muted", Category::Audio, Specialization::Default, false}; Setting dump_audio_commands{ @@ -156,7 +163,7 @@ struct Values { 9999, "speed_limit", Category::Core, - Specialization::Countable, + Specialization::Countable | Specialization::Percentage, true, true, &use_speed_limit}; @@ -268,9 +275,16 @@ struct Values { Specialization::Default, true, true}; - SwitchableSetting fsr_sharpening_slider{ - linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, Specialization::Scalar, - true, true}; + SwitchableSetting fsr_sharpening_slider{linkage, + 25, + 0, + 200, + "fsr_sharpening_slider", + Category::Renderer, + Specialization::Scalar | + Specialization::Percentage, + true, + true}; SwitchableSetting bg_red{ linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true}; diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 53d4548f5..799942980 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -7,8 +7,8 @@ namespace Settings { BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_, - enum Specialization specialization_, BasicSetting* other_setting_) + bool save_, bool runtime_modifiable_, u32 specialization_, + BasicSetting* other_setting_) : label{name}, category{category_}, id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_}, specialization{specialization_}, other_setting{other_setting_} { @@ -40,7 +40,7 @@ Category BasicSetting::Category() const { return category; } -Specialization BasicSetting::Specialization() const { +u32 BasicSetting::Specialization() const { return specialization; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index ad005ca4e..6b717deb1 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -43,15 +43,21 @@ enum class Category : u32 { MaxEnum, }; -enum class Specialization : u32 { - Default, - Time, - Hex, - List, - RuntimeList, - Scalar, - Countable, - Paired, +constexpr u8 SpecializationTypeMask = 0xf; +constexpr u8 SpecializationAttributeMask = 0xf0; +constexpr u8 SpecializationAttributeOffset = 4; + +enum Specialization : u8 { + Default = 0, + Time = 1, + Hex = 2, + List = 3, + RuntimeList = 4, + Scalar = 5, + Countable = 6, + Paired = 7, + + Percentage = (1 << SpecializationAttributeOffset), }; bool IsConfiguringGlobal(); @@ -75,7 +81,7 @@ public: class BasicSetting { protected: explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_, Specialization spec, + bool save_, bool runtime_modifiable_, u32 specialization, BasicSetting* other_setting); public: @@ -195,7 +201,7 @@ public: /** * @returns Extra metadata for data representation in frontend implementations. */ - [[nodiscard]] enum Specialization Specialization() const; + [[nodiscard]] u32 Specialization() const; /** * @returns Another BasicSetting if one is paired, or nullptr otherwise. @@ -240,9 +246,8 @@ private: const u32 id; ///< Unique integer for the setting const bool save; ///< Suggests if the setting should be saved and read to a frontend config const bool - runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running - const enum Specialization - specialization; ///< Extra data to identify representation of a setting + runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running + const u32 specialization; ///< Extra data to identify representation of a setting BasicSetting* const other_setting; ///< A paired setting }; diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index dd91250a1..d1915cb43 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -35,8 +35,7 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_, - enum Specialization specialization = Specialization::Default, + enum Category category_, u32 specialization = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, BasicSetting* other_setting = nullptr) requires(!ranged) @@ -57,9 +56,8 @@ public: */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, enum Category category_, - enum Specialization specialization = Specialization::Default, - bool save_ = true, bool runtime_modifiable_ = false, - BasicSetting* other_setting = nullptr) + u32 specialization = Specialization::Default, bool save_ = true, + bool runtime_modifiable_ = false, BasicSetting* other_setting = nullptr) requires(ranged) : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, other_setting), @@ -237,8 +235,7 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category_, - enum Specialization specialization = Specialization::Default, + Category category_, u32 specialization = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, BasicSetting* other_setting = nullptr) requires(!ranged) @@ -261,8 +258,8 @@ public: */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category_, - enum Specialization specialization = Specialization::Default, - bool save_ = true, bool runtime_modifiable_ = false, + u32 specialization = Specialization::Default, bool save_ = true, + bool runtime_modifiable_ = false, BasicSetting* other_setting = nullptr) requires(ranged) : Setting{ -- cgit v1.2.3 From 54d58130a0818efc4d70d72624f734f2b6f0a6d3 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:38:30 -0400 Subject: settings_setting: Silence shadowing warnings --- src/common/settings_setting.h | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index d1915cb43..eb46b2b6d 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -35,12 +35,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_, u32 specialization = Specialization::Default, + enum Category category_, u32 specialization_ = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, - BasicSetting* other_setting = nullptr) + BasicSetting* other_setting_ = nullptr) requires(!ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, - other_setting), + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization_, + other_setting_), value{default_val}, default_value{default_val} {} virtual ~Setting() = default; @@ -56,11 +56,11 @@ public: */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, enum Category category_, - u32 specialization = Specialization::Default, bool save_ = true, - bool runtime_modifiable_ = false, BasicSetting* other_setting = nullptr) + u32 specialization_ = Specialization::Default, bool save_ = true, + bool runtime_modifiable_ = false, BasicSetting* other_setting_ = nullptr) requires(ranged) - : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, - other_setting), + : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization_, + other_setting_), value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val} {} /** @@ -235,13 +235,13 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category_, u32 specialization = Specialization::Default, + Category category_, u32 specialization_ = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, - BasicSetting* other_setting = nullptr) + BasicSetting* other_setting_ = nullptr) requires(!ranged) : Setting{ - linkage, default_val, name, category_, specialization, - save_, runtime_modifiable_, other_setting} { + linkage, default_val, name, category_, specialization_, + save_, runtime_modifiable_, other_setting_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -258,13 +258,14 @@ public: */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category_, - u32 specialization = Specialization::Default, bool save_ = true, + u32 specialization_ = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, - BasicSetting* other_setting = nullptr) + BasicSetting* other_setting_ = nullptr) requires(ranged) - : Setting{ - linkage, default_val, min_val, max_val, name, category_, specialization, - save_, runtime_modifiable_, other_setting} { + : Setting{linkage, default_val, min_val, + max_val, name, category_, + specialization_, save_, runtime_modifiable_, + other_setting_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } -- cgit v1.2.3 From 8497fb0a046a208b0abcda9ba31ec77866ec922d Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:39:28 -0400 Subject: settings_enums: Remove casting Not sure how I missed this earlier, but these vectors can be constructed using the type of the enum. --- src/common/settings_enums.h | 110 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index c380e409e..a5f87c956 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -12,60 +12,60 @@ namespace Settings { template struct Canonicalization { - static constexpr std::vector> Get(); + static constexpr std::vector> Get(); }; -#define PAIR_45(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) -#define PAIR_44(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_45(N, __VA_ARGS__)) -#define PAIR_43(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_44(N, __VA_ARGS__)) -#define PAIR_42(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_43(N, __VA_ARGS__)) -#define PAIR_41(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_42(N, __VA_ARGS__)) -#define PAIR_40(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_41(N, __VA_ARGS__)) -#define PAIR_39(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_40(N, __VA_ARGS__)) -#define PAIR_38(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_39(N, __VA_ARGS__)) -#define PAIR_37(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_38(N, __VA_ARGS__)) -#define PAIR_36(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_37(N, __VA_ARGS__)) -#define PAIR_35(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_36(N, __VA_ARGS__)) -#define PAIR_34(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_35(N, __VA_ARGS__)) -#define PAIR_33(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_34(N, __VA_ARGS__)) -#define PAIR_32(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_33(N, __VA_ARGS__)) -#define PAIR_31(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_32(N, __VA_ARGS__)) -#define PAIR_30(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_31(N, __VA_ARGS__)) -#define PAIR_29(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_30(N, __VA_ARGS__)) -#define PAIR_28(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_29(N, __VA_ARGS__)) -#define PAIR_27(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_28(N, __VA_ARGS__)) -#define PAIR_26(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_27(N, __VA_ARGS__)) -#define PAIR_25(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_26(N, __VA_ARGS__)) -#define PAIR_24(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_25(N, __VA_ARGS__)) -#define PAIR_23(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_24(N, __VA_ARGS__)) -#define PAIR_22(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_23(N, __VA_ARGS__)) -#define PAIR_21(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_22(N, __VA_ARGS__)) -#define PAIR_20(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_21(N, __VA_ARGS__)) -#define PAIR_19(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_20(N, __VA_ARGS__)) -#define PAIR_18(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_19(N, __VA_ARGS__)) -#define PAIR_17(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_18(N, __VA_ARGS__)) -#define PAIR_16(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_17(N, __VA_ARGS__)) -#define PAIR_15(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_16(N, __VA_ARGS__)) -#define PAIR_14(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_15(N, __VA_ARGS__)) -#define PAIR_13(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_14(N, __VA_ARGS__)) -#define PAIR_12(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_13(N, __VA_ARGS__)) -#define PAIR_11(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_12(N, __VA_ARGS__)) -#define PAIR_10(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_11(N, __VA_ARGS__)) -#define PAIR_9(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_10(N, __VA_ARGS__)) -#define PAIR_8(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_9(N, __VA_ARGS__)) -#define PAIR_7(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_8(N, __VA_ARGS__)) -#define PAIR_6(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_7(N, __VA_ARGS__)) -#define PAIR_5(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_6(N, __VA_ARGS__)) -#define PAIR_4(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_5(N, __VA_ARGS__)) -#define PAIR_3(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_4(N, __VA_ARGS__)) -#define PAIR_2(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_3(N, __VA_ARGS__)) -#define PAIR_1(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_2(N, __VA_ARGS__)) -#define PAIR(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_1(N, __VA_ARGS__)) +#define PAIR_45(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) +#define PAIR_44(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_45(N, __VA_ARGS__)) +#define PAIR_43(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_44(N, __VA_ARGS__)) +#define PAIR_42(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_43(N, __VA_ARGS__)) +#define PAIR_41(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_42(N, __VA_ARGS__)) +#define PAIR_40(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_41(N, __VA_ARGS__)) +#define PAIR_39(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_40(N, __VA_ARGS__)) +#define PAIR_38(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_39(N, __VA_ARGS__)) +#define PAIR_37(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_38(N, __VA_ARGS__)) +#define PAIR_36(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_37(N, __VA_ARGS__)) +#define PAIR_35(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_36(N, __VA_ARGS__)) +#define PAIR_34(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_35(N, __VA_ARGS__)) +#define PAIR_33(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_34(N, __VA_ARGS__)) +#define PAIR_32(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_33(N, __VA_ARGS__)) +#define PAIR_31(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_32(N, __VA_ARGS__)) +#define PAIR_30(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_31(N, __VA_ARGS__)) +#define PAIR_29(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_30(N, __VA_ARGS__)) +#define PAIR_28(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_29(N, __VA_ARGS__)) +#define PAIR_27(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_28(N, __VA_ARGS__)) +#define PAIR_26(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_27(N, __VA_ARGS__)) +#define PAIR_25(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_26(N, __VA_ARGS__)) +#define PAIR_24(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_25(N, __VA_ARGS__)) +#define PAIR_23(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_24(N, __VA_ARGS__)) +#define PAIR_22(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_23(N, __VA_ARGS__)) +#define PAIR_21(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_22(N, __VA_ARGS__)) +#define PAIR_20(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_21(N, __VA_ARGS__)) +#define PAIR_19(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_20(N, __VA_ARGS__)) +#define PAIR_18(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_19(N, __VA_ARGS__)) +#define PAIR_17(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_18(N, __VA_ARGS__)) +#define PAIR_16(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_17(N, __VA_ARGS__)) +#define PAIR_15(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_16(N, __VA_ARGS__)) +#define PAIR_14(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_15(N, __VA_ARGS__)) +#define PAIR_13(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_14(N, __VA_ARGS__)) +#define PAIR_12(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_13(N, __VA_ARGS__)) +#define PAIR_11(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_12(N, __VA_ARGS__)) +#define PAIR_10(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_11(N, __VA_ARGS__)) +#define PAIR_9(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_10(N, __VA_ARGS__)) +#define PAIR_8(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_9(N, __VA_ARGS__)) +#define PAIR_7(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_8(N, __VA_ARGS__)) +#define PAIR_6(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_7(N, __VA_ARGS__)) +#define PAIR_5(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_6(N, __VA_ARGS__)) +#define PAIR_4(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_5(N, __VA_ARGS__)) +#define PAIR_3(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_4(N, __VA_ARGS__)) +#define PAIR_2(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_3(N, __VA_ARGS__)) +#define PAIR_1(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_2(N, __VA_ARGS__)) +#define PAIR(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_1(N, __VA_ARGS__)) #define ENUM(NAME, ...) \ enum class NAME : u32 { __VA_ARGS__ }; \ template <> \ - constexpr std::vector> Canonicalization::Get() { \ + constexpr std::vector> Canonicalization::Get() { \ return {PAIR(NAME, __VA_ARGS__)}; \ } @@ -77,12 +77,12 @@ enum class AudioEngine : u32 { }; template <> -constexpr std::vector> Canonicalization::Get() { +constexpr std::vector> Canonicalization::Get() { return { - {"auto", static_cast(AudioEngine::Auto)}, - {"cubeb", static_cast(AudioEngine::Cubeb)}, - {"sdl2", static_cast(AudioEngine::Sdl2)}, - {"null", static_cast(AudioEngine::Null)}, + {"auto", AudioEngine::Auto}, + {"cubeb", AudioEngine::Cubeb}, + {"sdl2", AudioEngine::Sdl2}, + {"null", AudioEngine::Null}, }; } @@ -132,7 +132,7 @@ template constexpr std::string CanonicalizeEnum(Type id) { const auto group = Canonicalization::Get(); for (auto& [name, value] : group) { - if (static_cast(value) == id) { + if (value == id) { return name; } } @@ -144,7 +144,7 @@ constexpr Type ToEnum(const std::string& canonicalization) { const auto group = Canonicalization::Get(); for (auto& [name, value] : group) { if (name == canonicalization) { - return static_cast(value); + return value; } } return {}; -- cgit v1.2.3 From 52cc7b438bbaccb440382d0fd38d2d0805907814 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:06:10 -0400 Subject: settings_common: Remove unncessary enum spec --- src/common/settings_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 6b717deb1..669d32204 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -80,8 +80,8 @@ public: */ class BasicSetting { protected: - explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, - bool save_, bool runtime_modifiable_, u32 specialization, + explicit BasicSetting(Linkage& linkage, const std::string& name, Category category_, bool save_, + bool runtime_modifiable_, u32 specialization, BasicSetting* other_setting); public: -- cgit v1.2.3 From e7f01128f181a7b754f6d5f94122cde059c7ed1a Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:41:06 -0400 Subject: settings: Give indices to enums --- src/common/settings_common.h | 5 +++++ src/common/settings_enums.h | 28 ++++++++++++++++++++++------ src/common/settings_setting.h | 9 +++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 669d32204..b355384a4 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -220,6 +220,11 @@ public: */ [[nodiscard]] virtual constexpr bool Ranged() const = 0; + /** + * @returns The index of the enum if the underlying setting type is an enum, else max of u32. + */ + [[nodiscard]] virtual constexpr u32 EnumIndex() const = 0; + /* * Switchable settings */ diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index a5f87c956..f9bb75840 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -11,8 +11,9 @@ namespace Settings { template -struct Canonicalization { - static constexpr std::vector> Get(); +struct EnumMetadata { + static constexpr std::vector> Canonicalizations(); + static constexpr u32 Index(); }; #define PAIR_45(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) @@ -65,10 +66,17 @@ struct Canonicalization { #define ENUM(NAME, ...) \ enum class NAME : u32 { __VA_ARGS__ }; \ template <> \ - constexpr std::vector> Canonicalization::Get() { \ + constexpr std::vector> EnumMetadata::Canonicalizations() { \ return {PAIR(NAME, __VA_ARGS__)}; \ + } \ + template <> \ + constexpr u32 EnumMetadata::Index() { \ + return __COUNTER__; \ } +// AudioEngine must be specified discretely due to having existing but slightly different +// canonicalizations +// TODO (lat9nq): Remove explicit definition of AudioEngine/sink_id enum class AudioEngine : u32 { Auto, Cubeb, @@ -77,7 +85,8 @@ enum class AudioEngine : u32 { }; template <> -constexpr std::vector> Canonicalization::Get() { +constexpr std::vector> +EnumMetadata::Canonicalizations() { return { {"auto", AudioEngine::Auto}, {"cubeb", AudioEngine::Cubeb}, @@ -86,6 +95,13 @@ constexpr std::vector> Canonicalization +constexpr u32 EnumMetadata::Index() { + // This is just a sufficiently large number that is more than the number of other enums declared + // here + return 100; +} + ENUM(AudioMode, Mono, Stereo, Surround); ENUM(Language, Japanese, EnglishAmerican, French, German, Italian, Spanish, Chinese, Korean, Dutch, @@ -130,7 +146,7 @@ ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); template constexpr std::string CanonicalizeEnum(Type id) { - const auto group = Canonicalization::Get(); + const auto group = EnumMetadata::Canonicalizations(); for (auto& [name, value] : group) { if (value == id) { return name; @@ -141,7 +157,7 @@ constexpr std::string CanonicalizeEnum(Type id) { template constexpr Type ToEnum(const std::string& canonicalization) { - const auto group = Canonicalization::Get(); + const auto group = EnumMetadata::Canonicalizations(); for (auto& [name, value] : group) { if (name == canonicalization) { return value; diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index eb46b2b6d..2e708fa0d 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -197,6 +198,14 @@ public: return std::type_index(typeid(Type)); } + constexpr u32 EnumIndex() const override { + if constexpr (std::is_enum()) { + return EnumMetadata::Index(); + } else { + return std::numeric_limits::max(); + } + } + virtual std::string MinVal() const override { return this->ToString(minimum); } -- cgit v1.2.3 From ff6a5031d5ea509375a5dc1ee7b9eeddda6d9ebc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:48:48 -0400 Subject: settings: Require time zone setting value for stirng --- src/common/settings.cpp | 4 ++-- src/common/settings.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index d9948dde8..78fa99113 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -66,8 +66,8 @@ SWITCHABLE(u8, true); Values values; -std::string GetTimeZoneString() { - const auto time_zone_index = static_cast(values.time_zone_index.GetValue()); +std::string GetTimeZoneString(TimeZone time_zone) { + const auto time_zone_index = static_cast(time_zone); ASSERT(time_zone_index < Common::TimeZone::GetTimeZoneStrings().size()); std::string location_name; diff --git a/src/common/settings.h b/src/common/settings.h index c4339cb1f..928636c72 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -516,7 +516,7 @@ bool IsFastmemEnabled(); float Volume(); -std::string GetTimeZoneString(); +std::string GetTimeZoneString(TimeZone time_zone); void LogSettings(); -- cgit v1.2.3 From 127b3da0f13ea0850c10115d45488dfe32a0a3f4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 17 Jul 2023 19:59:22 -0400 Subject: core,common: Give memory layout setting an enum Allows for 6GB and 8GB layouts to be selected. --- src/common/settings.h | 8 ++++++-- src/common/settings_enums.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 928636c72..618c34334 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -153,8 +153,12 @@ struct Values { // Core SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; - SwitchableSetting use_unsafe_extended_memory_layout{ - linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; + SwitchableSetting memory_layout_mode{linkage, + MemoryLayout::Memory_4Gb, + MemoryLayout::Memory_4Gb, + MemoryLayout::Memory_8Gb, + "memory_layout_mode", + Category::Core}; SwitchableSetting use_speed_limit{ linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, false, true}; SwitchableSetting speed_limit{linkage, diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f9bb75840..a1a29ebf6 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -131,6 +131,8 @@ ENUM(GpuAccuracy, Normal, High, Extreme); ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid); +ENUM(MemoryLayout, Memory_4Gb, Memory_6Gb, Memory_8Gb); + ENUM(FullscreenMode, Borderless, Exclusive); ENUM(NvdecEmulation, Off, Cpu, Gpu); -- cgit v1.2.3 From 267f3c7905972ad78713cd92f96e3073ea1c8996 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:36:20 -0400 Subject: settings: Cleanup Addresses review feedback Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> --- src/common/CMakeLists.txt | 1 + src/common/settings.cpp | 5 +-- src/common/settings_setting.h | 77 ++++++++++++++++++++++++++----------------- 3 files changed, 51 insertions(+), 32 deletions(-) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index e205055e6..bf97d9ba2 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -205,6 +205,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") -Werror=unreachable-code-aggressive ) target_compile_definitions(common PRIVATE + # Clang 14 and earlier have errors when explicitly instantiating Settings::Setting $<$,15>:CANNOT_EXPLICITLY_INSTANTIATE> ) endif() diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 78fa99113..59d24a053 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -25,6 +25,7 @@ namespace Settings { +// Clang 14 and earlier have errors when explicitly instantiating these classes #ifndef CANNOT_EXPLICITLY_INSTANTIATE #define SETTING(TYPE, RANGED) template class Setting #define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting @@ -113,11 +114,11 @@ void LogSettings() { for (const auto& setting : settings) { if (setting->Id() == values.yuzu_token.Id()) { - // Hide the token secret, which could be used to share patreon builds + // Hide the token secret, for security reasons. continue; } - std::string name = fmt::format( + const auto name = fmt::format( "{:c}{:c} {}.{}", setting->ToString() == setting->DefaultToString() ? '-' : 'M', setting->UsingGlobal() ? '-' : 'C', TranslateCategory(category), setting->GetLabel()); diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 2e708fa0d..959b4f3f9 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -34,6 +34,10 @@ public: * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group + * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param save_ Suggests that this should or should not be saved to a frontend config file + * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded + * @param other_setting_ A second Setting to associate to this one in metadata */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, enum Category category_, u32 specialization_ = Specialization::Default, @@ -54,6 +58,10 @@ public: * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group + * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param save_ Suggests that this should or should not be saved to a frontend config file + * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded + * @param other_setting_ A second Setting to associate to this one in metadata */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, enum Category category_, @@ -93,18 +101,19 @@ public: } [[nodiscard]] constexpr bool IsEnum() const override { - return std::is_enum::value; + return std::is_enum_v; } protected: - std::string ToString(const Type& value_) const { - if constexpr (std::is_same()) { + [[nodiscard]] std::string ToString(const Type& value_) const { + if constexpr (std::is_same_v) { return value_; - } else if constexpr (std::is_same>()) { + } else if constexpr (std::is_same_v>) { return value_.has_value() ? std::to_string(*value_) : "none"; - } else if constexpr (std::is_same()) { + } else if constexpr (std::is_same_v) { return value_ ? "true" : "false"; - } else if constexpr (std::is_same()) { + } else if constexpr (std::is_same_v) { + // Compatibility with old AudioEngine setting being a string return CanonicalizeEnum(value_); } else { return std::to_string(static_cast(value_)); @@ -118,7 +127,7 @@ public: * * @returns The current setting as a std::string */ - std::string ToString() const override { + [[nodiscard]] std::string ToString() const override { return ToString(this->GetValue()); } @@ -127,7 +136,7 @@ public: * * @returns The default value as a string. */ - std::string DefaultToString() const override { + [[nodiscard]] std::string DefaultToString() const override { return ToString(default_value); } @@ -159,19 +168,19 @@ public: * * @param input The desired value */ - void LoadString(const std::string& input) override { + void LoadString(const std::string& input) override final { if (input.empty()) { this->SetValue(this->GetDefault()); return; } try { - if constexpr (std::is_same()) { + if constexpr (std::is_same_v) { this->SetValue(input); - } else if constexpr (std::is_same>()) { + } else if constexpr (std::is_same_v>) { this->SetValue(static_cast(std::stoul(input))); - } else if constexpr (std::is_same()) { + } else if constexpr (std::is_same_v) { this->SetValue(input == "true"); - } else if constexpr (std::is_same()) { + } else if constexpr (std::is_same_v) { this->SetValue(ToEnum(input)); } else { this->SetValue(static_cast(std::stoll(input))); @@ -181,8 +190,8 @@ public: } } - [[nodiscard]] std::string constexpr Canonicalize() const override { - if constexpr (std::is_enum::value) { + [[nodiscard]] std::string constexpr Canonicalize() const override final { + if constexpr (std::is_enum_v) { return CanonicalizeEnum(this->GetValue()); } else { return ToString(this->GetValue()); @@ -194,26 +203,26 @@ public: * * @returns the type_index of the setting's type */ - virtual std::type_index TypeId() const override { + [[nodiscard]] std::type_index TypeId() const override final { return std::type_index(typeid(Type)); } - constexpr u32 EnumIndex() const override { - if constexpr (std::is_enum()) { + [[nodiscard]] constexpr u32 EnumIndex() const override final { + if constexpr (std::is_enum_v) { return EnumMetadata::Index(); } else { return std::numeric_limits::max(); } } - virtual std::string MinVal() const override { + [[nodiscard]] std::string MinVal() const override final { return this->ToString(minimum); } - virtual std::string MaxVal() const override { + [[nodiscard]] std::string MaxVal() const override final { return this->ToString(maximum); } - constexpr bool Ranged() const override { + [[nodiscard]] constexpr bool Ranged() const override { return ranged; } @@ -242,6 +251,10 @@ public: * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group + * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param save_ Suggests that this should or should not be saved to a frontend config file + * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded + * @param other_setting_ A second Setting to associate to this one in metadata */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, Category category_, u32 specialization_ = Specialization::Default, @@ -264,6 +277,10 @@ public: * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group + * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param save_ Suggests that this should or should not be saved to a frontend config file + * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded + * @param other_setting_ A second Setting to associate to this one in metadata */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name, Category category_, @@ -284,7 +301,7 @@ public: * * @param to_global Whether to use the global or custom setting. */ - void SetGlobal(bool to_global) override { + void SetGlobal(bool to_global) override final { use_global = to_global; } @@ -293,7 +310,7 @@ public: * * @returns The global state */ - [[nodiscard]] bool UsingGlobal() const override { + [[nodiscard]] bool UsingGlobal() const override final { return use_global; } @@ -305,13 +322,13 @@ public: * * @returns The required value of the setting */ - [[nodiscard]] virtual const Type& GetValue() const override { + [[nodiscard]] const Type& GetValue() const override final { if (use_global) { return this->value; } return custom; } - [[nodiscard]] virtual const Type& GetValue(bool need_global) const { + [[nodiscard]] const Type& GetValue(bool need_global) const { if (use_global || need_global) { return this->value; } @@ -323,7 +340,7 @@ public: * * @param val The new value */ - void SetValue(const Type& val) override { + void SetValue(const Type& val) override final { Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; if (use_global) { std::swap(this->value, temp); @@ -332,11 +349,11 @@ public: } } - [[nodiscard]] virtual constexpr bool Switchable() const override { + [[nodiscard]] constexpr bool Switchable() const override final { return true; } - [[nodiscard]] virtual std::string ToStringGlobal() const override { + [[nodiscard]] std::string ToStringGlobal() const override final { return this->ToString(this->value); } @@ -347,7 +364,7 @@ public: * * @returns A reference to the current setting value */ - const Type& operator=(const Type& val) override { + const Type& operator=(const Type& val) override final { Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; if (use_global) { std::swap(this->value, temp); @@ -362,7 +379,7 @@ public: * * @returns A reference to the current setting value */ - virtual explicit operator const Type&() const override { + explicit operator const Type&() const override final { if (use_global) { return this->value; } -- cgit v1.2.3 From 1e093767a85ee0fdce6f1619e967a6560963dcf3 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:42:59 -0400 Subject: common,configure_system: Rename method to GetCategory Fixes essentially a shadowing issue. --- src/common/settings_common.cpp | 2 +- src/common/settings_common.h | 8 ++++---- src/common/settings_setting.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 799942980..8b666f8b2 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -36,7 +36,7 @@ bool BasicSetting::RuntimeModfiable() const { return runtime_modifiable; } -Category BasicSetting::Category() const { +Category BasicSetting::GetCategory() const { return category; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index b355384a4..ca218e37b 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -196,7 +196,7 @@ public: * * @returns The setting's category */ - [[nodiscard]] enum Category Category() const; + [[nodiscard]] Category GetCategory() const; /** * @returns Extra metadata for data representation in frontend implementations. @@ -246,9 +246,9 @@ public: [[nodiscard]] virtual bool UsingGlobal() const; private: - const std::string label; ///< The setting's label - const enum Category category; ///< The setting's category AKA INI group - const u32 id; ///< Unique integer for the setting + const std::string label; ///< The setting's label + const Category category; ///< The setting's category AKA INI group + const u32 id; ///< Unique integer for the setting const bool save; ///< Suggests if the setting should be saved and read to a frontend config const bool runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 959b4f3f9..55280fec4 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -40,7 +40,7 @@ public: * @param other_setting_ A second Setting to associate to this one in metadata */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_, u32 specialization_ = Specialization::Default, + Category category_, u32 specialization_ = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, BasicSetting* other_setting_ = nullptr) requires(!ranged) @@ -64,7 +64,7 @@ public: * @param other_setting_ A second Setting to associate to this one in metadata */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, enum Category category_, + const Type& max_val, const std::string& name, Category category_, u32 specialization_ = Specialization::Default, bool save_ = true, bool runtime_modifiable_ = false, BasicSetting* other_setting_ = nullptr) requires(ranged) -- cgit v1.2.3 From b02e7eea78cf5d5f3631b11a58f28d0888948fc0 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:44:27 -0400 Subject: settings_setting: Fix typo --- src/common/settings_setting.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 55280fec4..a8beb06e9 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -34,7 +34,7 @@ public: * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group - * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param specialization_ Suggestion for how frontend implementations represent this in a config * @param save_ Suggests that this should or should not be saved to a frontend config file * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded * @param other_setting_ A second Setting to associate to this one in metadata @@ -58,7 +58,7 @@ public: * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group - * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param specialization_ Suggestion for how frontend implementations represent this in a config * @param save_ Suggests that this should or should not be saved to a frontend config file * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded * @param other_setting_ A second Setting to associate to this one in metadata @@ -251,7 +251,7 @@ public: * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group - * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param specialization_ Suggestion for how frontend implementations represent this in a config * @param save_ Suggests that this should or should not be saved to a frontend config file * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded * @param other_setting_ A second Setting to associate to this one in metadata @@ -277,7 +277,7 @@ public: * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting * @param category_ Category of the setting AKA INI group - * @param specialization_ Suggestion for how frontend implemetations represent this in a config + * @param specialization_ Suggestion for how frontend implementations represent this in a config * @param save_ Suggests that this should or should not be saved to a frontend config file * @param runtime_modifiable_ Suggests whether this is modifiable while a guest is loaded * @param other_setting_ A second Setting to associate to this one in metadata -- cgit v1.2.3 From 32116231924bfc1ad356fc0f39df327a393b8df1 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:49:36 -0400 Subject: common: Move global configuration state modifiers back to settings --- src/common/settings.cpp | 10 ++++++++++ src/common/settings.h | 3 +++ src/common/settings_common.cpp | 10 ---------- src/common/settings_common.h | 3 --- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 59d24a053..4c1cd1cac 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -287,4 +287,14 @@ void RestoreGlobalState(bool is_powered_on) { } } +static bool configuring_global = true; + +bool IsConfiguringGlobal() { + return configuring_global; +} + +void SetConfiguringGlobal(bool is_global) { + configuring_global = is_global; +} + } // namespace Settings diff --git a/src/common/settings.h b/src/common/settings.h index 618c34334..655f6468a 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -529,4 +529,7 @@ void UpdateRescalingInfo(); // Restore the global state of all applicable settings in the Values struct void RestoreGlobalState(bool is_powered_on); +bool IsConfiguringGlobal(); +void SetConfiguringGlobal(bool is_global); + } // namespace Settings diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 8b666f8b2..1439fb451 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -52,14 +52,4 @@ const std::string& BasicSetting::GetLabel() const { return label; } -static bool configuring_global = true; - -bool IsConfiguringGlobal() { - return configuring_global; -} - -void SetConfiguringGlobal(bool is_global) { - configuring_global = is_global; -} - } // namespace Settings diff --git a/src/common/settings_common.h b/src/common/settings_common.h index ca218e37b..a7630a97f 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -60,9 +60,6 @@ enum Specialization : u8 { Percentage = (1 << SpecializationAttributeOffset), }; -bool IsConfiguringGlobal(); -void SetConfiguringGlobal(bool is_global); - class BasicSetting; class Linkage { -- cgit v1.2.3 From ffb384463f1f12264dbd8ad8827a8b42115921aa Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 19 Jul 2023 13:45:50 -0400 Subject: settings: Remove sorting from log Unecessary, and would run every time the settings are logged. --- src/common/settings.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 4c1cd1cac..0e2ccf857 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -108,10 +108,6 @@ void LogSettings() { LOG_INFO(Config, "yuzu Configuration:"); for (auto& [category, settings] : values.linkage.by_category) { - settings.sort([](const BasicSetting* a, const BasicSetting* b) { - return a->GetLabel() < b->GetLabel(); - }); - for (const auto& setting : settings) { if (setting->Id() == values.yuzu_token.Id()) { // Hide the token secret, for security reasons. -- cgit v1.2.3 From 2911988b852ec29016780aabb1f46e2d0c231744 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 19 Jul 2023 13:46:48 -0400 Subject: settings_common: Use a vector in category linkage Improve storage requirements. --- src/common/settings_common.cpp | 2 +- src/common/settings_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 1439fb451..90842e797 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -12,7 +12,7 @@ BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Categ : label{name}, category{category_}, id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_}, specialization{specialization_}, other_setting{other_setting_} { - linkage.by_category[category].push_front(this); + linkage.by_category[category].push_back(this); linkage.count++; } diff --git a/src/common/settings_common.h b/src/common/settings_common.h index a7630a97f..bfd1bad64 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -66,7 +66,7 @@ class Linkage { public: explicit Linkage(u32 initial_count = 0); ~Linkage(); - std::map> by_category{}; + std::map> by_category{}; std::vector> restore_functions{}; u32 count; }; -- cgit v1.2.3 From 17b9c1e1715a16bebcdd92c02ce7f7e503212462 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:09:09 -0400 Subject: common,qt-config: Remove usage of forward_list --- src/common/settings.cpp | 1 - src/common/settings_common.h | 1 - 2 files changed, 2 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 0e2ccf857..4a4ba307c 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/src/common/settings_common.h b/src/common/settings_common.h index bfd1bad64..6f90ae90d 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -3,7 +3,6 @@ #pragma once -#include #include #include #include -- cgit v1.2.3 From f84e7b4656f1e69cced4e58117df920efaec922e Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 23 Jul 2023 16:21:08 -0400 Subject: settings_common: Document specializations --- src/common/settings_common.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/common') diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 6f90ae90d..2efb329b0 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -46,17 +46,18 @@ constexpr u8 SpecializationTypeMask = 0xf; constexpr u8 SpecializationAttributeMask = 0xf0; constexpr u8 SpecializationAttributeOffset = 4; +// Scalar and countable could have better names enum Specialization : u8 { Default = 0, - Time = 1, - Hex = 2, - List = 3, - RuntimeList = 4, - Scalar = 5, - Countable = 6, - Paired = 7, - - Percentage = (1 << SpecializationAttributeOffset), + Time = 1, // Duration or specific moment in time + Hex = 2, // Hexadecimal number + List = 3, // Setting has specific members + RuntimeList = 4, // Members of the list are determined during runtime + Scalar = 5, // Values are continuous + Countable = 6, // Can be stepped through + Paired = 7, // Another setting is associated with this setting + + Percentage = (1 << SpecializationAttributeOffset), // Should be represented as a percentage }; class BasicSetting; -- cgit v1.2.3 From b1716a9e147f744dfe4bd977f4a5af12f3a2ec0f Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:28:13 -0400 Subject: settings: Set GPU as default ASTC decoder --- src/common/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 655f6468a..43ebeae9e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -226,7 +226,7 @@ struct Values { SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; SwitchableSetting accelerate_astc{linkage, - AstcDecodeMode::Cpu, + AstcDecodeMode::Gpu, AstcDecodeMode::Cpu, AstcDecodeMode::CpuAsynchronous, "accelerate_astc", -- cgit v1.2.3 From 397333b2d51fc93c1285465f43668fb86e709fc3 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 Jul 2023 15:57:55 -0400 Subject: settings: Correct Linkage member impl location --- src/common/settings.cpp | 3 --- src/common/settings_common.cpp | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 4a4ba307c..491adc30e 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -151,9 +151,6 @@ float Volume() { return values.volume.GetValue() / static_cast(values.volume.GetDefault()); } -Linkage::Linkage(u32 initial_count) : count{initial_count} {} -Linkage::~Linkage() = default; - const char* TranslateCategory(Category category) { switch (category) { case Category::Audio: diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 90842e797..dedf5ef90 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp @@ -52,4 +52,7 @@ const std::string& BasicSetting::GetLabel() const { return label; } +Linkage::Linkage(u32 initial_count) : count{initial_count} {} +Linkage::~Linkage() = default; + } // namespace Settings -- cgit v1.2.3 From 1bc0b673aa2fc0510d332286e49f6c8d44568065 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 Jul 2023 22:31:21 -0400 Subject: backend: Remove usage of explicit operator overload Causes a crash on MSVC from a race condition on application quit. Intended to address yuzu-emu/yuzu/issues/11137 --- src/common/logging/backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 6e8e8eb36..d4f27197c 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -108,7 +108,7 @@ public: using namespace Common::Literals; // Prevent logs from exceeding a set maximum size in the event that log entries are spammed. - const auto write_limit = Settings::values.extended_logging ? 1_GiB : 100_MiB; + const auto write_limit = Settings::values.extended_logging.GetValue() ? 1_GiB : 100_MiB; const bool write_limit_exceeded = bytes_written > write_limit; if (entry.log_level >= Level::Error || write_limit_exceeded) { if (write_limit_exceeded) { -- cgit v1.2.3 From 195403c87cf17e91c686fc98c27429d23974af73 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 25 Jul 2023 23:13:54 -0400 Subject: (ui)settings: Add more runtime_modifiable settings --- src/common/settings.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 43ebeae9e..b0bc6519a 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -134,9 +134,10 @@ struct Values { Specialization::RuntimeList}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio, Specialization::RuntimeList}; - SwitchableSetting sound_index{linkage, AudioMode::Stereo, - AudioMode::Mono, AudioMode::Surround, - "sound_index", Category::SystemAudio}; + SwitchableSetting sound_index{ + linkage, AudioMode::Stereo, AudioMode::Mono, AudioMode::Surround, + "sound_index", Category::SystemAudio, Specialization::Default, true, + true}; SwitchableSetting volume{linkage, 100, 0, @@ -147,7 +148,7 @@ struct Values { true, true}; Setting audio_muted{ - linkage, false, "audio_muted", Category::Audio, Specialization::Default, false}; + linkage, false, "audio_muted", Category::Audio, Specialization::Default, false, true}; Setting dump_audio_commands{ linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; -- cgit v1.2.3