diff options
| author | 2021-07-18 20:33:20 +0200 | |
|---|---|---|
| committer | 2021-11-16 22:11:27 +0100 | |
| commit | 37ef9c913028e234509bcf70bad049b0210e4592 (patch) | |
| tree | 4502ff26068fcbef55b36679c7afdc546182bf36 /src | |
| 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')
| -rw-r--r-- | src/common/settings.cpp | 51 | ||||
| -rw-r--r-- | src/common/settings.h | 13 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 26 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.ui | 64 |
6 files changed, 155 insertions, 5 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 | ||
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index faea5dda1..7ddc40b00 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -824,6 +824,7 @@ void Config::ReadRendererValues() { | |||
| 824 | ReadGlobalSetting(Settings::values.vulkan_device); | 824 | ReadGlobalSetting(Settings::values.vulkan_device); |
| 825 | ReadGlobalSetting(Settings::values.fullscreen_mode); | 825 | ReadGlobalSetting(Settings::values.fullscreen_mode); |
| 826 | ReadGlobalSetting(Settings::values.aspect_ratio); | 826 | ReadGlobalSetting(Settings::values.aspect_ratio); |
| 827 | ReadGlobalSetting(Settings::values.resolution_setup); | ||
| 827 | ReadGlobalSetting(Settings::values.max_anisotropy); | 828 | ReadGlobalSetting(Settings::values.max_anisotropy); |
| 828 | ReadGlobalSetting(Settings::values.use_speed_limit); | 829 | ReadGlobalSetting(Settings::values.use_speed_limit); |
| 829 | ReadGlobalSetting(Settings::values.speed_limit); | 830 | ReadGlobalSetting(Settings::values.speed_limit); |
| @@ -1364,6 +1365,10 @@ void Config::SaveRendererValues() { | |||
| 1364 | static_cast<u32>(Settings::values.fullscreen_mode.GetDefault()), | 1365 | static_cast<u32>(Settings::values.fullscreen_mode.GetDefault()), |
| 1365 | Settings::values.fullscreen_mode.UsingGlobal()); | 1366 | Settings::values.fullscreen_mode.UsingGlobal()); |
| 1366 | WriteGlobalSetting(Settings::values.aspect_ratio); | 1367 | WriteGlobalSetting(Settings::values.aspect_ratio); |
| 1368 | WriteSetting(QString::fromStdString(Settings::values.resolution_setup.GetLabel()), | ||
| 1369 | static_cast<u32>(Settings::values.resolution_setup.GetValue(global)), | ||
| 1370 | static_cast<u32>(Settings::values.resolution_setup.GetDefault()), | ||
| 1371 | Settings::values.resolution_setup.UsingGlobal()); | ||
| 1367 | WriteGlobalSetting(Settings::values.max_anisotropy); | 1372 | WriteGlobalSetting(Settings::values.max_anisotropy); |
| 1368 | WriteGlobalSetting(Settings::values.use_speed_limit); | 1373 | WriteGlobalSetting(Settings::values.use_speed_limit); |
| 1369 | WriteGlobalSetting(Settings::values.speed_limit); | 1374 | WriteGlobalSetting(Settings::values.speed_limit); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index a7f4a6720..fbb91d312 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -189,5 +189,6 @@ Q_DECLARE_METATYPE(Settings::CPUAccuracy); | |||
| 189 | Q_DECLARE_METATYPE(Settings::GPUAccuracy); | 189 | Q_DECLARE_METATYPE(Settings::GPUAccuracy); |
| 190 | Q_DECLARE_METATYPE(Settings::FullscreenMode); | 190 | Q_DECLARE_METATYPE(Settings::FullscreenMode); |
| 191 | Q_DECLARE_METATYPE(Settings::NvdecEmulation); | 191 | Q_DECLARE_METATYPE(Settings::NvdecEmulation); |
| 192 | Q_DECLARE_METATYPE(Settings::ResolutionSetup); | ||
| 192 | Q_DECLARE_METATYPE(Settings::RendererBackend); | 193 | Q_DECLARE_METATYPE(Settings::RendererBackend); |
| 193 | Q_DECLARE_METATYPE(Settings::ShaderBackend); | 194 | Q_DECLARE_METATYPE(Settings::ShaderBackend); |
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 8e20cc6f3..4f08ae3e0 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -102,6 +102,8 @@ void ConfigureGraphics::SetConfiguration() { | |||
| 102 | ui->nvdec_emulation->setCurrentIndex( | 102 | ui->nvdec_emulation->setCurrentIndex( |
| 103 | static_cast<int>(Settings::values.nvdec_emulation.GetValue())); | 103 | static_cast<int>(Settings::values.nvdec_emulation.GetValue())); |
| 104 | ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue()); | 104 | ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue()); |
| 105 | ui->resolution_combobox->setCurrentIndex( | ||
| 106 | static_cast<int>(Settings::values.resolution_setup.GetValue())); | ||
| 105 | } else { | 107 | } else { |
| 106 | ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); | 108 | ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); |
| 107 | ConfigurationShared::SetHighlight(ui->api_widget, | 109 | ConfigurationShared::SetHighlight(ui->api_widget, |
| @@ -122,6 +124,11 @@ void ConfigureGraphics::SetConfiguration() { | |||
| 122 | ConfigurationShared::SetHighlight(ui->ar_label, | 124 | ConfigurationShared::SetHighlight(ui->ar_label, |
| 123 | !Settings::values.aspect_ratio.UsingGlobal()); | 125 | !Settings::values.aspect_ratio.UsingGlobal()); |
| 124 | 126 | ||
| 127 | ConfigurationShared::SetPerGameSetting(ui->resolution_combobox, | ||
| 128 | &Settings::values.resolution_setup); | ||
| 129 | ConfigurationShared::SetHighlight(ui->resolution_label, | ||
| 130 | !Settings::values.resolution_setup.UsingGlobal()); | ||
| 131 | |||
| 125 | ui->bg_combobox->setCurrentIndex(Settings::values.bg_red.UsingGlobal() ? 0 : 1); | 132 | ui->bg_combobox->setCurrentIndex(Settings::values.bg_red.UsingGlobal() ? 0 : 1); |
| 126 | ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal()); | 133 | ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal()); |
| 127 | ConfigurationShared::SetHighlight(ui->bg_layout, !Settings::values.bg_red.UsingGlobal()); | 134 | ConfigurationShared::SetHighlight(ui->bg_layout, !Settings::values.bg_red.UsingGlobal()); |
| @@ -133,11 +140,14 @@ void ConfigureGraphics::SetConfiguration() { | |||
| 133 | } | 140 | } |
| 134 | 141 | ||
| 135 | void ConfigureGraphics::ApplyConfiguration() { | 142 | void ConfigureGraphics::ApplyConfiguration() { |
| 143 | const auto resolution_setup = static_cast<Settings::ResolutionSetup>( | ||
| 144 | ui->resolution_combobox->currentIndex() - | ||
| 145 | ((Settings::IsConfiguringGlobal()) ? 0 : ConfigurationShared::USE_GLOBAL_OFFSET)); | ||
| 146 | |||
| 136 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.fullscreen_mode, | 147 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.fullscreen_mode, |
| 137 | ui->fullscreen_mode_combobox); | 148 | ui->fullscreen_mode_combobox); |
| 138 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.aspect_ratio, | 149 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.aspect_ratio, |
| 139 | ui->aspect_ratio_combobox); | 150 | ui->aspect_ratio_combobox); |
| 140 | |||
| 141 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache, | 151 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache, |
| 142 | ui->use_disk_shader_cache, use_disk_shader_cache); | 152 | ui->use_disk_shader_cache, use_disk_shader_cache); |
| 143 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation, | 153 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation, |
| @@ -165,7 +175,16 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
| 165 | Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); | 175 | Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); |
| 166 | Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); | 176 | Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); |
| 167 | } | 177 | } |
| 178 | if (Settings::values.resolution_setup.UsingGlobal()) { | ||
| 179 | Settings::values.resolution_setup.SetValue(resolution_setup); | ||
| 180 | } | ||
| 168 | } else { | 181 | } else { |
| 182 | if (ui->resolution_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { | ||
| 183 | Settings::values.resolution_setup.SetGlobal(true); | ||
| 184 | } else { | ||
| 185 | Settings::values.resolution_setup.SetGlobal(false); | ||
| 186 | Settings::values.resolution_setup.SetValue(resolution_setup); | ||
| 187 | } | ||
| 169 | if (ui->api->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { | 188 | if (ui->api->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { |
| 170 | Settings::values.renderer_backend.SetGlobal(true); | 189 | Settings::values.renderer_backend.SetGlobal(true); |
| 171 | Settings::values.shader_backend.SetGlobal(true); | 190 | Settings::values.shader_backend.SetGlobal(true); |
| @@ -207,6 +226,7 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
| 207 | Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); | 226 | Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); |
| 208 | } | 227 | } |
| 209 | } | 228 | } |
| 229 | Settings::UpdateRescalingInfo(); | ||
| 210 | } | 230 | } |
| 211 | 231 | ||
| 212 | void ConfigureGraphics::changeEvent(QEvent* event) { | 232 | void ConfigureGraphics::changeEvent(QEvent* event) { |
| @@ -312,6 +332,7 @@ void ConfigureGraphics::SetupPerGameUI() { | |||
| 312 | ui->device->setEnabled(Settings::values.renderer_backend.UsingGlobal()); | 332 | ui->device->setEnabled(Settings::values.renderer_backend.UsingGlobal()); |
| 313 | ui->fullscreen_mode_combobox->setEnabled(Settings::values.fullscreen_mode.UsingGlobal()); | 333 | ui->fullscreen_mode_combobox->setEnabled(Settings::values.fullscreen_mode.UsingGlobal()); |
| 314 | ui->aspect_ratio_combobox->setEnabled(Settings::values.aspect_ratio.UsingGlobal()); | 334 | ui->aspect_ratio_combobox->setEnabled(Settings::values.aspect_ratio.UsingGlobal()); |
| 335 | ui->resolution_combobox->setEnabled(Settings::values.resolution_setup.UsingGlobal()); | ||
| 315 | ui->use_asynchronous_gpu_emulation->setEnabled( | 336 | ui->use_asynchronous_gpu_emulation->setEnabled( |
| 316 | Settings::values.use_asynchronous_gpu_emulation.UsingGlobal()); | 337 | Settings::values.use_asynchronous_gpu_emulation.UsingGlobal()); |
| 317 | ui->nvdec_emulation->setEnabled(Settings::values.nvdec_emulation.UsingGlobal()); | 338 | ui->nvdec_emulation->setEnabled(Settings::values.nvdec_emulation.UsingGlobal()); |
| @@ -340,6 +361,9 @@ void ConfigureGraphics::SetupPerGameUI() { | |||
| 340 | ConfigurationShared::SetColoredComboBox( | 361 | ConfigurationShared::SetColoredComboBox( |
| 341 | ui->fullscreen_mode_combobox, ui->fullscreen_mode_label, | 362 | ui->fullscreen_mode_combobox, ui->fullscreen_mode_label, |
| 342 | static_cast<int>(Settings::values.fullscreen_mode.GetValue(true))); | 363 | static_cast<int>(Settings::values.fullscreen_mode.GetValue(true))); |
| 364 | ConfigurationShared::SetColoredComboBox( | ||
| 365 | ui->resolution_combobox, ui->resolution_label, | ||
| 366 | static_cast<int>(Settings::values.resolution_setup.GetValue(true))); | ||
| 343 | ConfigurationShared::InsertGlobalItem( | 367 | ConfigurationShared::InsertGlobalItem( |
| 344 | ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true))); | 368 | ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true))); |
| 345 | ConfigurationShared::InsertGlobalItem( | 369 | ConfigurationShared::InsertGlobalItem( |
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index beae74344..1b6ac3cbb 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui | |||
| @@ -310,6 +310,70 @@ | |||
| 310 | </widget> | 310 | </widget> |
| 311 | </item> | 311 | </item> |
| 312 | <item> | 312 | <item> |
| 313 | <widget class="QWidget" name="resolution_layout" native="true"> | ||
| 314 | <layout class="QHBoxLayout" name="horizontalLayout_5"> | ||
| 315 | <property name="leftMargin"> | ||
| 316 | <number>0</number> | ||
| 317 | </property> | ||
| 318 | <property name="topMargin"> | ||
| 319 | <number>0</number> | ||
| 320 | </property> | ||
| 321 | <property name="rightMargin"> | ||
| 322 | <number>0</number> | ||
| 323 | </property> | ||
| 324 | <property name="bottomMargin"> | ||
| 325 | <number>0</number> | ||
| 326 | </property> | ||
| 327 | <item> | ||
| 328 | <widget class="QLabel" name="resolution_label"> | ||
| 329 | <property name="text"> | ||
| 330 | <string>Resolution:</string> | ||
| 331 | </property> | ||
| 332 | </widget> | ||
| 333 | </item> | ||
| 334 | <item> | ||
| 335 | <widget class="QComboBox" name="resolution_combobox"> | ||
| 336 | <item> | ||
| 337 | <property name="text"> | ||
| 338 | <string>0.5X (360p/540p)</string> | ||
| 339 | </property> | ||
| 340 | </item> | ||
| 341 | <item> | ||
| 342 | <property name="text"> | ||
| 343 | <string>0.75X (540p/810p)</string> | ||
| 344 | </property> | ||
| 345 | </item> | ||
| 346 | <item> | ||
| 347 | <property name="text"> | ||
| 348 | <string>1X (720p/1080p)</string> | ||
| 349 | </property> | ||
| 350 | </item> | ||
| 351 | <item> | ||
| 352 | <property name="text"> | ||
| 353 | <string>1.5X (1080p/1620p)</string> | ||
| 354 | </property> | ||
| 355 | </item> | ||
| 356 | <item> | ||
| 357 | <property name="text"> | ||
| 358 | <string>2X (1440p/2160[4K]p)</string> | ||
| 359 | </property> | ||
| 360 | </item> | ||
| 361 | <item> | ||
| 362 | <property name="text"> | ||
| 363 | <string>3X (2160p[4K]/3240p[6K])</string> | ||
| 364 | </property> | ||
| 365 | </item> | ||
| 366 | <item> | ||
| 367 | <property name="text"> | ||
| 368 | <string>4X (2880p/4320p[8K])</string> | ||
| 369 | </property> | ||
| 370 | </item> | ||
| 371 | </widget> | ||
| 372 | </item> | ||
| 373 | </layout> | ||
| 374 | </widget> | ||
| 375 | </item> | ||
| 376 | <item> | ||
| 313 | <widget class="QWidget" name="bg_layout" native="true"> | 377 | <widget class="QWidget" name="bg_layout" native="true"> |
| 314 | <property name="sizePolicy"> | 378 | <property name="sizePolicy"> |
| 315 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | 379 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |