diff options
| author | nitsuja <nitsuja-@hotmail.com> | 2011-12-30 20:16:12 -0800 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2012-05-26 13:09:38 +1000 |
| commit | a81631b58e3a77f8d088c574fc048f3fb37a7c51 (patch) | |
| tree | 6f3f0e1a37d219e4d0132c9754f555b5640aa91f /Source/Core/VideoCommon/Src/MainBase.cpp | |
| parent | 108f69eaa9c06de8d2df3845a0f70699027183c1 (diff) | |
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.
Diffstat (limited to 'Source/Core/VideoCommon/Src/MainBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/MainBase.cpp | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/Source/Core/VideoCommon/Src/MainBase.cpp b/Source/Core/VideoCommon/Src/MainBase.cpp index 0b1258a662..85fbc3d8e9 100644 --- a/Source/Core/VideoCommon/Src/MainBase.cpp +++ b/Source/Core/VideoCommon/Src/MainBase.cpp @@ -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() +// Run from the CPU thread +void VideoBackendHardware::DoState(PointerWrap& p) { - 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); + // Clear all caches that touch RAM + TextureCache::Invalidate(false); + VertexLoaderManager::MarkAllDirty(); - // Refresh state. - if (s_doStateArgs.mode == PointerWrap::MODE_READ) - { - BPReload(); - RecomputeCachedArraybases(); - } + VideoCommon_DoState(p); - Common::AtomicStoreRelease(s_doStateRequested, false); + // Refresh state. + if (p.GetMode() == PointerWrap::MODE_READ) + { + BPReload(); + RecomputeCachedArraybases(); } } -// Run from the CPU thread -void VideoBackendHardware::DoState(PointerWrap& p) +void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock) { - s_doStateArgs.ptr = p.ptr; - s_doStateArgs.mode = p.mode; - Common::AtomicStoreRelease(s_doStateRequested, true); - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) - { - while (Common::AtomicLoadAcquire(s_doStateRequested) && !s_FifoShuttingDown) - //Common::SleepCurrentThread(1); - Common::YieldCPU(); - } - else - VideoFifo_CheckStateRequest(); + Fifo_PauseAndLock(doLock, unpauseOnUnlock); } + void VideoBackendHardware::RunLoop(bool enable) { VideoCommon_RunLoop(enable); |
