Skip to content

Commit

Permalink
Savestates/sys_spu: Minor fix in saving sys_spu_thread_receive_event
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jul 9, 2022
1 parent 28b907e commit b0ee0b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4811,6 +4811,7 @@ bool spu_thread::stop_and_signal(u32 code)
{
queue->sq.emplace_back(this);
group->run_state = SPU_THREAD_GROUP_STATUS_WAITING;
group->waiter_spu_index = index;

for (auto& thread : group->threads)
{
Expand Down
17 changes: 14 additions & 3 deletions rpcs3/Emu/Cell/lv2/sys_spu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,25 @@ lv2_spu_group::lv2_spu_group(utils::serial& ar) noexcept
*ep = idm::get_unlocked<lv2_obj, lv2_event_queue>(ar.operator u32());
}

u32 waiter_spu_index = -1;

switch (run_state)
{
// Commented stuff are handled by different means currently
//case SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED:
//case SPU_THREAD_GROUP_STATUS_INITIALIZED:
//case SPU_THREAD_GROUP_STATUS_READY:
//case SPU_THREAD_GROUP_STATUS_WAITING:
case SPU_THREAD_GROUP_STATUS_WAITING:
{
ar(waiter_spu_index);
[[fallthrough]];
}
case SPU_THREAD_GROUP_STATUS_SUSPENDED:
{
// Suspend all SPU threads
// Suspend all SPU threads except a thread that waits on sys_spu_thread_receive_event
for (const auto& thread : threads)
{
if (thread)
if (thread && thread->index != waiter_spu_index)
{
thread->state += cpu_flag::suspend;
}
Expand Down Expand Up @@ -305,6 +311,11 @@ void lv2_spu_group::save(utils::serial& ar)
{
ar(lv2_obj::check(*ep) ? (*ep)->id : 0);
}

if (_run_state == SPU_THREAD_GROUP_STATUS_WAITING)
{
ar(waiter_spu_index);
}
}

lv2_spu_image::lv2_spu_image(utils::serial& ar)
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/lv2/sys_spu.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ struct lv2_spu_group
atomic_t<u32> join_state; // flags used to detect exit cause and signal
atomic_t<u32> running = 0; // Number of running threads
atomic_t<u64> stop_count = 0;
u32 waiter_spu_index = -1; // Index of SPU executing a waiting syscall
class ppu_thread* waiter = nullptr;
bool set_terminate = false;

Expand Down

0 comments on commit b0ee0b2

Please sign in to comment.