From 2a89d87fab845ac5e6fa123c8871239c5da8dc05 Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:58:38 +0300 Subject: [PATCH] Savestates/SPU: Fix MFC commands abort --- rpcs3/Emu/Cell/SPULLVMRecompiler.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp b/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp index 6bd75aea2d..10d48f4240 100644 --- a/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp @@ -3121,14 +3121,25 @@ public: _spu->do_mfc(); } + template static void exec_mfc_cmd(spu_thread* _spu) { + if constexpr (!Saveable) + { + _spu->unsavable = true; + } + if (!_spu->process_mfc_cmd() || _spu->state & cpu_flag::again) { fmt::throw_exception("exec_mfc_cmd(): Should not abort!"); } static_cast(_spu->test_stopped()); + + if constexpr (!Saveable) + { + _spu->unsavable = false; + } } void WRCH(spu_opcode_t op) // @@ -3307,8 +3318,17 @@ public: case MFC_GETLB_CMD: case MFC_GETLF_CMD: { + m_ir->CreateBr(next); + m_ir->SetInsertPoint(exec); + m_ir->CreateUnreachable(); + m_ir->SetInsertPoint(fail); + m_ir->CreateUnreachable(); + m_ir->SetInsertPoint(next); + m_ir->CreateStore(ci, spu_ptr(&spu_thread::ch_mfc_cmd, &spu_mfc_cmd::cmd)); + update_pc(); ensure_gpr_stores(); - [[fallthrough]]; + call("spu_exec_mfc_cmd_saveable", &exec_mfc_cmd, m_thread); + return; } case MFC_SDCRZ_CMD: case MFC_GETLLAR_CMD: @@ -3325,7 +3345,7 @@ public: m_ir->SetInsertPoint(next); m_ir->CreateStore(ci, spu_ptr(&spu_thread::ch_mfc_cmd, &spu_mfc_cmd::cmd)); update_pc(); - call("spu_exec_mfc_cmd", &exec_mfc_cmd, m_thread); + call("spu_exec_mfc_cmd", &exec_mfc_cmd, m_thread); return; } case MFC_SNDSIG_CMD: @@ -3384,7 +3404,7 @@ public: } m_ir->CreateStore(ci, spu_ptr(&spu_thread::ch_mfc_cmd, &spu_mfc_cmd::cmd)); - call("spu_exec_mfc_cmd", &exec_mfc_cmd, m_thread); + call("spu_exec_mfc_cmd", &exec_mfc_cmd, m_thread); m_ir->CreateBr(next); m_ir->SetInsertPoint(copy);