diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 8bf4b62282..6f697b1bc4 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -238,7 +238,7 @@ struct spu_limits_t raw_spu_count += spu_thread::g_raw_spu_ctr; - if (spu_limit + raw_limit > 6 || raw_spu_count > raw_limit || physical_spus_count + controllable_spu_count > spu_limit) + if (spu_limit + raw_limit > 6 || raw_spu_count > raw_limit || physical_spus_count >= spu_limit || physical_spus_count + controllable_spu_count > spu_limit) { return false; } @@ -714,6 +714,10 @@ error_code sys_spu_thread_group_destroy(ppu_thread& ppu, u32 id) sys_spu.warning("sys_spu_thread_group_destroy(id=0x%x)", id); + auto& limits = g_fxo->get(); + + std::lock_guard lock(limits.mutex); + const auto group = idm::withdraw(id, [](lv2_spu_group& group) -> CellError { if (!group.run_state.fetch_op([](spu_group_status& state) @@ -2052,6 +2056,10 @@ error_code raw_spu_destroy(ppu_thread& ppu, u32 id) (*thread)(); + auto& limits = g_fxo->get(); + + std::lock_guard lock(limits.mutex); + if (auto ret = idm::withdraw>(idm_id, [&](spu_thread& spu) -> CellError { if (std::addressof(spu) != std::addressof(*thread))