diff options
| author | Stenzek <stenzek@gmail.com> | 2019-06-29 18:35:12 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2019-07-24 04:08:25 +1000 |
| commit | b26bb0605b962456720519b273f171919ebfb65d (patch) | |
| tree | 726c68df8d167671bc161c27d59d05532330d896 /Source/Core/VideoCommon/VideoBackendBase.cpp | |
| parent | a25a4e07083d4e20b5be6192892c346c4549ed73 (diff) | |
VideoBackendBase: Do save state logic on the GPU thread
Diffstat (limited to 'Source/Core/VideoCommon/VideoBackendBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VideoBackendBase.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index aa4cd8f6dd..ae628e5ab1 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -40,6 +40,7 @@ #include "VideoCommon/RenderBase.h" #include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/VertexLoaderManager.h" +#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexShaderManager.h" #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" @@ -236,9 +237,26 @@ void VideoBackendBase::PopulateBackendInfo() g_Config.Refresh(); } -// Run from the CPU thread void VideoBackendBase::DoState(PointerWrap& p) { + if (!SConfig::GetInstance().bCPUThread) + { + DoStateGPUThread(p); + return; + } + + AsyncRequests::Event ev = {}; + ev.do_save_state.p = &p; + ev.type = AsyncRequests::Event::DO_SAVE_STATE; + AsyncRequests::GetInstance()->PushEvent(ev, true); + + // Let the GPU thread sleep after loading the state, so we're not spinning if paused after loading + // a state. The next GP burst will wake it up again. + Fifo::GpuMaySleep(); +} + +void VideoBackendBase::DoStateGPUThread(PointerWrap& p) +{ bool software = false; p.Do(software); @@ -254,7 +272,10 @@ void VideoBackendBase::DoState(PointerWrap& p) // Refresh state. if (p.GetMode() == PointerWrap::MODE_READ) { - m_invalid = true; + // Inform backend of new state from registers. + g_vertex_manager->Flush(); + g_texture_cache->Invalidate(); + BPReload(); // Clear all caches that touch RAM // (? these don't appear to touch any emulation state that gets saved. moved to on load only.) @@ -262,17 +283,6 @@ void VideoBackendBase::DoState(PointerWrap& p) } } -void VideoBackendBase::CheckInvalidState() -{ - if (m_invalid) - { - m_invalid = false; - - BPReload(); - g_texture_cache->Invalidate(); - } -} - void VideoBackendBase::InitializeShared() { memset(&g_main_cp_state, 0, sizeof(g_main_cp_state)); @@ -282,8 +292,6 @@ void VideoBackendBase::InitializeShared() // do not initialize again for the config window m_initialized = true; - m_invalid = false; - CommandProcessor::Init(); Fifo::Init(); OpcodeDecoder::Init(); |
