From 60b053d7be1f5a62509561ef9902fdf89e85cf66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 31 Oct 2026 16:29:25 +0100 Subject: [PATCH] Android: Allow custom Vulkan drivers on Mali too Custom drivers that target Mali's kbase kernel interface exist now, and AdrenoTools can load them the same way it loads Turnip. Offer the driver manager when /dev/mali0 exists, not just /dev/kgsl-3d0, like Dolphin does (dolphin-emu/dolphin#14958). The manager is now called "Custom driver manager", and the Turnip flags are only shown on Adreno. Co-Authored-By: Claude Opus 5.5 --- UI/DeveloperSettingsPages.cpp | 26 +------------------- UI/DriverManagerScreen.cpp | 45 ++++++++++++++++++++++++++++++----- UI/DriverManagerScreen.h | 4 ++++ assets/lang/en_US.ini | 2 +- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/UI/DeveloperSettingsPages.cpp b/UI/DeveloperSettingsPages.cpp index 424f20a920..a41d51d472 100644 --- a/UI/DeveloperSettingsPages.cpp +++ b/UI/DeveloperSettingsPages.cpp @@ -51,30 +51,6 @@ #include "UI/MiscViews.h" #include "UI/SettingsPage.h" -#if PPSSPP_PLATFORM(ANDROID) - -static bool CheckKgslPresent() { - constexpr auto KgslPath{ "/dev/kgsl-3d0" }; - - return access(KgslPath, F_OK) == 0; -} - -static bool SupportsCustomDriver() { - return android_get_device_api_level() >= 28 && CheckKgslPresent(); -} - -#else - -static bool SupportsCustomDriver() { -#ifdef _DEBUG - return false; // change to true to debug driver installation on other platforms. DO NOT commit as true. -#else - return false; -#endif -} - -#endif - static std::string PostShaderTranslateName(std::string_view value) { const ShaderInfo *info = GetPostShaderInfo(value); if (info) { @@ -539,7 +515,7 @@ static void BuildGraphicsPage(SettingsPage *page) { } if (GetGPUBackend() == GPUBackend::VULKAN && SupportsCustomDriver()) { - page->Choice({ I18NCat::GRAPHICS, "AdrenoTools driver manager" }).OpensScreen().OnClick([host](UI::EventParams &e) { + page->Choice({ I18NCat::GRAPHICS, "Custom driver manager" }).OpensScreen().OnClick([host](UI::EventParams &e) { host->PageScreenManager()->push(new DriverManagerScreen(host->PageGamePath())); }); } diff --git a/UI/DriverManagerScreen.cpp b/UI/DriverManagerScreen.cpp index 91007188c0..bec893ce5b 100644 --- a/UI/DriverManagerScreen.cpp +++ b/UI/DriverManagerScreen.cpp @@ -20,6 +20,31 @@ #include "UI/OnScreenDisplay.h" #include "UI/MiscScreens.h" +#if PPSSPP_PLATFORM(ANDROID) +#include +#include + +// Adreno +static bool CheckKgslPresent() { + return access("/dev/kgsl-3d0", F_OK) == 0; +} + +// Mali +static bool CheckKbasePresent() { + return access("/dev/mali0", F_OK) == 0; +} +#endif + +bool SupportsCustomDriver() { +#if PPSSPP_PLATFORM(ANDROID) + return android_get_device_api_level() >= 28 && (CheckKgslPresent() || CheckKbasePresent()); +#elif defined(_DEBUG) + return false; // change to true to debug driver installation on other platforms. DO NOT commit as true. +#else + return false; +#endif +} + static Path GetDriverPath() { if (g_Config.internalDataDirectory.empty()) { Path curDir = File::GetCurDirectory(); @@ -168,17 +193,25 @@ void DriverManagerScreen::CreateDriverTab(UI::ViewGroup *drivers) { ChoiceGroupList *groups = drivers->Add(new ChoiceGroupList()); - ChoiceGroup *driverManagerGroup = groups->Add(new ChoiceGroup(gr->T("AdrenoTools driver manager"))); + ChoiceGroup *driverManagerGroup = groups->Add(new ChoiceGroup(gr->T("Custom driver manager"))); auto customDriverInstallChoice = driverManagerGroup->Add(new Choice(gr->T("Install custom driver..."))); driverManagerGroup->Add(new Choice(di->T("More info")))->OnClick.Add([=](UI::EventParams &e) { System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/docs/reference/custom-drivers/"); }); - ChoiceGroup *adrenoEnvVarGroup = groups->Add(new ChoiceGroup(gr->T("Turnip driver flags"))); - int count = 0; - const AdrenoEnvVarDef *adrenoEnvVarDefs = GetAdrenoEnvVarDefs(&count); - for (int i = 0; i < count; i++) { - adrenoEnvVarGroup->Add(new BitCheckBox(&g_Config.iAdrenoEnvVars, (int)adrenoEnvVarDefs[i].var, adrenoEnvVarDefs[i].name)); + // Turnip is Adreno-only. Keep the flags visible off Android, for debugging the screen. +#if PPSSPP_PLATFORM(ANDROID) + const bool showTurnipFlags = CheckKgslPresent(); +#else + const bool showTurnipFlags = true; +#endif + if (showTurnipFlags) { + ChoiceGroup *adrenoEnvVarGroup = groups->Add(new ChoiceGroup(gr->T("Turnip driver flags"))); + int count = 0; + const AdrenoEnvVarDef *adrenoEnvVarDefs = GetAdrenoEnvVarDefs(&count); + for (int i = 0; i < count; i++) { + adrenoEnvVarGroup->Add(new BitCheckBox(&g_Config.iAdrenoEnvVars, (int)adrenoEnvVarDefs[i].var, adrenoEnvVarDefs[i].name)); + } } customDriverInstallChoice->OnClick.Handle(this, &DriverManagerScreen::OnCustomDriverInstall); diff --git a/UI/DriverManagerScreen.h b/UI/DriverManagerScreen.h index 5efb5c6583..ba8731e924 100644 --- a/UI/DriverManagerScreen.h +++ b/UI/DriverManagerScreen.h @@ -6,6 +6,10 @@ #include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" +// Whether custom Vulkan drivers can be loaded through AdrenoTools. Works on Adreno (KGSL) +// and on Mali (kbase), for drivers that target those kernel interfaces. +bool SupportsCustomDriver(); + // Per-game settings screen - enables you to configure graphic options, control options, etc // per game. class DriverManagerScreen : public UITabbedBaseDialogScreen { diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index d5959bdcdf..f3cc476359 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -791,7 +791,6 @@ Watch video = Watch video 10x PSP = 10× PSP 16x = 16× Add postprocessing shader = Add postprocessing shader -AdrenoTools driver manager = AdrenoTools driver manager Aggressive = Aggressive Allow exclusive fullscreen = Allow exclusive fullscreen Alternative Speed = Alternative speed (in %, 0 = unlimited) @@ -815,6 +814,7 @@ Buffer graphics commands = Buffer graphics commands Copy to texture = Copy to texture CPU texture upscaler (slow) = Upscale type Current GPU driver = Current GPU driver +Custom driver manager = Custom driver manager Default = Default Default GPU driver = Default GPU driver Disable culling = Disable culling