diff options
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 94 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.h | 4 |
2 files changed, 68 insertions, 30 deletions
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index fd6bebf0f..0836bcb7e 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -106,32 +106,30 @@ ConfigureGraphics::ConfigureGraphics( | |||
| 106 | Settings::values.bg_green.GetValue(), | 106 | Settings::values.bg_green.GetValue(), |
| 107 | Settings::values.bg_blue.GetValue())); | 107 | Settings::values.bg_blue.GetValue())); |
| 108 | UpdateAPILayout(); | 108 | UpdateAPILayout(); |
| 109 | PopulateVSyncModeSelection(); //< must happen after UpdateAPILayout | 109 | PopulateVSyncModeSelection(false); //< must happen after UpdateAPILayout |
| 110 | 110 | ||
| 111 | // VSync setting needs to be determined after populating the VSync combobox | 111 | // VSync setting needs to be determined after populating the VSync combobox |
| 112 | if (Settings::IsConfiguringGlobal()) { | 112 | const auto vsync_mode_setting = Settings::values.vsync_mode.GetValue(); |
| 113 | const auto vsync_mode_setting = Settings::values.vsync_mode.GetValue(); | 113 | const auto vsync_mode = VSyncSettingToMode(vsync_mode_setting); |
| 114 | const auto vsync_mode = VSyncSettingToMode(vsync_mode_setting); | 114 | int index{}; |
| 115 | int index{}; | 115 | for (const auto mode : vsync_mode_combobox_enum_map) { |
| 116 | for (const auto mode : vsync_mode_combobox_enum_map) { | 116 | if (mode == vsync_mode) { |
| 117 | if (mode == vsync_mode) { | 117 | break; |
| 118 | break; | ||
| 119 | } | ||
| 120 | index++; | ||
| 121 | } | ||
| 122 | if (static_cast<unsigned long>(index) < vsync_mode_combobox_enum_map.size()) { | ||
| 123 | vsync_mode_combobox->setCurrentIndex(index); | ||
| 124 | } | 118 | } |
| 119 | index++; | ||
| 120 | } | ||
| 121 | if (static_cast<unsigned long>(index) < vsync_mode_combobox_enum_map.size()) { | ||
| 122 | vsync_mode_combobox->setCurrentIndex(index); | ||
| 125 | } | 123 | } |
| 126 | 124 | ||
| 127 | connect(api_combobox, qOverload<int>(&QComboBox::activated), this, [this] { | 125 | connect(api_combobox, qOverload<int>(&QComboBox::activated), this, [this] { |
| 128 | UpdateAPILayout(); | 126 | UpdateAPILayout(); |
| 129 | PopulateVSyncModeSelection(); | 127 | PopulateVSyncModeSelection(false); |
| 130 | }); | 128 | }); |
| 131 | connect(vulkan_device_combobox, qOverload<int>(&QComboBox::activated), this, | 129 | connect(vulkan_device_combobox, qOverload<int>(&QComboBox::activated), this, |
| 132 | [this](int device) { | 130 | [this](int device) { |
| 133 | UpdateDeviceSelection(device); | 131 | UpdateDeviceSelection(device); |
| 134 | PopulateVSyncModeSelection(); | 132 | PopulateVSyncModeSelection(false); |
| 135 | }); | 133 | }); |
| 136 | connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this, | 134 | connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this, |
| 137 | [this](int backend) { UpdateShaderBackendSelection(backend); }); | 135 | [this](int backend) { UpdateShaderBackendSelection(backend); }); |
| @@ -147,8 +145,9 @@ ConfigureGraphics::ConfigureGraphics( | |||
| 147 | const auto& update_screenshot_info = [this, &builder]() { | 145 | const auto& update_screenshot_info = [this, &builder]() { |
| 148 | const auto& combobox_enumerations = builder.ComboboxTranslations().at( | 146 | const auto& combobox_enumerations = builder.ComboboxTranslations().at( |
| 149 | Settings::EnumMetadata<Settings::AspectRatio>::Index()); | 147 | Settings::EnumMetadata<Settings::AspectRatio>::Index()); |
| 150 | const auto index = aspect_ratio_combobox->currentIndex(); | 148 | const auto ratio_index = aspect_ratio_combobox->currentIndex(); |
| 151 | const auto ratio = static_cast<Settings::AspectRatio>(combobox_enumerations[index].first); | 149 | const auto ratio = |
| 150 | static_cast<Settings::AspectRatio>(combobox_enumerations[ratio_index].first); | ||
| 152 | 151 | ||
| 153 | const auto& combobox_enumerations_resolution = builder.ComboboxTranslations().at( | 152 | const auto& combobox_enumerations_resolution = builder.ComboboxTranslations().at( |
| 154 | Settings::EnumMetadata<Settings::ResolutionSetup>::Index()); | 153 | Settings::EnumMetadata<Settings::ResolutionSetup>::Index()); |
| @@ -174,11 +173,7 @@ ConfigureGraphics::ConfigureGraphics( | |||
| 174 | } | 173 | } |
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | void ConfigureGraphics::PopulateVSyncModeSelection() { | 176 | void ConfigureGraphics::PopulateVSyncModeSelection(bool use_setting) { |
| 178 | if (!Settings::IsConfiguringGlobal()) { | ||
| 179 | return; | ||
| 180 | } | ||
| 181 | |||
| 182 | const Settings::RendererBackend backend{GetCurrentGraphicsBackend()}; | 177 | const Settings::RendererBackend backend{GetCurrentGraphicsBackend()}; |
| 183 | if (backend == Settings::RendererBackend::Null) { | 178 | if (backend == Settings::RendererBackend::Null) { |
| 184 | vsync_mode_combobox->setEnabled(false); | 179 | vsync_mode_combobox->setEnabled(false); |
| @@ -189,8 +184,9 @@ void ConfigureGraphics::PopulateVSyncModeSelection() { | |||
| 189 | const int current_index = //< current selected vsync mode from combobox | 184 | const int current_index = //< current selected vsync mode from combobox |
| 190 | vsync_mode_combobox->currentIndex(); | 185 | vsync_mode_combobox->currentIndex(); |
| 191 | const auto current_mode = //< current selected vsync mode as a VkPresentModeKHR | 186 | const auto current_mode = //< current selected vsync mode as a VkPresentModeKHR |
| 192 | current_index == -1 ? VSyncSettingToMode(Settings::values.vsync_mode.GetValue()) | 187 | current_index == -1 || use_setting |
| 193 | : vsync_mode_combobox_enum_map[current_index]; | 188 | ? VSyncSettingToMode(Settings::values.vsync_mode.GetValue()) |
| 189 | : vsync_mode_combobox_enum_map[current_index]; | ||
| 194 | int index{}; | 190 | int index{}; |
| 195 | const int device{vulkan_device_combobox->currentIndex()}; //< current selected Vulkan device | 191 | const int device{vulkan_device_combobox->currentIndex()}; //< current selected Vulkan device |
| 196 | 192 | ||
| @@ -214,6 +210,23 @@ void ConfigureGraphics::PopulateVSyncModeSelection() { | |||
| 214 | } | 210 | } |
| 215 | index++; | 211 | index++; |
| 216 | } | 212 | } |
| 213 | |||
| 214 | if (!Settings::IsConfiguringGlobal()) { | ||
| 215 | vsync_restore_global_button->setVisible(!Settings::values.vsync_mode.UsingGlobal()); | ||
| 216 | |||
| 217 | const Settings::VSyncMode global_vsync_mode = Settings::values.vsync_mode.GetValue(true); | ||
| 218 | vsync_restore_global_button->setEnabled( | ||
| 219 | (backend == Settings::RendererBackend::OpenGL && | ||
| 220 | (global_vsync_mode == Settings::VSyncMode::Immediate || | ||
| 221 | global_vsync_mode == Settings::VSyncMode::Fifo)) || | ||
| 222 | backend == Settings::RendererBackend::Vulkan); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | |||
| 226 | void ConfigureGraphics::UpdateVsyncSetting() const { | ||
| 227 | const auto mode = vsync_mode_combobox_enum_map[vsync_mode_combobox->currentIndex()]; | ||
| 228 | const auto vsync_mode = PresentModeToSetting(mode); | ||
| 229 | Settings::values.vsync_mode.SetValue(vsync_mode); | ||
| 217 | } | 230 | } |
| 218 | 231 | ||
| 219 | void ConfigureGraphics::UpdateDeviceSelection(int device) { | 232 | void ConfigureGraphics::UpdateDeviceSelection(int device) { |
| @@ -299,6 +312,33 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { | |||
| 299 | } else if (setting->Id() == Settings::values.vsync_mode.Id()) { | 312 | } else if (setting->Id() == Settings::values.vsync_mode.Id()) { |
| 300 | // Keep track of vsync_mode's combobox so we can populate it | 313 | // Keep track of vsync_mode's combobox so we can populate it |
| 301 | vsync_mode_combobox = widget->combobox; | 314 | vsync_mode_combobox = widget->combobox; |
| 315 | |||
| 316 | // Since vsync is populated at runtime, we have to manually set up the button for | ||
| 317 | // restoring the global setting. | ||
| 318 | if (!Settings::IsConfiguringGlobal()) { | ||
| 319 | QPushButton* restore_button = | ||
| 320 | ConfigurationShared::Widget::CreateRestoreGlobalButton( | ||
| 321 | Settings::values.vsync_mode.UsingGlobal(), widget); | ||
| 322 | restore_button->setEnabled(true); | ||
| 323 | widget->layout()->addWidget(restore_button); | ||
| 324 | |||
| 325 | QObject::connect(restore_button, &QAbstractButton::clicked, | ||
| 326 | [restore_button, this](bool) { | ||
| 327 | Settings::values.vsync_mode.SetGlobal(true); | ||
| 328 | PopulateVSyncModeSelection(true); | ||
| 329 | |||
| 330 | restore_button->setVisible(false); | ||
| 331 | }); | ||
| 332 | |||
| 333 | std::function<void()> set_non_global = [restore_button, this]() { | ||
| 334 | Settings::values.vsync_mode.SetGlobal(false); | ||
| 335 | UpdateVsyncSetting(); | ||
| 336 | restore_button->setVisible(true); | ||
| 337 | }; | ||
| 338 | QObject::connect(widget->combobox, QOverload<int>::of(&QComboBox::activated), | ||
| 339 | [set_non_global]() { set_non_global(); }); | ||
| 340 | vsync_restore_global_button = restore_button; | ||
| 341 | } | ||
| 302 | hold_graphics.emplace(setting->Id(), widget); | 342 | hold_graphics.emplace(setting->Id(), widget); |
| 303 | } else if (setting->Id() == Settings::values.aspect_ratio.Id()) { | 343 | } else if (setting->Id() == Settings::values.aspect_ratio.Id()) { |
| 304 | // Keep track of the aspect ratio combobox to update other UI tabs that need it | 344 | // Keep track of the aspect ratio combobox to update other UI tabs that need it |
| @@ -400,11 +440,7 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
| 400 | func(powered_on); | 440 | func(powered_on); |
| 401 | } | 441 | } |
| 402 | 442 | ||
| 403 | if (Settings::IsConfiguringGlobal()) { | 443 | UpdateVsyncSetting(); |
| 404 | const auto mode = vsync_mode_combobox_enum_map[vsync_mode_combobox->currentIndex()]; | ||
| 405 | const auto vsync_mode = PresentModeToSetting(mode); | ||
| 406 | Settings::values.vsync_mode.SetValue(vsync_mode); | ||
| 407 | } | ||
| 408 | 444 | ||
| 409 | Settings::values.vulkan_device.SetGlobal(true); | 445 | Settings::values.vulkan_device.SetGlobal(true); |
| 410 | Settings::values.shader_backend.SetGlobal(true); | 446 | Settings::values.shader_backend.SetGlobal(true); |
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 9c24a56db..5c8286836 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h | |||
| @@ -62,7 +62,8 @@ private: | |||
| 62 | 62 | ||
| 63 | void Setup(const ConfigurationShared::Builder& builder); | 63 | void Setup(const ConfigurationShared::Builder& builder); |
| 64 | 64 | ||
| 65 | void PopulateVSyncModeSelection(); | 65 | void PopulateVSyncModeSelection(bool use_setting); |
| 66 | void UpdateVsyncSetting() const; | ||
| 66 | void UpdateBackgroundColorButton(QColor color); | 67 | void UpdateBackgroundColorButton(QColor color); |
| 67 | void UpdateAPILayout(); | 68 | void UpdateAPILayout(); |
| 68 | void UpdateDeviceSelection(int device); | 69 | void UpdateDeviceSelection(int device); |
| @@ -104,6 +105,7 @@ private: | |||
| 104 | QComboBox* api_combobox; | 105 | QComboBox* api_combobox; |
| 105 | QComboBox* shader_backend_combobox; | 106 | QComboBox* shader_backend_combobox; |
| 106 | QComboBox* vsync_mode_combobox; | 107 | QComboBox* vsync_mode_combobox; |
| 108 | QPushButton* vsync_restore_global_button; | ||
| 107 | QWidget* vulkan_device_widget; | 109 | QWidget* vulkan_device_widget; |
| 108 | QWidget* api_widget; | 110 | QWidget* api_widget; |
| 109 | QWidget* shader_backend_widget; | 111 | QWidget* shader_backend_widget; |