diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/math_util.h | 4 | ||||
| -rw-r--r-- | src/common/settings.cpp | 53 | ||||
| -rw-r--r-- | src/common/settings.h | 59 |
3 files changed, 111 insertions, 5 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h index 4c38d8040..510c4e56d 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h | |||
| @@ -48,8 +48,8 @@ struct Rectangle { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | [[nodiscard]] Rectangle<T> Scale(const float s) const { | 50 | [[nodiscard]] Rectangle<T> Scale(const float s) const { |
| 51 | return Rectangle{left, top, static_cast<T>(left + GetWidth() * s), | 51 | return Rectangle{left, top, static_cast<T>(static_cast<float>(left + GetWidth()) * s), |
| 52 | static_cast<T>(top + GetHeight() * s)}; | 52 | static_cast<T>(static_cast<float>(top + GetHeight()) * s)}; |
| 53 | } | 53 | } |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 9dd5e3efb..3bcaa072f 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -47,7 +47,9 @@ void LogSettings() { | |||
| 47 | log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); | 47 | log_setting("System_TimeZoneIndex", values.time_zone_index.GetValue()); |
| 48 | log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); | 48 | log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); |
| 49 | log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); | 49 | log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); |
| 50 | log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); | 50 | log_setting("Renderer_UseResolutionScaling", values.resolution_setup.GetValue()); |
| 51 | log_setting("Renderer_ScalingFilter", values.scaling_filter.GetValue()); | ||
| 52 | log_setting("Renderer_AntiAliasing", values.anti_aliasing.GetValue()); | ||
| 51 | log_setting("Renderer_UseSpeedLimit", values.use_speed_limit.GetValue()); | 53 | log_setting("Renderer_UseSpeedLimit", values.use_speed_limit.GetValue()); |
| 52 | log_setting("Renderer_SpeedLimit", values.speed_limit.GetValue()); | 54 | log_setting("Renderer_SpeedLimit", values.speed_limit.GetValue()); |
| 53 | log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); | 55 | log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); |
| @@ -105,6 +107,55 @@ float Volume() { | |||
| 105 | return values.volume.GetValue() / 100.0f; | 107 | return values.volume.GetValue() / 100.0f; |
| 106 | } | 108 | } |
| 107 | 109 | ||
| 110 | void UpdateRescalingInfo() { | ||
| 111 | const auto setup = values.resolution_setup.GetValue(); | ||
| 112 | auto& info = values.resolution_info; | ||
| 113 | info.downscale = false; | ||
| 114 | switch (setup) { | ||
| 115 | case ResolutionSetup::Res1_2X: | ||
| 116 | info.up_scale = 1; | ||
| 117 | info.down_shift = 1; | ||
| 118 | info.downscale = true; | ||
| 119 | break; | ||
| 120 | case ResolutionSetup::Res3_4X: | ||
| 121 | info.up_scale = 3; | ||
| 122 | info.down_shift = 2; | ||
| 123 | info.downscale = true; | ||
| 124 | break; | ||
| 125 | case ResolutionSetup::Res1X: | ||
| 126 | info.up_scale = 1; | ||
| 127 | info.down_shift = 0; | ||
| 128 | break; | ||
| 129 | case ResolutionSetup::Res2X: | ||
| 130 | info.up_scale = 2; | ||
| 131 | info.down_shift = 0; | ||
| 132 | break; | ||
| 133 | case ResolutionSetup::Res3X: | ||
| 134 | info.up_scale = 3; | ||
| 135 | info.down_shift = 0; | ||
| 136 | break; | ||
| 137 | case ResolutionSetup::Res4X: | ||
| 138 | info.up_scale = 4; | ||
| 139 | info.down_shift = 0; | ||
| 140 | break; | ||
| 141 | case ResolutionSetup::Res5X: | ||
| 142 | info.up_scale = 5; | ||
| 143 | info.down_shift = 0; | ||
| 144 | break; | ||
| 145 | case ResolutionSetup::Res6X: | ||
| 146 | info.up_scale = 6; | ||
| 147 | info.down_shift = 0; | ||
| 148 | break; | ||
| 149 | default: | ||
| 150 | UNREACHABLE(); | ||
| 151 | info.up_scale = 1; | ||
| 152 | info.down_shift = 0; | ||
| 153 | } | ||
| 154 | info.up_factor = static_cast<f32>(info.up_scale) / (1U << info.down_shift); | ||
| 155 | info.down_factor = static_cast<f32>(1U << info.down_shift) / info.up_scale; | ||
| 156 | info.active = info.up_scale != 1 || info.down_shift != 0; | ||
| 157 | } | ||
| 158 | |||
| 108 | void RestoreGlobalState(bool is_powered_on) { | 159 | void RestoreGlobalState(bool is_powered_on) { |
| 109 | // If a game is running, DO NOT restore the global settings state | 160 | // If a game is running, DO NOT restore the global settings state |
| 110 | if (is_powered_on) { | 161 | if (is_powered_on) { |
diff --git a/src/common/settings.h b/src/common/settings.h index 9ff4cf85d..42f8b4a7d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -52,6 +52,56 @@ enum class NvdecEmulation : u32 { | |||
| 52 | GPU = 2, | 52 | GPU = 2, |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | enum class ResolutionSetup : u32 { | ||
| 56 | Res1_2X = 0, | ||
| 57 | Res3_4X = 1, | ||
| 58 | Res1X = 2, | ||
| 59 | Res2X = 3, | ||
| 60 | Res3X = 4, | ||
| 61 | Res4X = 5, | ||
| 62 | Res5X = 6, | ||
| 63 | Res6X = 7, | ||
| 64 | }; | ||
| 65 | |||
| 66 | enum class ScalingFilter : u32 { | ||
| 67 | NearestNeighbor = 0, | ||
| 68 | Bilinear = 1, | ||
| 69 | Bicubic = 2, | ||
| 70 | Gaussian = 3, | ||
| 71 | ScaleForce = 4, | ||
| 72 | Fsr = 5, | ||
| 73 | LastFilter = Fsr, | ||
| 74 | }; | ||
| 75 | |||
| 76 | enum class AntiAliasing : u32 { | ||
| 77 | None = 0, | ||
| 78 | Fxaa = 1, | ||
| 79 | LastAA = Fxaa, | ||
| 80 | }; | ||
| 81 | |||
| 82 | struct ResolutionScalingInfo { | ||
| 83 | u32 up_scale{1}; | ||
| 84 | u32 down_shift{0}; | ||
| 85 | f32 up_factor{1.0f}; | ||
| 86 | f32 down_factor{1.0f}; | ||
| 87 | bool active{}; | ||
| 88 | bool downscale{}; | ||
| 89 | |||
| 90 | s32 ScaleUp(s32 value) const { | ||
| 91 | if (value == 0) { | ||
| 92 | return 0; | ||
| 93 | } | ||
| 94 | return std::max((value * static_cast<s32>(up_scale)) >> static_cast<s32>(down_shift), 1); | ||
| 95 | } | ||
| 96 | |||
| 97 | u32 ScaleUp(u32 value) const { | ||
| 98 | if (value == 0U) { | ||
| 99 | return 0U; | ||
| 100 | } | ||
| 101 | return std::max((value * up_scale) >> down_shift, 1U); | ||
| 102 | } | ||
| 103 | }; | ||
| 104 | |||
| 55 | /** The BasicSetting class is a simple resource manager. It defines a label and default value | 105 | /** The BasicSetting class is a simple resource manager. It defines a label and default value |
| 56 | * alongside the actual value of the setting for simpler and less-error prone use with frontend | 106 | * alongside the actual value of the setting for simpler and less-error prone use with frontend |
| 57 | * configurations. Setting a default value and label is required, though subclasses may deviate from | 107 | * configurations. Setting a default value and label is required, though subclasses may deviate from |
| @@ -451,7 +501,10 @@ struct Values { | |||
| 451 | "disable_shader_loop_safety_checks"}; | 501 | "disable_shader_loop_safety_checks"}; |
| 452 | Setting<int> vulkan_device{0, "vulkan_device"}; | 502 | Setting<int> vulkan_device{0, "vulkan_device"}; |
| 453 | 503 | ||
| 454 | Setting<u16> resolution_factor{1, "resolution_factor"}; | 504 | ResolutionScalingInfo resolution_info{}; |
| 505 | Setting<ResolutionSetup> resolution_setup{ResolutionSetup::Res1X, "resolution_setup"}; | ||
| 506 | Setting<ScalingFilter> scaling_filter{ScalingFilter::Bilinear, "scaling_filter"}; | ||
| 507 | Setting<AntiAliasing> anti_aliasing{AntiAliasing::None, "anti_aliasing"}; | ||
| 455 | // *nix platforms may have issues with the borderless windowed fullscreen mode. | 508 | // *nix platforms may have issues with the borderless windowed fullscreen mode. |
| 456 | // Default to exclusive fullscreen on these platforms for now. | 509 | // Default to exclusive fullscreen on these platforms for now. |
| 457 | RangedSetting<FullscreenMode> fullscreen_mode{ | 510 | RangedSetting<FullscreenMode> fullscreen_mode{ |
| @@ -462,7 +515,7 @@ struct Values { | |||
| 462 | #endif | 515 | #endif |
| 463 | FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; | 516 | FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; |
| 464 | RangedSetting<int> aspect_ratio{0, 0, 3, "aspect_ratio"}; | 517 | RangedSetting<int> aspect_ratio{0, 0, 3, "aspect_ratio"}; |
| 465 | RangedSetting<int> max_anisotropy{0, 0, 4, "max_anisotropy"}; | 518 | RangedSetting<int> max_anisotropy{0, 0, 5, "max_anisotropy"}; |
| 466 | Setting<bool> use_speed_limit{true, "use_speed_limit"}; | 519 | Setting<bool> use_speed_limit{true, "use_speed_limit"}; |
| 467 | RangedSetting<u16> speed_limit{100, 0, 9999, "speed_limit"}; | 520 | RangedSetting<u16> speed_limit{100, 0, 9999, "speed_limit"}; |
| 468 | Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; | 521 | Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; |
| @@ -595,6 +648,8 @@ std::string GetTimeZoneString(); | |||
| 595 | 648 | ||
| 596 | void LogSettings(); | 649 | void LogSettings(); |
| 597 | 650 | ||
| 651 | void UpdateRescalingInfo(); | ||
| 652 | |||
| 598 | // Restore the global state of all applicable settings in the Values struct | 653 | // Restore the global state of all applicable settings in the Values struct |
| 599 | void RestoreGlobalState(bool is_powered_on); | 654 | void RestoreGlobalState(bool is_powered_on); |
| 600 | 655 | ||