Treat savestates specially, no longer using events.

This makes it easier to run them on the GPU thread anyway, which is best
if they reset GPU caches etc., and should remove any timing related
issues.
This commit is contained in:
Unknown W. Brackets 2013-08-06 23:00:20 -07:00
parent 7a2ef728cb
commit dc56ab9e83
3 changed files with 13 additions and 18 deletions

View File

@ -60,23 +60,15 @@ namespace SaveState
void *cbUserData;
};
static int timer;
static bool needsProcess = false;
static std::vector<Operation> pending;
static std::recursive_mutex mutex;
void Process(u64 userdata, int cyclesLate);
void SaveStart::DoState(PointerWrap &p)
{
// Gotta do CoreTiming first since we'll restore into it.
CoreTiming::DoState(p);
// This save state even saves its own state.
p.Do(timer);
CoreTiming::RestoreRegisterEvent(timer, "SaveState", Process);
p.DoMarker("SaveState");
Memory::DoState(p);
MemoryStick_DoState(p);
currentMIPS->DoState(p);
@ -96,10 +88,8 @@ namespace SaveState
if (Core_IsInactive() && __KernelIsRunning())
{
// Warning: this may run on a different thread.
Process(0, 0);
Process();
}
else if (__KernelIsRunning())
CoreTiming::ScheduleEvent_Threadsafe(0, timer);
else
needsProcess = true;
}
@ -210,8 +200,12 @@ namespace SaveState
return copy;
}
void Process(u64 userdata, int cyclesLate)
void Process()
{
if (!needsProcess)
return;
needsProcess = false;
if (!__KernelIsRunning())
{
ERROR_LOG(COMMON, "Savestate failure: Unable to load without kernel, this should never happen.");
@ -272,15 +266,9 @@ namespace SaveState
void Init()
{
timer = CoreTiming::RegisterEvent("SaveState", Process);
// Make sure there's a directory for save slots
pspFileSystem.MkDir("ms0:/PSP/PPSSPP_STATE");
std::lock_guard<std::recursive_mutex> guard(mutex);
if (needsProcess)
{
CoreTiming::ScheduleEvent(0, timer);
needsProcess = false;
}
}
}

View File

@ -31,7 +31,9 @@ namespace SaveState
void SaveSlot(int slot, Callback callback, void *cbUserData = 0);
void LoadSlot(int slot, Callback callback, void *cbUserData = 0);
// Checks whether there's an existing save in the specified slot.
bool HasSaveInSlot(int slot);
// Returns -1 if there's no newest slot.
int GetNewestSlot();
// Load the specified file into the current state (async.)
@ -45,4 +47,7 @@ namespace SaveState
// For testing / automated tests. Runs a save state verification pass (async.)
// Warning: callback will be called on a different thread.
void Verify(Callback callback = 0, void *cbUserData = 0);
// Check if there's any save stating needing to be done. Normally called once per frame.
void Process();
};

View File

@ -38,6 +38,7 @@
#include "Core/Loaders.h"
#include "Core/PSPLoaders.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/SaveState.h"
#include "Common/LogManager.h"
MetaFileSystem pspFileSystem;
@ -151,6 +152,7 @@ void PSP_Shutdown()
}
void PSP_RunLoopUntil(u64 globalticks) {
SaveState::Process();
mipsr4k.RunLoopUntil(globalticks);
}