SaveState: Delay restart handling until end frame.

Otherwise, we end up having unmatched pushbuffer map/unmap.
This commit is contained in:
Unknown W. Brackets 2021-02-21 08:18:13 -08:00
parent e326971a96
commit 8c655750fe
3 changed files with 24 additions and 11 deletions

View File

@ -248,6 +248,7 @@ namespace SaveState
};
static bool needsProcess = false;
static bool needsRestart = false;
static std::vector<Operation> pending;
static std::mutex mutex;
static int screenshotFailures = 0;
@ -662,17 +663,9 @@ namespace SaveState
}
// We tried, our only remaining option is to reset the game.
PSP_Shutdown();
std::string resetError;
if (!PSP_Init(PSP_CoreParameter(), &resetError))
{
ERROR_LOG(BOOT, "Error resetting: %s", resetError.c_str());
// TODO: This probably doesn't clean up well enough.
Core_Stop();
return false;
}
host->BootDone();
host->UpdateDisassembly();
needsRestart = true;
// Make sure we don't proceed to run anything yet.
coreState = CORE_NEXTFRAME;
return false;
}
@ -899,6 +892,22 @@ namespace SaveState
}
}
void Cleanup() {
if (needsRestart) {
PSP_Shutdown();
std::string resetError;
if (!PSP_Init(PSP_CoreParameter(), &resetError)) {
ERROR_LOG(BOOT, "Error resetting: %s", resetError.c_str());
// TODO: This probably doesn't clean up well enough.
Core_Stop();
return;
}
host->BootDone();
host->UpdateDisassembly();
needsRestart = false;
}
}
void Init()
{
// Make sure there's a directory for save slots

View File

@ -93,4 +93,7 @@ namespace SaveState
// Check if there's any save stating needing to be done. Normally called once per frame.
void Process();
// Cleanup by triggering a restart if needed.
void Cleanup();
};

View File

@ -525,6 +525,7 @@ void PSP_EndHostFrame() {
if (gpu) {
gpu->EndHostFrame();
}
SaveState::Cleanup();
}
void PSP_RunLoopWhileState() {