diff --git a/Core/Config.cpp b/Core/Config.cpp index 1663b29aa4..aa62b14d08 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -603,7 +603,6 @@ static const ConfigSetting graphicsSettings[] = { #if PPSSPP_PLATFORM(ANDROID) && PPSSPP_ARCH(ARM64) ConfigSetting("CustomDriver", &g_Config.sCustomDriver, "", CfgFlag::DEFAULT), #endif - ConfigSetting("FailedGraphicsBackends", &g_Config.sFailedGPUBackends, "", CfgFlag::DEFAULT), ConfigSetting("DisabledGraphicsBackends", &g_Config.sDisabledGPUBackends, "", CfgFlag::DEFAULT), ConfigSetting("VulkanDevice", &g_Config.sVulkanDevice, "", CfgFlag::DEFAULT), #ifdef _WIN32 diff --git a/Core/Config.h b/Core/Config.h index 801aadbdcb..49612b2d83 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -150,7 +150,7 @@ public: // GFX int iGPUBackend; std::string sCustomDriver; - std::string sFailedGPUBackends; + std::string sFailedGPUBackends; // NOT stored in ppsspp.ini anymore! std::string sDisabledGPUBackends; // We have separate device parameters for each backend so it doesn't get erased if you switch backends. // If not set, will use the "best" device. diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 074e00b94b..b45647ffc5 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -281,6 +281,16 @@ void PostLoadConfig() { #endif } +static Path GetFailedBackendsDir() { + Path failedBackendsDir; + if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { + failedBackendsDir = GetSysDirectory(DIRECTORY_APP_CACHE); + } else { + failedBackendsDir = GetSysDirectory(DIRECTORY_SYSTEM); + } + return failedBackendsDir; +} + static void CheckFailedGPUBackends() { #ifdef _DEBUG // If you're in debug mode, you probably don't want a fallback. If you're in release mode, use IGNORE below. @@ -305,12 +315,12 @@ static void CheckFailedGPUBackends() { } lastBackend = g_Config.iGPUBackend; - Path cache = GetSysDirectory(DIRECTORY_APP_CACHE) / "FailedGraphicsBackends.txt"; + const Path failedBackendsDir = GetFailedBackendsDir(); + const Path failedBackendsFile = failedBackendsDir / "FailedGraphicsBackends.txt"; - if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { - std::string data; - if (File::ReadTextFileToString(cache, &data)) - g_Config.sFailedGPUBackends = data; + std::string data; + if (File::ReadTextFileToString(failedBackendsFile, &data)) { + g_Config.sFailedGPUBackends = data; } // Use this if you want to debug a graphics crash... @@ -326,36 +336,28 @@ static void CheckFailedGPUBackends() { System_GraphicsBackendFailedAlert(param); WARN_LOG(Log::Loader, "Failed graphics backend switched from %s (%d to %d)", param.c_str(), lastBackend, g_Config.iGPUBackend); } - // And then let's - for now - add the current to the failed list. + // And then let's - for now - add the current to the failed list, in case it fails - we'll clear it again once it succeeds. if (g_Config.sFailedGPUBackends.empty()) { g_Config.sFailedGPUBackends = GPUBackendToString((GPUBackend)g_Config.iGPUBackend); } else if (g_Config.sFailedGPUBackends.find("ALL") == std::string::npos) { g_Config.sFailedGPUBackends += "," + GPUBackendToString((GPUBackend)g_Config.iGPUBackend); } - if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { - // Let's try to create, in case it doesn't exist. - if (!File::Exists(GetSysDirectory(DIRECTORY_APP_CACHE))) - File::CreateDir(GetSysDirectory(DIRECTORY_APP_CACHE)); - File::WriteStringToFile(true, g_Config.sFailedGPUBackends, cache); - } else { - // Just save immediately, since we have storage. - g_Config.Save("got storage permission"); - } + // Let's try to create, in case it doesn't exist. + File::CreateFullPath(failedBackendsDir); + File::WriteStringToFile(true, g_Config.sFailedGPUBackends, failedBackendsFile); } static void ClearFailedGPUBackends() { if (g_Config.sFailedGPUBackends == "IGNORE") return; + const Path failedBackendsDir = GetFailedBackendsDir(); + const Path failedBackendsFile = failedBackendsDir / "FailedGraphicsBackends.txt"; // We've successfully started graphics without crashing, hurray. // In case they update drivers and have totally different problems much later, clear the failed list. g_Config.sFailedGPUBackends.clear(); - if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS) || System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) { - File::Delete(GetSysDirectory(DIRECTORY_APP_CACHE) / "FailedGraphicsBackends.txt"); - } else { - g_Config.Save("clearFailedGPUBackends"); - } + File::Delete(failedBackendsFile); } void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir) {