mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Use the common EmuThread implementation on iOS as well
This commit is contained in:
1 parent
d0c6362a21
commit
568ffe5a05
3 files changed
+10
-66
No files matched your search
@@ -163,16 +163,6 @@ bool GLRenderManager::ThreadFrame(bool waitIfEmpty) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLRenderManager::StartThread() {
|
||||
// There's not really a lot to do here anymore.
|
||||
INFO_LOG(Log::G3D, "GLRenderManager::StartThread()");
|
||||
if (!runCompileThread_) {
|
||||
runCompileThread_ = true;
|
||||
} else {
|
||||
INFO_LOG(Log::G3D, "GL submission thread was already running.");
|
||||
}
|
||||
}
|
||||
|
||||
std::string GLRenderManager::GetGpuProfileString() const {
|
||||
int curFrame = curFrame_;
|
||||
const GLQueueProfileContext &profile = frameData_[curFrame].profile;
|
||||
|
||||
@@ -823,8 +823,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void StartThread(); // Currently only used on iOS, since we fully recreate the context on Android
|
||||
|
||||
// Only supports a common subset.
|
||||
std::string GetGLString(int name) const {
|
||||
return queueRunner_.GetGLString(name);
|
||||
|
||||
+10
-54
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/EmuThread.h"
|
||||
#include "Core/KeyMap.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
@@ -95,10 +96,6 @@ public:
|
||||
renderManager_->ThreadEnd();
|
||||
}
|
||||
|
||||
void StartThread() {
|
||||
renderManager_->StartThread();
|
||||
}
|
||||
|
||||
protected:
|
||||
void BeginShutdown() {
|
||||
renderManager_->SetSkipGLCalls();
|
||||
@@ -109,9 +106,8 @@ private:
|
||||
GLRenderManager *renderManager_;
|
||||
};
|
||||
|
||||
static std::atomic<bool> exitRenderLoop;
|
||||
static std::atomic<bool> renderLoopRunning;
|
||||
static std::thread g_renderLoopThread;
|
||||
static std::thread g_emuThread;
|
||||
|
||||
PPSSPPBaseViewController *sharedViewController;
|
||||
|
||||
@@ -141,61 +137,25 @@ PPSSPPBaseViewController *sharedViewController;
|
||||
return self;
|
||||
}
|
||||
|
||||
// The actual rendering is NOT on this thread, this is the emu thread
|
||||
// that runs game logic.
|
||||
void GLRenderLoop(IOSGLESContext *graphicsContext) {
|
||||
SetCurrentThreadName("EmuThreadGL");
|
||||
renderLoopRunning = true;
|
||||
|
||||
NativeInitGraphics(graphicsContext);
|
||||
|
||||
INFO_LOG(Log::System, "Emulation thread starting\n");
|
||||
while (!exitRenderLoop) {
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
|
||||
INFO_LOG(Log::System, "Emulation thread shutting down\n");
|
||||
NativeShutdownGraphics(graphicsContext);
|
||||
|
||||
// Also ask the main thread to stop, so it doesn't hang waiting for a new frame.
|
||||
INFO_LOG(Log::System, "Emulation thread stopping\n");
|
||||
|
||||
exitRenderLoop = false;
|
||||
renderLoopRunning = false;
|
||||
}
|
||||
|
||||
- (bool)runGLRenderLoop {
|
||||
if (!graphicsContext) {
|
||||
ERROR_LOG(Log::G3D, "runVulkanRenderLoop: Tried to enter without a created graphics context.");
|
||||
ERROR_LOG(Log::G3D, "runGLRenderLoop: Tried to enter without a created graphics context.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (g_renderLoopThread.joinable()) {
|
||||
ERROR_LOG(Log::G3D, "runVulkanRenderLoop: Already running");
|
||||
if (g_emuThread.joinable()) {
|
||||
ERROR_LOG(Log::G3D, "runGLRenderLoop: Already running");
|
||||
return false;
|
||||
}
|
||||
|
||||
_dbg_assert_(!renderLoopRunning);
|
||||
_dbg_assert_(!exitRenderLoop);
|
||||
|
||||
graphicsContext->StartThread();
|
||||
|
||||
g_renderLoopThread = std::thread(GLRenderLoop, graphicsContext);
|
||||
g_emuThread = EmuThread_Start(graphicsContext, new NativeApplication(), [](){});
|
||||
return true;
|
||||
}
|
||||
|
||||
- (void)requestExitGLRenderLoop {
|
||||
if (!renderLoopRunning) {
|
||||
ERROR_LOG(Log::System, "Render loop already exited");
|
||||
return;
|
||||
}
|
||||
_assert_(g_renderLoopThread.joinable());
|
||||
exitRenderLoop = true;
|
||||
graphicsContext->ThreadFrameUntilCondition([]() -> bool {
|
||||
return !renderLoopRunning.load();
|
||||
});
|
||||
g_renderLoopThread.join();
|
||||
_assert_(!g_renderLoopThread.joinable());
|
||||
_assert_(g_emuThread.joinable());
|
||||
EmuThread_Join(graphicsContext, g_emuThread);
|
||||
_assert_(!g_emuThread.joinable());
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
@@ -325,7 +285,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
|
||||
}
|
||||
|
||||
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
|
||||
if (!renderLoopRunning) {
|
||||
if (!g_emuThread.joinable()) {
|
||||
INFO_LOG(Log::G3D, "Ignoring drawInRect");
|
||||
return;
|
||||
}
|
||||
@@ -374,10 +334,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
// Skipping GL calls here because the old context is lost.
|
||||
graphicsContext->ThreadFrameUntilCondition([]() -> bool {
|
||||
return !renderLoopRunning;
|
||||
});
|
||||
graphicsContext->ShutdownSurface();
|
||||
graphicsContext->ShutdownAPI();
|
||||
delete graphicsContext;
|
||||
|
||||
Reference in new issue
Block a user