mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #10672 from hrydgard/android-gfx-fixes
Android: Fix fallback from Vulkan to GL.
This commit is contained in:
commit
a0612f4c87
4 changed files with 28 additions and 17 deletions
|
@ -72,12 +72,15 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL Vulkan_Dbg(VkDebugReportFlagsEXT msgFlags,
|
|||
return false;
|
||||
}
|
||||
|
||||
AndroidVulkanContext::AndroidVulkanContext() {
|
||||
}
|
||||
|
||||
AndroidVulkanContext::~AndroidVulkanContext() {
|
||||
delete g_Vulkan;
|
||||
g_Vulkan = nullptr;
|
||||
}
|
||||
|
||||
bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) {
|
||||
bool AndroidVulkanContext::InitAPI() {
|
||||
ILOG("AndroidVulkanContext::Init");
|
||||
init_glslang();
|
||||
|
||||
|
@ -124,6 +127,10 @@ bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredB
|
|||
g_Vulkan = nullptr;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) {
|
||||
int width = desiredBackbufferSizeX;
|
||||
int height = desiredBackbufferSizeY;
|
||||
if (!width || !height) {
|
||||
|
|
|
@ -8,9 +8,11 @@ class VulkanContext;
|
|||
|
||||
class AndroidVulkanContext : public AndroidGraphicsContext {
|
||||
public:
|
||||
AndroidVulkanContext() : draw_(nullptr) {}
|
||||
AndroidVulkanContext();
|
||||
~AndroidVulkanContext();
|
||||
|
||||
bool InitAPI();
|
||||
|
||||
bool InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) override;
|
||||
void Shutdown() override;
|
||||
void SwapInterval(int interval) override;
|
||||
|
|
|
@ -431,25 +431,33 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
|||
NativeInit(2, argv, user_data_path.c_str(), externalDir.c_str(), cacheDir.c_str());
|
||||
}
|
||||
|
||||
// Now that we've loaded config, set javaGL.
|
||||
javaGL = NativeQueryConfig("androidJavaGL") == "true";
|
||||
|
||||
retry:
|
||||
// Now that we've loaded config, set javaGL.
|
||||
javaGL = NativeQueryConfig("androidJavaGL") == "true";
|
||||
switch (g_Config.iGPUBackend) {
|
||||
case (int)GPUBackend::OPENGL:
|
||||
ILOG("NativeApp.init() -- creating OpenGL context");
|
||||
useCPUThread = true;
|
||||
if (javaGL) {
|
||||
graphicsContext = new AndroidJavaEGLGraphicsContext();
|
||||
} else {
|
||||
graphicsContext = new AndroidEGLGraphicsContext();
|
||||
}
|
||||
_assert_(javaGL);
|
||||
ILOG("NativeApp.init() -- creating OpenGL context (JavaGL)");
|
||||
graphicsContext = new AndroidJavaEGLGraphicsContext();
|
||||
break;
|
||||
case (int)GPUBackend::VULKAN:
|
||||
{
|
||||
ILOG("NativeApp.init() -- creating Vulkan context");
|
||||
useCPUThread = false; // The Vulkan render manager manages its own thread.
|
||||
// We create and destroy the Vulkan graphics context in the "EGL" thread.
|
||||
AndroidVulkanContext *ctx = new AndroidVulkanContext();
|
||||
if (!ctx->InitAPI()) {
|
||||
ILOG("Failed to initialize Vulkan, switching to OpenGL");
|
||||
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
goto retry;
|
||||
} else {
|
||||
graphicsContext = ctx;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ELOG("NativeApp.init(): iGPUBackend %d not supported. Switching to OpenGL.", (int)g_Config.iGPUBackend);
|
||||
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
|
||||
|
@ -931,12 +939,6 @@ retry:
|
|||
|
||||
int tries = 0;
|
||||
|
||||
_assert_msg_(G3D, !graphicsContext, "Graphics context already exists entering runEGLRenderLoop - this is wrong.");
|
||||
|
||||
if (vulkan) {
|
||||
graphicsContext = new AndroidVulkanContext();
|
||||
}
|
||||
|
||||
if (!graphicsContext->InitFromRenderThread(wnd, desiredBackbufferSizeX, desiredBackbufferSizeY, backbuffer_format, androidVersion)) {
|
||||
ELOG("Failed to initialize graphics context.");
|
||||
|
||||
|
|
|
@ -482,7 +482,7 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
|||
gainAudioFocus(this.audioManager, this.audioFocusChangeListener);
|
||||
NativeApp.audioInit();
|
||||
|
||||
if (javaGL) {
|
||||
if (javaGL) {
|
||||
mGLSurfaceView = new NativeGLView(this);
|
||||
nativeRenderer = new NativeRenderer(this);
|
||||
mGLSurfaceView.setEGLContextClientVersion(2);
|
||||
|
|
Loading…
Add table
Reference in a new issue