SPU: Fix CPU usage of spu_channel on BE configuration

This commit is contained in:
Elad 2026-04-20 12:09:43 +03:00
parent 320e8d634a
commit 33016742f1
2 changed files with 13 additions and 7 deletions

View File

@ -7200,11 +7200,13 @@ s64 spu_channel::pop_wait(cpu_thread& spu, bool pop)
lv2_obj::notify_all(); lv2_obj::notify_all();
const u32 wait_on_val = static_cast<u32>(((pop ? bit_occupy : 0) | bit_wait) >> 32); old = (pop ? bit_occupy : 0) | bit_wait;
while (true) while (true)
{ {
thread_ctrl::wait_on(utils::bless<atomic_t<u32>>(&data)[1], wait_on_val); const usz is_le = std::endian::native == std::endian::little ? 1 : 0;
thread_ctrl::wait_on(utils::bless<atomic_t<u32>>(&data)[is_le], read_from_ptr<u32>(reinterpret_cast<char*>(&old), is_le * 4));
old = data; old = data;
if (!(old & bit_wait)) 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]] if (data & bit_count) [[unlikely]]
{ {
jostling_value.release(push ? (bit_occupy | value) : static_cast<u32>(data)); jostling_value.release(push ? value : static_cast<u32>(data));
data |= (push ? bit_occupy : 0) | bit_wait; data |= (push ? bit_occupy : 0) | bit_wait;
} }
else if (push) 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); return !data.bit_test_reset(off_wait);
} }
thread_ctrl::wait_on(utils::bless<atomic_t<u32>>(&data)[1], u32(state >> 32)); const usz is_le = std::endian::native == std::endian::little ? 1 : 0;
thread_ctrl::wait_on(utils::bless<atomic_t<u32>>(&data)[is_le], u32(state >> 32));
state = data; state = data;
} }
} }

View File

@ -269,7 +269,8 @@ public:
{ {
if (!postpone_notify) if (!postpone_notify)
{ {
utils::bless<atomic_t<u32>>(&data)[1].notify_one(); const usz is_le = std::endian::native == std::endian::little ? 1 : 0;
utils::bless<atomic_t<u32>>(&data)[is_le].notify_one();
} }
} }
@ -280,7 +281,8 @@ public:
void notify() void notify()
{ {
utils::bless<atomic_t<u32>>(&data)[1].notify_one(); const usz is_le = std::endian::native == std::endian::little ? 1 : 0;
utils::bless<atomic_t<u32>>(&data)[is_le].notify_one();
} }
// Returns true on success // Returns true on success
@ -334,7 +336,8 @@ public:
if (old & bit_wait) if (old & bit_wait)
{ {
utils::bless<atomic_t<u32>>(&data)[1].notify_one(); const usz is_le = std::endian::native == std::endian::little ? 1 : 0;
utils::bless<atomic_t<u32>>(&data)[is_le].notify_one();
} }
return static_cast<u32>(old); return static_cast<u32>(old);