From 8c022d56be36599ce8c2a68ed00149bdc937d6fe Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 09:34:20 -0700 Subject: [PATCH 1/3] Support non-pfat0 savestates, slightly hacky... --- Core/FileSystems/MetaFileSystem.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index e5d8b5c0d2..a6fa2330d7 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -515,14 +515,22 @@ void MetaFileSystem::DoState(PointerWrap &p) u32 n = (u32) fileSystems.size(); p.Do(n); + bool skipPfat0 = false; if (n != (u32) fileSystems.size()) { - p.SetError(p.ERROR_FAILURE); - ERROR_LOG(FILESYS, "Savestate failure: number of filesystems doesn't match."); - return; + if (n == (u32) fileSystems.size() - 1) { + skipPfat0 = true; + } else { + p.SetError(p.ERROR_FAILURE); + ERROR_LOG(FILESYS, "Savestate failure: number of filesystems doesn't match."); + return; + } } - for (u32 i = 0; i < n; ++i) - fileSystems[i].system->DoState(p); + for (u32 i = 0; i < n; ++i) { + if (!skipPfat0 || fileSystems[i].prefix != "pfat0:") { + fileSystems[i].system->DoState(p); + } + } } From 9cbb1cb8d34056ae17007304447a1f9e9727039f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 09:34:54 -0700 Subject: [PATCH 2/3] Warning fix. --- GPU/GLES/Framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index c273301641..cfa91d69f5 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -193,7 +193,7 @@ void FramebufferManager::CompileDraw2DProgram() { // user shader experiments. ERROR_LOG(G3D, "Failed to build post-processing program from %s and %s!\n%s", shaderInfo->vertexShaderFile.c_str(), shaderInfo->fragmentShaderFile.c_str(), errorString.c_str()); // let's show the first line of the error string as an OSM. - for (int i = 0; i < errorString.size(); i++) { + for (size_t i = 0; i < errorString.size(); i++) { if (errorString[i] == '\n') { errorString = errorString.substr(0, i); break; From 479a9801d44ddd344181295d95923ee99397eb0c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 09:35:02 -0700 Subject: [PATCH 3/3] Shutdown issues: the legend continues. If the gpu was slow (softgpu for example), it might still be accessing memory. Need to let it wake, and ignoring coreState too. --- Core/System.cpp | 4 ++++ Core/ThreadEventQueue.h | 5 +++-- GPU/GPUInterface.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index 66557b25b1..e58a7a1989 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -257,6 +257,10 @@ void CPU_RunLoop() { coreState = CORE_POWERDOWN; } + // Let's make sure the gpu has already cleaned up before we start freeing memory. + gpu->FinishEventLoop(); + gpu->SyncThread(true); + CPU_Shutdown(); CPU_SetState(CPU_THREAD_NOT_RUNNING); } diff --git a/Core/ThreadEventQueue.h b/Core/ThreadEventQueue.h index 0416e8275c..03d84b9c14 100644 --- a/Core/ThreadEventQueue.h +++ b/Core/ThreadEventQueue.h @@ -89,7 +89,8 @@ struct ThreadEventQueue : public B { } while (CoreTiming::GetTicks() < globalticks); } - void SyncThread() { + // Force ignores coreState. + void SyncThread(bool force = false) { if (!threadEnabled_) { return; } @@ -98,7 +99,7 @@ struct ThreadEventQueue : public B { // While processing the last event, HasEvents() will be false even while not done. // So we schedule a nothing event and wait for that to finish. ScheduleEvent(EVENT_SYNC); - while (HasEvents() && coreState == CORE_RUNNING) { + while (HasEvents() && (force || coreState == CORE_RUNNING)) { eventsDrain_.wait_for(eventsLock_, 1); } } diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index eb46ad713e..c7a515c718 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -231,7 +231,7 @@ public: virtual void DeviceLost() = 0; virtual void ReapplyGfxState() = 0; - virtual void SyncThread() = 0; + virtual void SyncThread(bool force = false) = 0; virtual u64 GetTickEstimate() = 0; virtual void DoState(PointerWrap &p) = 0;