Savestates/SPU: Kill emulation when its safe to save SPU state

This commit is contained in:
Eladash 2022-07-14 22:07:02 +03:00 committed by Ivan
parent 105781fa76
commit 3e51426379
7 changed files with 114 additions and 18 deletions

View file

@ -24,6 +24,7 @@
#include "lv2/sys_prx.h"
#include "lv2/sys_overlay.h"
#include "lv2/sys_process.h"
#include "lv2/sys_spu.h"
#ifdef LLVM_AVAILABLE
#ifdef _MSC_VER
@ -1400,6 +1401,21 @@ void ppu_thread::cpu_task()
// (the farther it's postponed, the less accuracy of guest time has been lost)
Emu.FixGuestTime();
// Run SPUs waiting on a syscall (savestates related)
idm::select<named_thread<spu_thread>>([&](u32, named_thread<spu_thread>& spu)
{
if (spu.group && spu.index == spu.group->waiter_spu_index)
{
if (std::exchange(spu.stop_flag_removal_protection, false))
{
return;
}
ensure(spu.state.test_and_reset(cpu_flag::stop));
spu.state.notify_one(cpu_flag::stop);
}
});
// Check if this is the only PPU left to initialize (savestates related)
if (lv2_obj::is_scheduler_ready())
{