diff options
| author | 2021-07-18 20:33:20 +0200 | |
|---|---|---|
| committer | 2021-11-16 22:11:27 +0100 | |
| commit | 37ef9c913028e234509bcf70bad049b0210e4592 (patch) | |
| tree | 4502ff26068fcbef55b36679c7afdc546182bf36 /src/common | |
| parent | VideoCore: Initial Setup for the Resolution Scaler. (diff) | |
| download | yuzu-37ef9c913028e234509bcf70bad049b0210e4592.tar.gz yuzu-37ef9c913028e234509bcf70bad049b0210e4592.tar.xz yuzu-37ef9c913028e234509bcf70bad049b0210e4592.zip | |
Settings: Add resolution scaling to settings.
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/settings.cpp | 51 | ||||
| -rw-r--r-- | src/common/settings.h | 13 |
2 files changed, 60 insertions, 4 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 8c6be2c84..dd3a3d456 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -106,6 +106,57 @@ float Volume() { | |||
| 106 | return values.volume.GetValue() / 100.0f; | 106 | return values.volume.GetValue() / 100.0f; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | void UpdateRescalingInfo() { | ||
| 110 | auto setup = values.resolution_setup.GetValue(); | ||
| 111 | auto& info = values.resolution_info; | ||
| 112 | switch (setup) { | ||
| 113 | case ResolutionSetup::Res1_2X: { | ||
| 114 | info.up_scale = 1; | ||
| 115 | info.down_shift = 1; | ||
| 116 | break; | ||
| 117 | } | ||
| 118 | case ResolutionSetup::Res3_4X: { | ||
| 119 | info.up_scale = 3; | ||
| 120 | info.down_shift = 2; | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | case ResolutionSetup::Res1X: { | ||
| 124 | info.up_scale = 1; | ||
| 125 | info.down_shift = 0; | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | case ResolutionSetup::Res3_2X: { | ||
| 129 | info.up_scale = 3; | ||
| 130 | info.down_shift = 1; | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | case ResolutionSetup::Res2X: { | ||
| 134 | info.up_scale = 2; | ||
| 135 | info.down_shift = 0; | ||
| 136 | break; | ||
| 137 | } | ||
| 138 | case ResolutionSetup::Res3X: { | ||
| 139 | info.up_scale = 3; | ||
| 140 | info.down_shift = 0; | ||
| 141 | break; | ||
| 142 | } | ||
| 143 | case ResolutionSetup::Res4X: { | ||
| 144 | info.up_scale = 4; | ||
| 145 | info.down_shift = 0; | ||
| 146 | break; | ||
| 147 | } | ||
| 148 | default: { | ||
| 149 | UNREACHABLE(); | ||
| 150 | info.up_scale = 1; | ||
| 151 | info.down_shift = 0; | ||
| 152 | } | ||
| 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.size_up = info.up_scale * info.up_scale; | ||
| 157 | info.size_shift = info.down_shift * 2; | ||
| 158 | } | ||
| 159 | |||
| 109 | void RestoreGlobalState(bool is_powered_on) { | 160 | void RestoreGlobalState(bool is_powered_on) { |
| 110 | // If a game is running, DO NOT restore the global settings state | 161 | // If a game is running, DO NOT restore the global settings state |
| 111 | if (is_powered_on) { | 162 | if (is_powered_on) { |
diff --git a/src/common/settings.h b/src/common/settings.h index 08f3da055..f4df2fc95 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -56,16 +56,19 @@ enum class ResolutionSetup : u32 { | |||
| 56 | Res1_2X = 0, | 56 | Res1_2X = 0, |
| 57 | Res3_4X = 1, | 57 | Res3_4X = 1, |
| 58 | Res1X = 2, | 58 | Res1X = 2, |
| 59 | Res3_2K = 3, | 59 | Res3_2X = 3, |
| 60 | Res2X = 4, | 60 | Res2X = 4, |
| 61 | Res3X = 5, | 61 | Res3X = 5, |
| 62 | Res4X = 6, | ||
| 62 | }; | 63 | }; |
| 63 | 64 | ||
| 64 | struct ResolutionScalingInfo { | 65 | struct ResolutionScalingInfo { |
| 65 | u32 up_scale{2}; | 66 | u32 up_scale{1}; |
| 66 | u32 down_shift{0}; | 67 | u32 down_shift{0}; |
| 67 | f32 up_factor{2.0f}; | 68 | f32 up_factor{1.0f}; |
| 68 | f32 down_factor{0.5f}; | 69 | f32 down_factor{1.0f}; |
| 70 | u32 size_up{1}; | ||
| 71 | u32 size_shift{0}; | ||
| 69 | }; | 72 | }; |
| 70 | 73 | ||
| 71 | /** The BasicSetting class is a simple resource manager. It defines a label and default value | 74 | /** The BasicSetting class is a simple resource manager. It defines a label and default value |
| @@ -613,6 +616,8 @@ std::string GetTimeZoneString(); | |||
| 613 | 616 | ||
| 614 | void LogSettings(); | 617 | void LogSettings(); |
| 615 | 618 | ||
| 619 | void UpdateRescalingInfo(); | ||
| 620 | |||
| 616 | // Restore the global state of all applicable settings in the Values struct | 621 | // Restore the global state of all applicable settings in the Values struct |
| 617 | void RestoreGlobalState(bool is_powered_on); | 622 | void RestoreGlobalState(bool is_powered_on); |
| 618 | 623 | ||