From 15330a86ee0a8eed165badfc263573df0f59db0f Mon Sep 17 00:00:00 2001 From: Farseer Date: Fri, 26 Jan 2018 13:04:17 +0200 Subject: [PATCH] Always invalidate code as temp fix Until I find out what else triggers SPU invalidation --- rpcs3/Emu/Cell/SPURecompiler.cpp | 4 +++- rpcs3/Emu/Cell/SPUThread.cpp | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 433e8156b2..090fb094c8 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -25,7 +25,9 @@ void spu_recompiler_base::enter(SPUThread& spu) // Search if cached data matches auto & func = spu.compiled_cache[spu.pc / 4]; - if (func.dirty_bit) + + // func.contents is there only as a temporary test, to see if SPU codfe not getting invalidated is the reason for the crashes + if (func.contents || func.dirty_bit) { func.dirty_bit = false; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index e04184c725..71a2067607 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -470,6 +470,7 @@ void SPUThread::do_dma_transfer(const spu_mfc_cmd& args, bool from_mfc) u32 eal = args.eal; u32 lsa = args.lsa & 0x3ffff; + SPUThread * spu = nullptr; if (eal >= SYS_SPU_THREAD_BASE_LOW && offset < RAW_SPU_BASE_ADDR) // SPU Thread Group MMIO (LS and SNR) { @@ -478,15 +479,15 @@ void SPUThread::do_dma_transfer(const spu_mfc_cmd& args, bool from_mfc) if (group && index < group->num && group->threads[index]) { - auto& spu = static_cast(*group->threads[index]); + spu = group->threads[index].get(); if (offset + args.size - 1 < 0x40000) // LS access { - eal = spu.offset + offset; // redirect access + eal = spu->offset + offset; // redirect access } else if (!is_get && args.size == 4 && (offset == SYS_SPU_THREAD_SNR1 || offset == SYS_SPU_THREAD_SNR2)) { - spu.push_snr(SYS_SPU_THREAD_SNR2 == offset, _ref(lsa)); + spu->push_snr(SYS_SPU_THREAD_SNR2 == offset, _ref(lsa)); return; } else @@ -554,6 +555,20 @@ void SPUThread::do_dma_transfer(const spu_mfc_cmd& args, bool from_mfc) } } + if (spu) + { + for (auto& func : spu->compiled_functions) + { + auto faddr = func->contents->addr; + auto fsize = func->contents->size; + + if (faddr >= eal && faddr + fsize < eal + args.size) + { + func->dirty_bit = true; + } + } + } + if (is_get && from_mfc) { //_mm_sfence();