Android: Fallback to OpenGL if Vulkan fails to init.

This commit is contained in:
Henrik Rydgård 2017-05-30 10:25:53 +02:00
parent c109f849e0
commit d21a1f8813

View File

@ -39,6 +39,7 @@
#include "thin3d/thin3d.h"
#include "Core/Config.h"
#include "Core/Loaders.h"
#include "Core/System.h"
#include "Common/CPUDetect.h"
#include "Common/GraphicsContext.h"
#include "Common/GL/GLInterfaceBase.h"
@ -1012,8 +1013,11 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
return false;
}
retry:
bool vulkan = g_Config.iGPUBackend == GPU_BACKEND_VULKAN;
int tries = 0;
AndroidGraphicsContext *graphicsContext;
if (vulkan) {
graphicsContext = new AndroidVulkanContext();
@ -1023,6 +1027,15 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
if (!graphicsContext->Init(wnd, desiredBackbufferSizeX, desiredBackbufferSizeY, backbuffer_format, androidVersion)) {
ELOG("Failed to initialize graphics context.");
if (vulkan && tries < 2) {
ILOG("Trying again, this time with OpenGL.");
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
SetGPUBackend((GPUBackend)g_Config.iGPUBackend); // Wait, why do we need a separate enum here?
tries++;
goto retry;
}
delete graphicsContext;
return false;
}