mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-19 19:00:09 +02: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:
@ -45,6 +45,7 @@ namespace SW
|
||||
|
||||
static volatile bool fifoStateRun = false;
|
||||
static volatile bool emuRunningState = false;
|
||||
static std::mutex m_csSWVidOccupied;
|
||||
|
||||
|
||||
std::string VideoSoftware::GetName()
|
||||
@ -91,6 +92,24 @@ bool VideoSoftware::Initialize(void *&window_handle)
|
||||
|
||||
void VideoSoftware::DoState(PointerWrap&)
|
||||
{
|
||||
// NYI
|
||||
}
|
||||
|
||||
void VideoSoftware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
||||
{
|
||||
if (doLock)
|
||||
{
|
||||
EmuStateChange(EMUSTATE_CHANGE_PAUSE);
|
||||
if (!Core::IsGPUThread())
|
||||
m_csSWVidOccupied.lock();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (unpauseOnUnlock)
|
||||
EmuStateChange(EMUSTATE_CHANGE_PLAY);
|
||||
if (!Core::IsGPUThread())
|
||||
m_csSWVidOccupied.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoSoftware::RunLoop(bool enable)
|
||||
@ -167,6 +186,7 @@ bool VideoSoftware::Video_Screenshot(const char *_szFilename)
|
||||
// -------------------------------
|
||||
void VideoSoftware::Video_EnterLoop()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_csSWVidOccupied);
|
||||
fifoStateRun = true;
|
||||
|
||||
while (fifoStateRun)
|
||||
@ -181,7 +201,9 @@ void VideoSoftware::Video_EnterLoop()
|
||||
while (!emuRunningState && fifoStateRun)
|
||||
{
|
||||
g_video_backend->PeekMessages();
|
||||
m_csSWVidOccupied.unlock();
|
||||
Common::SleepCurrentThread(1);
|
||||
m_csSWVidOccupied.lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user