diff --git a/CMakeLists.txt b/CMakeLists.txt index 150e415647..dd029a30b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -913,7 +913,6 @@ if(ANDROID) android/jni/AndroidJavaGLContext.h android/jni/AndroidVulkanContext.cpp android/jni/AndroidVulkanContext.h - android/jni/AndroidGraphicsContext.h android/jni/AndroidAudio.cpp android/jni/AndroidAudio.h android/jni/OpenSLContext.cpp diff --git a/Common/GraphicsContext.h b/Common/GraphicsContext.h index 4f7008cad9..4a9c7c33cd 100644 --- a/Common/GraphicsContext.h +++ b/Common/GraphicsContext.h @@ -16,6 +16,7 @@ public: virtual bool InitFromRenderThread(std::string *errorMessage) { return true; } virtual void ShutdownFromRenderThread() {} + virtual void BeginShutdown() {} // This is currently only used on Android. virtual void Shutdown() = 0; // Used during window resize. Must be called from the window thread, diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index 30914b7727..51494a4b0a 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -728,14 +728,6 @@ - - true - true - true - true - true - true - true true diff --git a/Windows/PPSSPP.vcxproj.filters b/Windows/PPSSPP.vcxproj.filters index 91195aec3a..7a0e7bbf1b 100644 --- a/Windows/PPSSPP.vcxproj.filters +++ b/Windows/PPSSPP.vcxproj.filters @@ -412,9 +412,6 @@ Windows\System - - Other Platforms\Android - Other Platforms\Android diff --git a/android/jni/AndroidGraphicsContext.h b/android/jni/AndroidGraphicsContext.h deleted file mode 100644 index f9191aadbd..0000000000 --- a/android/jni/AndroidGraphicsContext.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include - -#include "Common/GPU/thin3d.h" -#include "Common/GraphicsContext.h" - -enum { - ANDROID_VERSION_GINGERBREAD = 9, - ANDROID_VERSION_ICS = 14, - ANDROID_VERSION_JELLYBEAN = 16, - ANDROID_VERSION_KITKAT = 19, - ANDROID_VERSION_LOLLIPOP = 21, - ANDROID_VERSION_MARSHMALLOW = 23, - ANDROID_VERSION_NOUGAT = 24, - ANDROID_VERSION_NOUGAT_1 = 25, -}; - -class AndroidGraphicsContext : public GraphicsContext { -public: - // This is different than the base class function since on - // Android (EGL, Vulkan) we do have all this info on the render thread. - virtual bool Init(ANativeWindow *wnd) { return true; } - virtual void BeginAndroidShutdown() {} -}; diff --git a/android/jni/AndroidJavaGLContext.h b/android/jni/AndroidJavaGLContext.h index b24ed480e0..bcce18aeba 100644 --- a/android/jni/AndroidJavaGLContext.h +++ b/android/jni/AndroidJavaGLContext.h @@ -1,10 +1,10 @@ #pragma once -#include "AndroidGraphicsContext.h" +#include "Common/GraphicsContext.h" #include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/GPU/thin3d_create.h" -class AndroidJavaEGLGraphicsContext : public AndroidGraphicsContext { +class AndroidJavaEGLGraphicsContext : public GraphicsContext { public: AndroidJavaEGLGraphicsContext(); ~AndroidJavaEGLGraphicsContext() override { delete draw_; } @@ -30,7 +30,7 @@ public: return renderManager_->ThreadFrame(waitIfEmpty); } - void BeginAndroidShutdown() override { + void BeginShutdown() override { renderManager_->SetSkipGLCalls(); } diff --git a/android/jni/AndroidVulkanContext.h b/android/jni/AndroidVulkanContext.h index f83daf9fa7..2400a18b93 100644 --- a/android/jni/AndroidVulkanContext.h +++ b/android/jni/AndroidVulkanContext.h @@ -1,17 +1,20 @@ #pragma once -#include "AndroidGraphicsContext.h" +#include "Common/GraphicsContext.h" +#include "Common/GPU/thin3d.h" + +#include class VulkanContext; -class AndroidVulkanContext : public AndroidGraphicsContext { +class AndroidVulkanContext : public GraphicsContext { public: AndroidVulkanContext(); ~AndroidVulkanContext(); bool InitAPI(); - bool Init(ANativeWindow *wnd) override; + bool Init(ANativeWindow *wnd); void ShutdownFromRenderThread() override; // Inverses InitFromRenderThread. void Shutdown() override; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 512ff66b0b..fe7b427ee4 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -91,7 +91,6 @@ struct JNIEnv {}; #include "Common/StringUtils.h" #include "Common/TimeUtil.h" -#include "AndroidGraphicsContext.h" #include "AndroidVulkanContext.h" #include "AndroidJavaGLContext.h" @@ -190,7 +189,7 @@ static std::string g_installerName; static std::map permissions; -static AndroidGraphicsContext *graphicsContext; +static GraphicsContext *graphicsContext; #define MessageBox(a, b, c, d) __android_log_print(ANDROID_LOG_INFO, APP_NAME, "%s %s", (b), (c)); @@ -963,8 +962,8 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) { // Now we know that more frames won't be coming in. - INFO_LOG(Log::System, "BeginAndroidShutdown"); - graphicsContext->BeginAndroidShutdown(); // Makes sure we don't actually perform draws. + INFO_LOG(Log::System, "BeginShutdown"); + graphicsContext->BeginShutdown(); // Makes sure we don't actually perform draws. // Now, it could be that we had some frames queued up. Get through them. // We're on the render thread, so this is synchronous. @@ -1039,7 +1038,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e INFO_LOG(Log::G3D, "NativeApp.displayInit() restoring"); EmuThreadStop("displayInit"); - graphicsContext->BeginAndroidShutdown(); + graphicsContext->BeginShutdown(); INFO_LOG(Log::G3D, "BeginAndroidShutdown. Looping until emu thread done..."); // Skipping GL calls here because the old context is lost. graphicsContext->ThreadFrameUntilCondition([]() -> bool { @@ -1053,7 +1052,6 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e INFO_LOG(Log::G3D, "Shut down both threads. Now let's bring it up again!"); - std::string errorMessage; if (!graphicsContext->InitFromRenderThread(&errorMessage)) { System_Toast(("Graphics initialization failed: Quitting: " + errorMessage).c_str()); return false; @@ -1699,7 +1697,7 @@ static void ProcessFrameCommands() { std::thread g_renderLoopThread; -static void VulkanEmuThread(ANativeWindow *wnd); +static void VulkanEmuThread(ANativeWindow *wnd, AndroidVulkanContext *graphicsContext); // This runs in Vulkan mode only. // This handles the entire lifecycle of the Vulkan context, init and exit. @@ -1727,7 +1725,7 @@ extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_PpssppActivity_runVulkanRende return false; } - g_renderLoopThread = std::thread(VulkanEmuThread, wnd); + g_renderLoopThread = std::thread(VulkanEmuThread, wnd, (AndroidVulkanContext *)graphicsContext); return true; } @@ -1744,7 +1742,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_PpssppActivity_requestExitVulkanR // TODO: Merge with the Win32 EmuThread and so on, and the Java EmuThread? // This function must release the window reference. -static void VulkanEmuThread(ANativeWindow *wnd) { +static void VulkanEmuThread(ANativeWindow *wnd, AndroidVulkanContext *graphicsContext) { SetCurrentThreadName("EmuThread"); AndroidJNIThreadContext ctx;