mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-30 11:50:32 +00:00
Core: Allow for disabling graphics backends.
Mainly for Vulkan, since sometimes even mobile drivers crash when we ask. This at least provides options. Also centralizes support checks.
This commit is contained in:
parent
df6c5f38dc
commit
504acf15de
@ -546,34 +546,43 @@ static int DefaultGPUBackend() {
|
||||
|
||||
int Config::NextValidBackend() {
|
||||
std::vector<std::string> split;
|
||||
std::set<int> failed;
|
||||
std::set<GPUBackend> failed;
|
||||
|
||||
SplitString(sFailedGPUBackends, ',', split);
|
||||
for (const auto &str : split) {
|
||||
if (!str.empty() && str != "ALL") {
|
||||
failed.insert((int)GPUBackendFromString(str));
|
||||
failed.insert(GPUBackendFromString(str));
|
||||
}
|
||||
}
|
||||
|
||||
if (failed.count(iGPUBackend)) {
|
||||
// Count these as "failed" too so we don't pick them.
|
||||
SplitString(sDisabledGPUBackends, ',', split);
|
||||
for (const auto &str : split) {
|
||||
if (!str.empty()) {
|
||||
failed.insert(GPUBackendFromString(str));
|
||||
}
|
||||
}
|
||||
|
||||
if (failed.count((GPUBackend)iGPUBackend)) {
|
||||
ERROR_LOG(LOADER, "Graphics backend failed for %d, trying another", iGPUBackend);
|
||||
|
||||
#if (PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID)) && !PPSSPP_PLATFORM(UWP)
|
||||
if (VulkanMayBeAvailable() && !failed.count((int)GPUBackend::VULKAN)) {
|
||||
if (!failed.count(GPUBackend::VULKAN) && VulkanMayBeAvailable()) {
|
||||
return (int)GPUBackend::VULKAN;
|
||||
}
|
||||
#endif
|
||||
#if PPSSPP_PLATFORM(WINDOWS)
|
||||
if (DoesVersionMatchWindows(6, 1, 0, 0, true) && !failed.count((int)GPUBackend::DIRECT3D11)) {
|
||||
if (!failed.count(GPUBackend::DIRECT3D11) && DoesVersionMatchWindows(6, 1, 0, 0, true)) {
|
||||
return (int)GPUBackend::DIRECT3D11;
|
||||
}
|
||||
#endif
|
||||
#if PPSSPP_API(ANY_GL)
|
||||
if (!failed.count((int)GPUBackend::OPENGL)) {
|
||||
if (!failed.count(GPUBackend::OPENGL)) {
|
||||
return (int)GPUBackend::OPENGL;
|
||||
}
|
||||
#endif
|
||||
#if PPSSPP_API(D3D9)
|
||||
if (!failed.count((int)GPUBackend::DIRECT3D9)) {
|
||||
if (!failed.count(GPUBackend::DIRECT3D9)) {
|
||||
return (int)GPUBackend::DIRECT3D9;
|
||||
}
|
||||
#endif
|
||||
@ -587,6 +596,48 @@ int Config::NextValidBackend() {
|
||||
return iGPUBackend;
|
||||
}
|
||||
|
||||
bool Config::IsBackendEnabled(GPUBackend backend, bool validate) {
|
||||
std::vector<std::string> split;
|
||||
|
||||
SplitString(sDisabledGPUBackends, ',', split);
|
||||
for (const auto &str : split) {
|
||||
if (str.empty())
|
||||
continue;
|
||||
auto match = GPUBackendFromString(str);
|
||||
if (match == backend)
|
||||
return false;
|
||||
}
|
||||
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
if (backend != GPUBackend::OPENGL)
|
||||
return false;
|
||||
#elif PPSSPP_PLATFORM(UWP)
|
||||
if (backend != GPUBackend::DIRECT3D11)
|
||||
return false;
|
||||
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||
if (validate) {
|
||||
if (backend == GPUBackend::DIRECT3D11 && !DoesVersionMatchWindows(6, 0, 0, 0, true))
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (backend == GPUBackend::DIRECT3D11 || backend == GPUBackend::DIRECT3D9)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if !PPSSPP_API(ANY_GL)
|
||||
if (backend == GPUBackend::OPENGL)
|
||||
return false;
|
||||
#endif
|
||||
#if !PPSSPP_PLATFORM(IOS)
|
||||
if (validate) {
|
||||
if (backend == GPUBackend::VULKAN && !VulkanMayBeAvailable())
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool DefaultVertexCache() {
|
||||
return DefaultGPUBackend() == (int)GPUBackend::OPENGL;
|
||||
}
|
||||
@ -599,6 +650,7 @@ static ConfigSetting graphicsSettings[] = {
|
||||
ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0, true, true),
|
||||
ReportedConfigSetting("GraphicsBackend", &g_Config.iGPUBackend, &DefaultGPUBackend),
|
||||
ConfigSetting("FailedGraphicsBackends", &g_Config.sFailedGPUBackends, ""),
|
||||
ConfigSetting("DisabledGraphicsBackends", &g_Config.sDisabledGPUBackends, ""),
|
||||
ConfigSetting("VulkanDevice", &g_Config.sVulkanDevice, "", true, false),
|
||||
#ifdef _WIN32
|
||||
ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false),
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
|
||||
extern const char *PPSSPP_GIT_VERSION;
|
||||
|
||||
@ -124,6 +125,7 @@ public:
|
||||
// GFX
|
||||
int iGPUBackend;
|
||||
std::string sFailedGPUBackends;
|
||||
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.
|
||||
std::string sVulkanDevice;
|
||||
@ -441,6 +443,7 @@ public:
|
||||
|
||||
bool IsPortrait() const;
|
||||
int NextValidBackend();
|
||||
bool IsBackendEnabled(GPUBackend backend, bool validate = true);
|
||||
|
||||
protected:
|
||||
void LoadStandardControllerIni();
|
||||
|
@ -68,8 +68,6 @@
|
||||
#include "Windows/W32Util/ShellUtil.h"
|
||||
#endif
|
||||
|
||||
extern bool VulkanMayBeAvailable();
|
||||
|
||||
GameSettingsScreen::GameSettingsScreen(std::string gamePath, std::string gameID, bool editThenRestore)
|
||||
: UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), enableReports_(false), editThenRestore_(editThenRestore) {
|
||||
lastVertical_ = UseVerticalLayout();
|
||||
@ -199,26 +197,17 @@ void GameSettingsScreen::CreateViews() {
|
||||
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), gr->GetName(), screenManager()));
|
||||
renderingBackendChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingBackend);
|
||||
#if !PPSSPP_PLATFORM(WINDOWS)
|
||||
renderingBackendChoice->HideChoice(1); // D3D9
|
||||
renderingBackendChoice->HideChoice(2); // D3D11
|
||||
#else
|
||||
#if !PPSSPP_API(ANY_GL)
|
||||
renderingBackendChoice->HideChoice(0); // OpenGL
|
||||
#endif
|
||||
if (!DoesVersionMatchWindows(6, 0, 0, 0, true)) {
|
||||
// Hide the D3D11 choice if Windows version is older than Windows Vista.
|
||||
renderingBackendChoice->HideChoice(2); // D3D11
|
||||
}
|
||||
#endif
|
||||
bool vulkanAvailable = false;
|
||||
#ifndef IOS
|
||||
vulkanAvailable = VulkanMayBeAvailable();
|
||||
#endif
|
||||
if (!vulkanAvailable) {
|
||||
renderingBackendChoice->HideChoice(3);
|
||||
}
|
||||
|
||||
if (!g_Config.IsBackendEnabled(GPUBackend::OPENGL))
|
||||
renderingBackendChoice->HideChoice((int)GPUBackend::OPENGL);
|
||||
if (!g_Config.IsBackendEnabled(GPUBackend::DIRECT3D9))
|
||||
renderingBackendChoice->HideChoice((int)GPUBackend::DIRECT3D9);
|
||||
if (!g_Config.IsBackendEnabled(GPUBackend::DIRECT3D11))
|
||||
renderingBackendChoice->HideChoice((int)GPUBackend::DIRECT3D11);
|
||||
if (!g_Config.IsBackendEnabled(GPUBackend::VULKAN))
|
||||
renderingBackendChoice->HideChoice((int)GPUBackend::VULKAN);
|
||||
#endif
|
||||
|
||||
Draw::DrawContext *draw = screenManager()->getDrawContext();
|
||||
|
||||
// Backends that don't allow a device choice will only expose one device.
|
||||
|
@ -1290,14 +1290,11 @@ namespace MainWindow {
|
||||
CheckMenuItem(menu, savestateSlot[i], MF_BYCOMMAND | ((i == g_Config.iCurrentStateSlot) ? MF_CHECKED : MF_UNCHECKED));
|
||||
}
|
||||
|
||||
bool allowD3D11 = DoesVersionMatchWindows(6, 0, 0, 0, true);
|
||||
bool allowVulkan = VulkanMayBeAvailable();
|
||||
bool allowD3D9 = g_Config.IsBackendEnabled(GPUBackend::DIRECT3D9);
|
||||
bool allowD3D11 = g_Config.IsBackendEnabled(GPUBackend::DIRECT3D11);
|
||||
bool allowOpenGL = g_Config.IsBackendEnabled(GPUBackend::OPENGL);
|
||||
bool allowVulkan = g_Config.IsBackendEnabled(GPUBackend::VULKAN);
|
||||
|
||||
#if PPSSPP_API(ANY_GL)
|
||||
bool allowOpenGL = true;
|
||||
#else
|
||||
bool allowOpenGL = false;
|
||||
#endif
|
||||
switch (GetGPUBackend()) {
|
||||
case GPUBackend::DIRECT3D9:
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_GRAYED);
|
||||
@ -1310,7 +1307,7 @@ namespace MainWindow {
|
||||
CheckMenuItem(menu, ID_OPTIONS_VULKAN, MF_UNCHECKED);
|
||||
break;
|
||||
case GPUBackend::OPENGL:
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_ENABLED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, allowD3D9 ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, allowD3D11 ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_OPENGL, MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_VULKAN, allowVulkan ? MF_ENABLED : MF_GRAYED);
|
||||
@ -1320,7 +1317,7 @@ namespace MainWindow {
|
||||
CheckMenuItem(menu, ID_OPTIONS_VULKAN, MF_UNCHECKED);
|
||||
break;
|
||||
case GPUBackend::VULKAN:
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_ENABLED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, allowD3D9 ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, allowD3D11 ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_OPENGL, allowOpenGL ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_VULKAN, MF_GRAYED);
|
||||
@ -1330,7 +1327,7 @@ namespace MainWindow {
|
||||
CheckMenuItem(menu, ID_OPTIONS_VULKAN, MF_CHECKED);
|
||||
break;
|
||||
case GPUBackend::DIRECT3D11:
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, MF_ENABLED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D9, allowD3D9 ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_DIRECT3D11, MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_OPENGL, allowOpenGL ? MF_ENABLED : MF_GRAYED);
|
||||
EnableMenuItem(menu, ID_OPTIONS_VULKAN, allowVulkan ? MF_ENABLED : MF_GRAYED);
|
||||
|
@ -572,7 +572,9 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
|
||||
#ifndef _DEBUG
|
||||
// See #11719 - too many Vulkan drivers crash on basic init.
|
||||
VulkanSetAvailable(DetectVulkanInExternalProcess());
|
||||
if (g_Config.IsBackendEnabled(GPUBackend::VULKAN)) {
|
||||
VulkanSetAvailable(DetectVulkanInExternalProcess());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (iCmdShow == SW_MAXIMIZE) {
|
||||
|
Loading…
Reference in New Issue
Block a user