From e52dd9dc6f6ceb9dd24d38fc8866a992a5175571 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 30 Jul 2020 16:01:25 +0300 Subject: [PATCH] SPU: Implement SYS_SPU_THREAD_OPTION_DEC_SYNC_TB_ENABLE (#8657) --- rpcs3/Emu/Cell/SPUThread.cpp | 7 ++++--- rpcs3/Emu/Cell/SPUThread.h | 3 ++- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 406540a4a3..55fd5d2a80 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -981,8 +981,8 @@ void spu_thread::cpu_init() interrupts_enabled.raw() = false; raddr = 0; - ch_dec_start_timestamp = get_timebased_time(); // ??? - ch_dec_value = 0; + ch_dec_start_timestamp = get_timebased_time(); + ch_dec_value = option & SYS_SPU_THREAD_OPTION_DEC_SYNC_TB_ENABLE ? ~static_cast(ch_dec_start_timestamp) : 0; if (get_type() >= spu_type::raw) { @@ -1188,7 +1188,7 @@ spu_thread::~spu_thread() } } -spu_thread::spu_thread(vm::addr_t _ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated) +spu_thread::spu_thread(vm::addr_t _ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated, u32 option) : cpu_thread(idm::last_id()) , index(index) , ls([&]() @@ -1209,6 +1209,7 @@ spu_thread::spu_thread(vm::addr_t _ls, lv2_spu_group* group, u32 index, std::str , thread_type(group ? spu_type::threaded : is_isolated ? spu_type::isolated : spu_type::raw) , offset(_ls) , group(group) + , option(option) , lv2_id(lv2_id) , spu_tname(stx::shared_cptr::make(name)) { diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index a327cbdcb0..034109f440 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -629,7 +629,7 @@ public: static const u32 id_step = 1; static const u32 id_count = 2048; - spu_thread(vm::addr_t ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated = false); + spu_thread(vm::addr_t ls, lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated = false, u32 option = 0); u32 pc = 0; @@ -722,6 +722,7 @@ private: const u32 offset; // SPU LS offset lv2_spu_group* const group; // SPU Thread Group (only safe to access in the spu thread itself) public: + const u32 option; // sys_spu_thread_initialize option const u32 lv2_id; // The actual id that is used by syscalls // Thread name diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 147c2ca353..ab06194d90 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -322,7 +322,9 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 g sys_spu.warning("sys_spu_thread_initialize(thread=*0x%x, group=0x%x, spu_num=%d, img=*0x%x, attr=*0x%x, arg=*0x%x)", thread, group_id, spu_num, img, attr, arg); - if (attr->name_len > 0x80 || attr->option & ~(SYS_SPU_THREAD_OPTION_DEC_SYNC_TB_ENABLE | SYS_SPU_THREAD_OPTION_ASYNC_INTR_ENABLE)) + const u32 option = attr->option; + + if (attr->name_len > 0x80 || option & ~(SYS_SPU_THREAD_OPTION_DEC_SYNC_TB_ENABLE | SYS_SPU_THREAD_OPTION_ASYNC_INTR_ENABLE)) { return CELL_EINVAL; } @@ -392,7 +394,7 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 g return CELL_EBUSY; } - if (u32 option = attr->option) + if (option & SYS_SPU_THREAD_OPTION_ASYNC_INTR_ENABLE) { sys_spu.warning("Unimplemented SPU Thread options (0x%x)", option); } @@ -412,7 +414,7 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr thread, u32 g fmt::append(full_name, "%s ", thread_name); } - const auto spu = std::make_shared>(full_name, ls_addr, group.get(), spu_num, thread_name, tid); + const auto spu = std::make_shared>(full_name, ls_addr, group.get(), spu_num, thread_name, tid, false, option); group->threads[inited] = spu; group->threads_map[spu_num] = static_cast(inited); return spu;