From f83b9c511d22a8ad7d42916e154dc7c295437e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 30 Aug 2025 15:39:57 +0200 Subject: [PATCH] Delay checking for active backend until you click the Backend popup --- Common/UI/PopupScreens.cpp | 5 +++++ Common/UI/PopupScreens.h | 7 +++++++ UI/GameSettingsScreen.cpp | 20 ++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 699082cc72..787e4ac15e 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -96,6 +96,11 @@ std::string ChopTitle(const std::string &title) { } UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) { + if (!callbackExecuted_ && preOpenCallback_) { + preOpenCallback_(this); + callbackExecuted_ = true; + } + restoreFocus_ = HasFocus(); auto category = GetI18NCategory(category_); diff --git a/Common/UI/PopupScreens.h b/Common/UI/PopupScreens.h index 9d25f6382e..d5d832498c 100644 --- a/Common/UI/PopupScreens.h +++ b/Common/UI/PopupScreens.h @@ -236,6 +236,10 @@ public: return hidden_.find(c) != hidden_.end(); } + void SetPreOpenCallback(std::function callback) { + preOpenCallback_ = callback; + } + UI::Event OnChoice; protected: @@ -259,6 +263,9 @@ private: bool restoreFocus_ = false; std::set hidden_; std::map icons_; + + std::function preOpenCallback_; + bool callbackExecuted_ = false; }; // Allows passing in a dynamic vector of strings. Saves the string. diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index fb34585f53..3447f76a9a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -267,15 +267,19 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) #if !PPSSPP_PLATFORM(UWP) static const char *renderingBackend[] = { "OpenGL", "Direct3D 9", "Direct3D 11", "Vulkan" }; PopupMultiChoice *renderingBackendChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iGPUBackend, gr->T("Backend"), renderingBackend, (int)GPUBackend::OPENGL, ARRAY_SIZE(renderingBackend), I18NCat::GRAPHICS, screenManager())); - renderingBackendChoice->HideChoice(1); - renderingBackendChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingBackend); + renderingBackendChoice->SetPreOpenCallback([this](UI::PopupMultiChoice *choice) { + // Don't filter until the last possible moment, since it involves trying to initialize Vulkan, if we were + // started in OpenGL mode on Android. + choice->HideChoice(1); + choice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingBackend); - if (!g_Config.IsBackendEnabled(GPUBackend::OPENGL)) - renderingBackendChoice->HideChoice((int)GPUBackend::OPENGL); - if (!g_Config.IsBackendEnabled(GPUBackend::DIRECT3D11)) - renderingBackendChoice->HideChoice((int)GPUBackend::DIRECT3D11); - if (!g_Config.IsBackendEnabled(GPUBackend::VULKAN)) - renderingBackendChoice->HideChoice((int)GPUBackend::VULKAN); + if (!g_Config.IsBackendEnabled(GPUBackend::OPENGL)) + choice->HideChoice((int)GPUBackend::OPENGL); + if (!g_Config.IsBackendEnabled(GPUBackend::DIRECT3D11)) + choice->HideChoice((int)GPUBackend::DIRECT3D11); + if (!g_Config.IsBackendEnabled(GPUBackend::VULKAN)) + choice->HideChoice((int)GPUBackend::VULKAN); + }); if (!IsFirstInstance()) { // If we're not the first instance, can't save the setting, and it requires a restart, so...