mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
made savestates synchronous and immediate. this allows saving or loading while the emulator is paused, fixes issues where savestate hotkeys would get ignored if pressed too close together, might speed up savestates in some cases, and hopefully makes savestates more stable too.
the intent is to replace the haphazard scheduling and finger-crossing associated with saving/loading with the correct and minimal necessary wait for each thread to reach a known safe location before commencing the savestate operation, and for any already-paused components to not need to be resumed to do so.
This commit is contained in:
@ -169,8 +169,7 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32
|
||||
return 0;
|
||||
}
|
||||
|
||||
static volatile u32 s_doStateRequested = false;
|
||||
|
||||
|
||||
void VideoBackendHardware::InitializeShared()
|
||||
{
|
||||
VideoCommon_Init();
|
||||
@ -183,52 +182,29 @@ void VideoBackendHardware::InitializeShared()
|
||||
s_AccessEFBResult = 0;
|
||||
}
|
||||
|
||||
static volatile struct
|
||||
{
|
||||
unsigned char **ptr;
|
||||
int mode;
|
||||
} s_doStateArgs;
|
||||
|
||||
// Depending on the threading mode (DC/SC) this can be called
|
||||
// from either the GPU thread or the CPU thread
|
||||
void VideoFifo_CheckStateRequest()
|
||||
{
|
||||
if (Common::AtomicLoadAcquire(s_doStateRequested))
|
||||
{
|
||||
// Clear all caches that touch RAM
|
||||
TextureCache::Invalidate(false);
|
||||
VertexLoaderManager::MarkAllDirty();
|
||||
|
||||
PointerWrap p(s_doStateArgs.ptr, s_doStateArgs.mode);
|
||||
VideoCommon_DoState(p);
|
||||
|
||||
// Refresh state.
|
||||
if (s_doStateArgs.mode == PointerWrap::MODE_READ)
|
||||
{
|
||||
BPReload();
|
||||
RecomputeCachedArraybases();
|
||||
}
|
||||
|
||||
Common::AtomicStoreRelease(s_doStateRequested, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Run from the CPU thread
|
||||
void VideoBackendHardware::DoState(PointerWrap& p)
|
||||
{
|
||||
s_doStateArgs.ptr = p.ptr;
|
||||
s_doStateArgs.mode = p.mode;
|
||||
Common::AtomicStoreRelease(s_doStateRequested, true);
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
|
||||
// Clear all caches that touch RAM
|
||||
TextureCache::Invalidate(false);
|
||||
VertexLoaderManager::MarkAllDirty();
|
||||
|
||||
VideoCommon_DoState(p);
|
||||
|
||||
// Refresh state.
|
||||
if (p.GetMode() == PointerWrap::MODE_READ)
|
||||
{
|
||||
while (Common::AtomicLoadAcquire(s_doStateRequested) && !s_FifoShuttingDown)
|
||||
//Common::SleepCurrentThread(1);
|
||||
Common::YieldCPU();
|
||||
BPReload();
|
||||
RecomputeCachedArraybases();
|
||||
}
|
||||
else
|
||||
VideoFifo_CheckStateRequest();
|
||||
}
|
||||
|
||||
void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
||||
{
|
||||
Fifo_PauseAndLock(doLock, unpauseOnUnlock);
|
||||
}
|
||||
|
||||
|
||||
void VideoBackendHardware::RunLoop(bool enable)
|
||||
{
|
||||
VideoCommon_RunLoop(enable);
|
||||
|
Reference in New Issue
Block a user