From 33016742f193fe2bf9c1cc634423672d8e2aa459 Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Mon, 20 Apr 2026 12:09:43 +0300 Subject: [PATCH] SPU: Fix CPU usage of spu_channel on BE configuration --- rpcs3/Emu/Cell/SPUThread.cpp | 11 +++++++---- rpcs3/Emu/Cell/SPUThread.h | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 855d95a44e..8315164ea9 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -7200,11 +7200,13 @@ s64 spu_channel::pop_wait(cpu_thread& spu, bool pop) lv2_obj::notify_all(); - const u32 wait_on_val = static_cast(((pop ? bit_occupy : 0) | bit_wait) >> 32); + old = (pop ? bit_occupy : 0) | bit_wait; while (true) { - thread_ctrl::wait_on(utils::bless>(&data)[1], wait_on_val); + const usz is_le = std::endian::native == std::endian::little ? 1 : 0; + thread_ctrl::wait_on(utils::bless>(&data)[is_le], read_from_ptr(reinterpret_cast(&old), is_le * 4)); + old = data; if (!(old & bit_wait)) @@ -7248,7 +7250,7 @@ bool spu_channel::push_wait(cpu_thread& spu, u32 value, bool push) { if (data & bit_count) [[unlikely]] { - jostling_value.release(push ? (bit_occupy | value) : static_cast(data)); + jostling_value.release(push ? value : static_cast(data)); data |= (push ? bit_occupy : 0) | bit_wait; } else if (push) @@ -7288,7 +7290,8 @@ bool spu_channel::push_wait(cpu_thread& spu, u32 value, bool push) return !data.bit_test_reset(off_wait); } - thread_ctrl::wait_on(utils::bless>(&data)[1], u32(state >> 32)); + const usz is_le = std::endian::native == std::endian::little ? 1 : 0; + thread_ctrl::wait_on(utils::bless>(&data)[is_le], u32(state >> 32)); state = data; } } diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index eb4e936c3b..30455e57cd 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -269,7 +269,8 @@ public: { if (!postpone_notify) { - utils::bless>(&data)[1].notify_one(); + const usz is_le = std::endian::native == std::endian::little ? 1 : 0; + utils::bless>(&data)[is_le].notify_one(); } } @@ -280,7 +281,8 @@ public: void notify() { - utils::bless>(&data)[1].notify_one(); + const usz is_le = std::endian::native == std::endian::little ? 1 : 0; + utils::bless>(&data)[is_le].notify_one(); } // Returns true on success @@ -334,7 +336,8 @@ public: if (old & bit_wait) { - utils::bless>(&data)[1].notify_one(); + const usz is_le = std::endian::native == std::endian::little ? 1 : 0; + utils::bless>(&data)[is_le].notify_one(); } return static_cast(old);