From e9bf3e13d0797f0aac0688ea74d7b922f274c643 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 15 May 2022 11:40:30 +0300 Subject: [PATCH] rsx/zcull: Pause the main thread before flushing reports --- rpcs3/Emu/Cell/lv2/sys_rsx.cpp | 6 ++---- rpcs3/Emu/RSX/RSXThread.h | 16 ++++++++++++++++ rpcs3/Emu/RSX/RSXZCULL.cpp | 5 ++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp index 623c7029c2..a1f31c5cd4 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp @@ -336,7 +336,7 @@ error_code sys_rsx_context_iomap(cpu_thread& cpu, u32 context_id, u32 io, u32 ea io >>= 20, ea >>= 20, size >>= 20; - render->pause(); + rsx::eng_lock fifo_lock(render); std::scoped_lock lock(render->sys_rsx_mtx); for (u32 i = 0; i < size; i++) @@ -350,7 +350,6 @@ error_code sys_rsx_context_iomap(cpu_thread& cpu, u32 context_id, u32 io, u32 ea table.io[ea + i].release((io + i) << 20); } - render->unpause(); return CELL_OK; } @@ -429,13 +428,12 @@ error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64 { case 0x001: // FIFO { - render->pause(); + rsx::eng_lock rlock(render); const u64 get = static_cast(a3); const u64 put = static_cast(a4); vm::_ref>(render->dma_address + ::offset32(&RsxDmaControl::put)).release(put << 32 | get); render->last_known_code_start = get; render->sync_point_request.release(true); - render->unpause(); break; } diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index f2c7d6c347..27c69100f8 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -874,4 +874,20 @@ namespace rsx } } }; + + class eng_lock + { + rsx::thread* pthr; + public: + eng_lock(rsx::thread* target) + :pthr(target) + { + if (pthr) pthr->pause(); + } + + ~eng_lock() + { + if (pthr) pthr->unpause(); + } + }; } diff --git a/rpcs3/Emu/RSX/RSXZCULL.cpp b/rpcs3/Emu/RSX/RSXZCULL.cpp index 43b4b28a30..296c3bee7a 100644 --- a/rpcs3/Emu/RSX/RSXZCULL.cpp +++ b/rpcs3/Emu/RSX/RSXZCULL.cpp @@ -848,7 +848,10 @@ namespace rsx // Flush all pending writes m_critical_reports_in_flight += 0x100000; - sync(ptimer); + { + rsx::eng_lock rlock(ptimer->is_current_thread() ? nullptr : ptimer); + ptimer->sync(); + } m_critical_reports_in_flight -= 0x100000; // Unlock pages