From c354dfcd2f5f564ed347069a36a8ed0978b17b77 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 9 Apr 2016 18:07:23 +1200 Subject: [PATCH 1/2] Remove instant ARAM DMA mode. Now that our timings are much more accurate it doesn't look like we need it anymore. And the instant ARAM DMA mode + scheduling fixes ctually breaks ATV: Quad Power Racing 2 (causing all sorts of werid bugs). --- Source/Core/Core/HW/DSP.cpp | 52 ------------------- Source/Core/Core/HW/DSP.h | 3 -- .../Interpreter/Interpreter_LoadStore.cpp | 8 --- .../Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp | 17 ------ Source/Core/Core/State.cpp | 2 +- 5 files changed, 1 insertion(+), 81 deletions(-) diff --git a/Source/Core/Core/HW/DSP.cpp b/Source/Core/Core/HW/DSP.cpp index 9fab707330..fd5b90f6f9 100644 --- a/Source/Core/Core/HW/DSP.cpp +++ b/Source/Core/Core/HW/DSP.cpp @@ -137,9 +137,6 @@ struct ARAMInfo static ARAMInfo g_ARAM; static AudioDMA g_audioDMA; static ARAM_DMA g_arDMA; -static u32 last_mmaddr; -static u32 last_aram_dma_count; -static bool instant_dma; UDSPControl g_dspState; union ARAM_Info { @@ -177,9 +174,6 @@ void DoState(PointerWrap& p) p.Do(g_AR_MODE); p.Do(g_AR_REFRESH); p.Do(dsp_slice); - p.Do(last_mmaddr); - p.Do(last_aram_dma_count); - p.Do(instant_dma); dsp_emulator->DoState(p); } @@ -197,30 +191,6 @@ static void CompleteARAM(u64 userdata, s64 cyclesLate) GenerateDSPInterrupt(INT_ARAM); } -void EnableInstantDMA() -{ - CoreTiming::RemoveEvent(et_CompleteARAM); - CompleteARAM(0, 0); - instant_dma = true; - ERROR_LOG(DSPINTERFACE, "Enabling Instant ARAM DMA hack"); -} - -void FlushInstantDMA(u32 address) -{ - u64 dma_in_progress = DSP::DMAInProgress(); - if (dma_in_progress != 0) - { - u32 start_addr = (dma_in_progress >> 32) & Memory::RAM_MASK; - u32 end_addr = (dma_in_progress & Memory::RAM_MASK) & 0xffffffff; - u32 invalidated_addr = (address & Memory::RAM_MASK) & ~0x1f; - - if (invalidated_addr >= start_addr && invalidated_addr <= end_addr) - { - DSP::EnableInstantDMA(); - } - } -} - DSPEmulator* GetDSPEmulator() { return dsp_emulator.get(); @@ -257,11 +227,6 @@ void Init(bool hle) g_AR_MODE = 1; // ARAM Controller has init'd g_AR_REFRESH = 156; // 156MHz - instant_dma = false; - - last_aram_dma_count = 0; - last_mmaddr = 0; - et_GenerateDSPInterrupt = CoreTiming::RegisterEvent("DSPint", GenerateDSPInterrupt); et_CompleteARAM = CoreTiming::RegisterEvent("ARAMint", CompleteARAM); } @@ -527,16 +492,8 @@ static void Do_ARAM_DMA() // ARAM DMA transfer rate has been measured on real hw int ticksToTransfer = (g_arDMA.Cnt.count / 32) * 246; - - // This is a huge hack that appears to be here only to fix Resident Evil 2/3 - if (instant_dma) - ticksToTransfer = std::min(ticksToTransfer, 100); - CoreTiming::ScheduleEvent(ticksToTransfer, et_CompleteARAM); - last_mmaddr = g_arDMA.MMAddr; - last_aram_dma_count = g_arDMA.Cnt.count; - // Real hardware DMAs in 32byte chunks, but we can get by with 8byte chunks if (g_arDMA.Cnt.dir) { @@ -667,13 +624,4 @@ u8* GetARAMPtr() return g_ARAM.ptr; } -u64 DMAInProgress() -{ - if (g_dspState.DMAState == 1) - { - return ((u64)last_mmaddr << 32 | (last_mmaddr + last_aram_dma_count)); - } - return 0; -} - } // end of namespace DSP diff --git a/Source/Core/Core/HW/DSP.h b/Source/Core/Core/HW/DSP.h index 440d8decdd..f7d3e136e6 100644 --- a/Source/Core/Core/HW/DSP.h +++ b/Source/Core/Core/HW/DSP.h @@ -80,8 +80,5 @@ u8* GetARAMPtr(); void UpdateAudioDMA(); void UpdateDSPSlice(int cycles); -u64 DMAInProgress(); -void EnableInstantDMA(); -void FlushInstantDMA(u32 address); } // end of namespace DSP diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp index 1d9f49d582..d6432e02a3 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -336,14 +336,6 @@ void Interpreter::dcbi(UGeckoInstruction _inst) // should use icbi consistently, but games aren't portable.) u32 address = Helper_Get_EA_X(_inst); JitInterface::InvalidateICache(address & ~0x1f, 32, false); - - // The following detects a situation where the game is writing to the dcache at the address being - // DMA'd. As we do not - // have dcache emulation, invalid data is being DMA'd causing audio glitches. The following code - // detects this and - // enables the DMA to complete instantly before the invalid data is written. Resident Evil 2 & 3 - // trigger this. - DSP::FlushInstantDMA(address); } void Interpreter::dcbst(UGeckoInstruction _inst) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index d5a355d0e4..8a076b2e40 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -315,23 +315,6 @@ void Jit64::dcbx(UGeckoInstruction inst) SwitchToNearCode(); SetJumpTarget(c); - // dcbi - if (inst.SUBOP10 == 470) - { - // Flush DSP DMA if DMAState bit is set - TEST(16, M(&DSP::g_dspState), Imm16(1 << 9)); - c = J_CC(CC_NZ, true); - SwitchToFarCode(); - SetJumpTarget(c); - ABI_PushRegistersAndAdjustStack(registersInUse, 0); - SHL(32, R(addr), Imm8(5)); - ABI_CallFunctionR(DSP::FlushInstantDMA, addr); - ABI_PopRegistersAndAdjustStack(registersInUse, 0); - c = J(true); - SwitchToNearCode(); - SetJumpTarget(c); - } - gpr.UnlockAllX(); } diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 117e16b935..df30731f6f 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -70,7 +70,7 @@ static Common::Event g_compressAndDumpStateSyncEvent; static std::thread g_save_thread; // Don't forget to increase this after doing changes on the savestate system -static const u32 STATE_VERSION = 56; +static const u32 STATE_VERSION = 57; // Maps savestate versions to Dolphin versions. // Versions after 42 don't need to be added to this list, From dbface94eab206b5c5b7b07ff98e6acd140d785a Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 9 Apr 2016 18:21:42 +1200 Subject: [PATCH 2/2] And remove the feature from the Arm64 jit too. --- .../PowerPC/JitArm64/JitArm64_LoadStore.cpp | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp index 34a8638024..08d51a6014 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp @@ -733,34 +733,6 @@ void JitArm64::dcbx(UGeckoInstruction inst) SetJumpTarget(bit_not_set); SetJumpTarget(near); - // dcbi - if (inst.SUBOP10 == 470) - { - // Flush DSP DMA if DMAState bit is set - MOVI2R(EncodeRegTo64(WA), (u64)&DSP::g_dspState); - LDRH(INDEX_UNSIGNED, WA, EncodeRegTo64(WA), 0); - - bit_not_set = TBZ(WA, 9); - far = B(); - SwitchToFarCode(); - SetJumpTarget(far); - - ABI_PushRegisters(gprs_to_push); - m_float_emit.ABI_PushRegisters(fprs_to_push, X30); - - LSL(W0, addr, 5); - MOVI2R(X1, (u64)DSP::FlushInstantDMA); - BLR(X1); - - m_float_emit.ABI_PopRegisters(fprs_to_push, X30); - ABI_PopRegisters(gprs_to_push); - - near = B(); - SwitchToNearCode(); - SetJumpTarget(near); - SetJumpTarget(bit_not_set); - } - gpr.Unlock(addr, value, W30); }