summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/settings.cpp6
-rw-r--r--src/common/settings.h40
-rw-r--r--src/common/settings_enums.h37
3 files changed, 45 insertions, 38 deletions
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) {
122} 122}
123 123
124bool IsGPULevelExtreme() { 124bool IsGPULevelExtreme() {
125 return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme; 125 return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme;
126} 126}
127 127
128bool IsGPULevelHigh() { 128bool IsGPULevelHigh() {
129 return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme || 129 return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme ||
130 values.gpu_accuracy.GetValue() == GPUAccuracy::High; 130 values.gpu_accuracy.GetValue() == GpuAccuracy::High;
131} 131}
132 132
133bool IsFastmemEnabled() { 133bool 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:
91 return {}; 91 return {};
92 } 92 }
93 virtual void LoadString(const std::string& load) = 0; 93 virtual void LoadString(const std::string& load) = 0;
94 virtual std::string Canonicalize() const = 0;
94 virtual const std::string& GetLabel() const = 0; 95 virtual const std::string& GetLabel() const = 0;
95 virtual std::string DefaultToString() const = 0; 96 virtual std::string DefaultToString() const = 0;
96 virtual bool Save() const = 0; 97 virtual bool Save() const = 0;
@@ -102,7 +103,7 @@ public:
102 virtual std::string MinVal() const = 0; 103 virtual std::string MinVal() const = 0;
103 virtual std::string MaxVal() const = 0; 104 virtual std::string MaxVal() const = 0;
104 virtual bool UsingGlobal() const { 105 virtual bool UsingGlobal() const {
105 return false; 106 return true;
106 } 107 }
107}; 108};
108 109
@@ -245,7 +246,7 @@ protected:
245 } else if constexpr (std::is_same<Type, bool>()) { 246 } else if constexpr (std::is_same<Type, bool>()) {
246 return value_ ? "true" : "false"; 247 return value_ ? "true" : "false";
247 } else if (std::is_same<Type, AudioEngine>()) { 248 } else if (std::is_same<Type, AudioEngine>()) {
248 return TranslateEnum(value_); 249 return CanonicalizeEnum(value_);
249 } else { 250 } else {
250 return std::to_string(static_cast<u64>(value_)); 251 return std::to_string(static_cast<u64>(value_));
251 } 252 }
@@ -321,6 +322,13 @@ public:
321 } 322 }
322 } 323 }
323 324
325 [[nodiscard]] std::string constexpr Canonicalize() const override {
326 if constexpr (std::is_enum<Type>::value) {
327 return CanonicalizeEnum(this->GetValue());
328 }
329 return ToString(this->GetValue());
330 }
331
324 /** 332 /**
325 * Returns the save preference of the setting i.e. when saving or reading the setting from a 333 * Returns the save preference of the setting i.e. when saving or reading the setting from a
326 * frontend, whether this setting should be skipped. 334 * frontend, whether this setting should be skipped.
@@ -560,8 +568,8 @@ struct Values {
560 linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; 568 linkage, false, "use_unsafe_extended_memory_layout", Category::Core};
561 569
562 // Cpu 570 // Cpu
563 SwitchableSetting<CPUAccuracy, true> cpu_accuracy{linkage, CPUAccuracy::Auto, 571 SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto,
564 CPUAccuracy::Auto, CPUAccuracy::Paranoid, 572 CpuAccuracy::Auto, CpuAccuracy::Paranoid,
565 "cpu_accuracy", Category::Cpu}; 573 "cpu_accuracy", Category::Cpu};
566 // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 574 // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021
567 Setting<bool> cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu}; 575 Setting<bool> cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu};
@@ -657,28 +665,28 @@ struct Values {
657 linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; 665 linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true};
658 SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache", 666 SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",
659 Category::Renderer}; 667 Category::Renderer};
660 SwitchableSetting<GPUAccuracy, true> gpu_accuracy{linkage, 668 SwitchableSetting<GpuAccuracy, true> gpu_accuracy{linkage,
661 GPUAccuracy::High, 669 GpuAccuracy::High,
662 GPUAccuracy::Normal, 670 GpuAccuracy::Normal,
663 GPUAccuracy::Extreme, 671 GpuAccuracy::Extreme,
664 "gpu_accuracy", 672 "gpu_accuracy",
665 Category::RendererAdvanced, 673 Category::RendererAdvanced,
666 true, 674 true,
667 true}; 675 true};
668 SwitchableSetting<bool> use_asynchronous_gpu_emulation{ 676 SwitchableSetting<bool> use_asynchronous_gpu_emulation{
669 linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; 677 linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer};
670 SwitchableSetting<NvdecEmulation> nvdec_emulation{linkage, NvdecEmulation::GPU, 678 SwitchableSetting<NvdecEmulation> nvdec_emulation{linkage, NvdecEmulation::Gpu,
671 "nvdec_emulation", Category::Renderer}; 679 "nvdec_emulation", Category::Renderer};
672 SwitchableSetting<AstcDecodeMode, true> accelerate_astc{linkage, 680 SwitchableSetting<AstcDecodeMode, true> accelerate_astc{linkage,
673 AstcDecodeMode::CPU, 681 AstcDecodeMode::Cpu,
674 AstcDecodeMode::CPU, 682 AstcDecodeMode::Cpu,
675 AstcDecodeMode::CPUAsynchronous, 683 AstcDecodeMode::CpuAsynchronous,
676 "accelerate_astc", 684 "accelerate_astc",
677 Category::Renderer}; 685 Category::Renderer};
678 Setting<VSyncMode, true> vsync_mode{linkage, 686 Setting<VSyncMode, true> vsync_mode{linkage,
679 VSyncMode::FIFO, 687 VSyncMode::Fifo,
680 VSyncMode::Immediate, 688 VSyncMode::Immediate,
681 VSyncMode::FIFORelaxed, 689 VSyncMode::FifoRelaxed,
682 "use_vsync", 690 "use_vsync",
683 Category::Renderer, 691 Category::Renderer,
684 true, 692 true,
@@ -686,7 +694,7 @@ struct Values {
686 SwitchableSetting<bool> use_reactive_flushing{linkage, true, "use_reactive_flushing", 694 SwitchableSetting<bool> use_reactive_flushing{linkage, true, "use_reactive_flushing",
687 Category::RendererAdvanced}; 695 Category::RendererAdvanced};
688 SwitchableSetting<ShaderBackend, true> shader_backend{ 696 SwitchableSetting<ShaderBackend, true> shader_backend{
689 linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, 697 linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV,
690 "shader_backend", Category::Renderer}; 698 "shader_backend", Category::Renderer};
691 SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", 699 SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
692 Category::RendererAdvanced}; 700 Category::RendererAdvanced};
@@ -730,7 +738,7 @@ struct Values {
730 Language::PortugueseBrazilian, 738 Language::PortugueseBrazilian,
731 "language_index", 739 "language_index",
732 Category::System}; 740 Category::System};
733 SwitchableSetting<Region, true> region_index{linkage, Region::USA, Region::Japan, 741 SwitchableSetting<Region, true> region_index{linkage, Region::Usa, Region::Japan,
734 Region::Taiwan, "region_index", Category::System}; 742 Region::Taiwan, "region_index", Category::System};
735 SwitchableSetting<TimeZone, true> time_zone_index{linkage, TimeZone::Auto, 743 SwitchableSetting<TimeZone, true> time_zone_index{linkage, TimeZone::Auto,
736 TimeZone::Auto, TimeZone::Zulu, 744 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 {
47 47
48enum class Region : u32 { 48enum class Region : u32 {
49 Japan, 49 Japan,
50 USA, 50 Usa,
51 Europe, 51 Europe,
52 Australia, 52 Australia,
53 China, 53 China,
@@ -114,9 +114,9 @@ enum class AnisotropyMode : u32 {
114}; 114};
115 115
116enum class AstcDecodeMode : u32 { 116enum class AstcDecodeMode : u32 {
117 CPU = 0, 117 Cpu = 0,
118 GPU = 1, 118 Gpu = 1,
119 CPUAsynchronous = 2, 119 CpuAsynchronous = 2,
120}; 120};
121 121
122enum class AstcRecompression : u32 { 122enum class AstcRecompression : u32 {
@@ -128,8 +128,8 @@ enum class AstcRecompression : u32 {
128enum class VSyncMode : u32 { 128enum class VSyncMode : u32 {
129 Immediate = 0, 129 Immediate = 0,
130 Mailbox = 1, 130 Mailbox = 1,
131 FIFO = 2, 131 Fifo = 2,
132 FIFORelaxed = 3, 132 FifoRelaxed = 3,
133}; 133};
134 134
135enum class RendererBackend : u32 { 135enum class RendererBackend : u32 {
@@ -139,19 +139,18 @@ enum class RendererBackend : u32 {
139}; 139};
140 140
141enum class ShaderBackend : u32 { 141enum class ShaderBackend : u32 {
142 GLSL = 0, 142 Glsl = 0,
143 GLASM = 1, 143 Glasm = 1,
144 SPIRV = 2, 144 SpirV = 2,
145}; 145};
146 146
147enum class GPUAccuracy : u32 { 147enum class GpuAccuracy : u32 {
148 Normal = 0, 148 Normal = 0,
149 High = 1, 149 High = 1,
150 Extreme = 2, 150 Extreme = 2,
151 MaxEnum = 3,
152}; 151};
153 152
154enum class CPUAccuracy : u32 { 153enum class CpuAccuracy : u32 {
155 Auto = 0, 154 Auto = 0,
156 Accurate = 1, 155 Accurate = 1,
157 Unsafe = 2, 156 Unsafe = 2,
@@ -165,8 +164,8 @@ enum class FullscreenMode : u32 {
165 164
166enum class NvdecEmulation : u32 { 165enum class NvdecEmulation : u32 {
167 Off = 0, 166 Off = 0,
168 CPU = 1, 167 Cpu = 1,
169 GPU = 2, 168 Gpu = 2,
170}; 169};
171 170
172enum class ResolutionSetup : u32 { 171enum class ResolutionSetup : u32 {
@@ -220,18 +219,18 @@ static std::map<std::type_index, std::map<std::string, u32>> translations = {
220static std::string empty_string{}; 219static std::string empty_string{};
221 220
222template <typename Type> 221template <typename Type>
223const std::string& TranslateEnum(Type id) { 222const std::string& CanonicalizeEnum(Type id) {
224 auto& group = translations.at(typeid(Type)); 223 auto& group = canonicalizations.at(typeid(Type));
225 for (auto& [name, value] : group) { 224 for (auto& [name, value] : group) {
226 if (static_cast<Type>(value) == id) { 225 if (static_cast<Type>(value) == id) {
227 return name; 226 return name;
228 } 227 }
229 } 228 }
230 return empty_string; 229 return invalid_string;
231} 230}
232 231
233template <typename Type> 232template <typename Type>
234static Type ToEnum(const std::string& text) { 233static Type ToEnum(const std::string& canonicalization) {
235 return static_cast<Type>(translations.at(typeid(Type)).at(text)); 234 return static_cast<Type>(canonicalizations.at(typeid(Type)).at(canonicalization));
236} 235}
237} // namespace Settings 236} // namespace Settings