mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Android work. Make the Android OpenGL exit prodecure make more sense
This commit is contained in:
parent
b62572a78f
commit
2659fd6f66
@ -189,14 +189,18 @@ void GLRenderManager::ThreadEnd() {
|
||||
}
|
||||
|
||||
// Unlike in Vulkan, this isn't a full independent function, instead it gets called every frame.
|
||||
// This also mean that we can poll the renderThreadQueue using a regular mutex, instead of
|
||||
// This also mean that we have to poll the renderThreadQueue using a regular mutex, instead of
|
||||
// blocking on it using a condition variable.
|
||||
// Returns true if it did anything. False means the queue was empty.
|
||||
bool GLRenderManager::ThreadFrame() {
|
||||
if (!run_)
|
||||
if (!run_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GLRRenderThreadTask task;
|
||||
|
||||
bool didAnything = false;
|
||||
|
||||
// In case of syncs or other partial completion, we keep going until we complete a frame.
|
||||
while (true) {
|
||||
// Pop a task of the queue and execute it.
|
||||
@ -209,6 +213,8 @@ bool GLRenderManager::ThreadFrame() {
|
||||
renderThreadQueue_.pop();
|
||||
}
|
||||
|
||||
didAnything = true;
|
||||
|
||||
// We got a task! We can now have pushMutex_ unlocked, allowing the host to
|
||||
// push more work when it feels like it, and just start working.
|
||||
if (task.runType == GLRRunType::EXIT) {
|
||||
@ -224,7 +230,7 @@ bool GLRenderManager::ThreadFrame() {
|
||||
Run(task);
|
||||
};
|
||||
|
||||
return true;
|
||||
return didAnything;
|
||||
}
|
||||
|
||||
void GLRenderManager::StopThread() {
|
||||
@ -233,7 +239,7 @@ void GLRenderManager::StopThread() {
|
||||
if (run_) {
|
||||
run_ = false;
|
||||
} else {
|
||||
INFO_LOG(G3D, "GL submission thread was already paused.");
|
||||
WARN_LOG(G3D, "GL submission thread was already paused.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ public:
|
||||
|
||||
void ThreadStart(Draw::DrawContext *draw);
|
||||
void ThreadEnd();
|
||||
bool ThreadFrame(); // Returns false to request exiting the loop.
|
||||
bool ThreadFrame(); // Returns true if it did anything. False means the queue was empty.
|
||||
|
||||
void SetErrorCallback(ErrorCallbackFn callback, void *userdata) {
|
||||
queueRunner_.SetErrorCallback(callback, userdata);
|
||||
@ -433,6 +433,11 @@ public:
|
||||
void Finish();
|
||||
void Run(GLRRenderThreadTask &task);
|
||||
|
||||
void WaitUntilQueueIdle() {
|
||||
// Don't think this needs to do anything anymore, at least not if called
|
||||
// from render thread.
|
||||
}
|
||||
|
||||
// Creation commands. These were not needed in Vulkan since there we can do that on the main thread.
|
||||
// We pass in width/height here even though it's not strictly needed until we support glTextureStorage
|
||||
// and then we'll also need formats and stuff.
|
||||
|
@ -233,16 +233,14 @@ void Shutdown()
|
||||
ClearPendingEvents();
|
||||
UnregisterAllEvents();
|
||||
|
||||
while(eventPool)
|
||||
{
|
||||
while (eventPool) {
|
||||
Event *ev = eventPool;
|
||||
eventPool = ev->next;
|
||||
delete ev;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lk(externalEventLock);
|
||||
while(eventTsPool)
|
||||
{
|
||||
while (eventTsPool) {
|
||||
Event *ev = eventTsPool;
|
||||
eventTsPool = ev->next;
|
||||
delete ev;
|
||||
@ -251,7 +249,12 @@ void Shutdown()
|
||||
|
||||
u64 GetTicks()
|
||||
{
|
||||
return (u64)globalTimer + slicelength - currentMIPS->downcount;
|
||||
if (currentMIPS) {
|
||||
return (u64)globalTimer + slicelength - currentMIPS->downcount;
|
||||
} else {
|
||||
// Reporting can actually end up here during weird task switching sequences on Android
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
u64 GetIdleTicks()
|
||||
|
@ -335,7 +335,7 @@ static void EmuThreadFunc() {
|
||||
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
|
||||
UpdateRunLoopAndroid(env);
|
||||
}
|
||||
INFO_LOG(SYSTEM, "QUIT_REQUESTED found, left loop. Setting state to STOPPED.");
|
||||
INFO_LOG(SYSTEM, "QUIT_REQUESTED found, left EmuThreadFunc loop. Setting state to STOPPED.");
|
||||
emuThreadState = (int)EmuThreadState::STOPPED;
|
||||
|
||||
NativeShutdownGraphics();
|
||||
@ -868,14 +868,13 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) {
|
||||
EmuThreadStop("shutdown");
|
||||
INFO_LOG(SYSTEM, "BeginAndroidShutdown");
|
||||
graphicsContext->BeginAndroidShutdown();
|
||||
// Skipping GL calls, the old context is gone.
|
||||
INFO_LOG(SYSTEM, "Joining emuthread");
|
||||
EmuThreadJoin();
|
||||
// Now, it could be that we had some frames queued up. Get through them.
|
||||
// We're on the render thread, so this is synchronous.
|
||||
while (graphicsContext->ThreadFrame()) {
|
||||
INFO_LOG(SYSTEM, "graphicsContext->ThreadFrame executed to clear buffers");
|
||||
}
|
||||
INFO_LOG(SYSTEM, "Joining emuthread");
|
||||
EmuThreadJoin();
|
||||
INFO_LOG(SYSTEM, "Joined emuthread");
|
||||
|
||||
graphicsContext->ThreadEnd();
|
||||
graphicsContext->ShutdownFromRenderThread();
|
||||
INFO_LOG(SYSTEM, "Graphics context now shut down from NativeApp_shutdown");
|
||||
|
Loading…
Reference in New Issue
Block a user