From ea46efd9a2713d28936141066e3d4418f28c4648 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 4 Sep 2023 20:21:14 -0400 Subject: [PATCH 1/4] configure_graphics: Fix handling of broken Vulkan The VSync combobox wouldn't populate if there was no Vulkan device, which caused issues with trying to set VSync on other backends. This also adds another layer to GetCurrentGraphicsBackend to check for broken Vulkan and return OpenGL instead of Vulkan. --- src/yuzu/configuration/configure_graphics.cpp | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 8622dc184..f36a0cae7 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -193,14 +193,10 @@ void ConfigureGraphics::PopulateVSyncModeSelection() { : vsync_mode_combobox_enum_map[current_index]; int index{}; const int device{vulkan_device_combobox->currentIndex()}; //< current selected Vulkan device - if (device == -1) { - // Invalid device - return; - } const auto& present_modes = //< relevant vector of present modes for the selected device or API - backend == Settings::RendererBackend::Vulkan ? device_present_modes[device] - : default_present_modes; + backend == Settings::RendererBackend::Vulkan && device > -1 ? device_present_modes[device] + : default_present_modes; vsync_mode_combobox->clear(); vsync_mode_combobox_enum_map.clear(); @@ -497,11 +493,19 @@ void ConfigureGraphics::RetrieveVulkanDevices() { } Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { - if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) { - return Settings::values.renderer_backend.GetValue(true); + const auto selected_backend = [=]() { + if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) { + return Settings::values.renderer_backend.GetValue(true); + } + return static_cast( + combobox_translations.at(Settings::EnumMetadata::Index()) + .at(api_combobox->currentIndex()) + .first); + }(); + + if (selected_backend == Settings::RendererBackend::Vulkan && + UISettings::values.has_broken_vulkan) { + return Settings::RendererBackend::OpenGL; } - return static_cast( - combobox_translations.at(Settings::EnumMetadata::Index()) - .at(api_combobox->currentIndex()) - .first); + return selected_backend; } From d078cff269b372106bd5e62dc4e25dd4694e33b4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 5 Sep 2023 17:50:21 -0400 Subject: [PATCH 2/4] configure_graphics: Capture by reference Small optimization. --- src/yuzu/configuration/configure_graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index f36a0cae7..fd6bebf0f 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -493,7 +493,7 @@ void ConfigureGraphics::RetrieveVulkanDevices() { } Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { - const auto selected_backend = [=]() { + const auto selected_backend = [&]() { if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) { return Settings::values.renderer_backend.GetValue(true); } From e4ebabcd5bde463d4534fbc41538af77495508e6 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 5 Sep 2023 17:59:10 -0400 Subject: [PATCH 3/4] yuzu-qt: Update API Text for broken Vulkan Otherwise caused a blue Vulkan badge to appear in the status bar. --- src/yuzu/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f2e6c03f0..91c7797cf 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -444,6 +444,7 @@ GMainWindow::GMainWindow(std::unique_ptr config_, bool has_broken_vulkan Settings::values.renderer_backend = Settings::RendererBackend::OpenGL; + UpdateAPIText(); renderer_status_button->setDisabled(true); renderer_status_button->setChecked(false); } else { From d8943e5bac380bbf49e1064aa30a9ec6b8f9be91 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 5 Sep 2023 17:59:44 -0400 Subject: [PATCH 4/4] yuzu-qt: Use Null when OpenGL is not compiled --- src/yuzu/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 91c7797cf..5262769bb 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -442,7 +442,11 @@ GMainWindow::GMainWindow(std::unique_ptr config_, bool has_broken_vulkan "#yuzu-starts-with-the-error-broken-vulkan-installation-detected'>" "here for instructions to fix the issue.")); +#ifdef HAS_OPENGL Settings::values.renderer_backend = Settings::RendererBackend::OpenGL; +#else + Settings::values.renderer_backend = Settings::RendererBackend::Null; +#endif UpdateAPIText(); renderer_status_button->setDisabled(true); @@ -3771,10 +3775,14 @@ void GMainWindow::OnToggleAdaptingFilter() { void GMainWindow::OnToggleGraphicsAPI() { auto api = Settings::values.renderer_backend.GetValue(); - if (api == Settings::RendererBackend::OpenGL) { + if (api != Settings::RendererBackend::Vulkan) { api = Settings::RendererBackend::Vulkan; } else { +#ifdef HAS_OPENGL api = Settings::RendererBackend::OpenGL; +#else + api = Settings::RendererBackend::Null; +#endif } Settings::values.renderer_backend.SetValue(api); renderer_status_button->setChecked(api == Settings::RendererBackend::Vulkan);