From c4ff5018083fb327e891e07b07ad442036fc425e Mon Sep 17 00:00:00 2001 From: hyperiris Date: Sun, 8 Feb 2009 04:52:19 +0000 Subject: [PATCH] optimize memory access. Memory::GetPointer is a complex function, call it in loop will impact performance. Test with MP1, Zelda TWW and Zelda TP, speed at least increased 2fps (for example, TP intro 14fps to 16fps) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2136 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/CommandProcessor.cpp | 11 ++++++++--- Source/Core/Core/Src/HW/GPFifo.cpp | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp index 6de8811f11..216eb236f1 100644 --- a/Source/Core/Core/Src/HW/CommandProcessor.cpp +++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp @@ -644,6 +644,9 @@ void CatchUpGPU() // check if we are able to run this buffer if ((fifo.bFF_GPReadEnable) && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint)) { + // HyperIris: Memory::GetPointer is an expensive call, call it less, run faster + u8 *ptr = Memory::GetPointer(fifo.CPReadPointer); + while (fifo.CPReadWriteDistance > 0) { // check if we are on a breakpoint @@ -662,21 +665,23 @@ void CatchUpGPU() } // read the data and send it to the VideoPlugin - - u8 *ptr = Memory::GetPointer(fifo.CPReadPointer); fifo.CPReadPointer += 32; // We are going to do FP math on the main thread so have to save the current state SaveSSEState(); LoadDefaultSSEState(); CPluginManager::GetInstance().GetVideo()->Video_SendFifoData(ptr,32); LoadSSEState(); + // adjust + ptr += 32; fifo.CPReadWriteDistance -= 32; // increase the ReadPtr if (fifo.CPReadPointer >= fifo.CPEnd) { - fifo.CPReadPointer = fifo.CPBase; + fifo.CPReadPointer = fifo.CPBase; + // adjust, take care + ptr = Memory::GetPointer(fifo.CPReadPointer); LOG(COMMANDPROCESSOR, "BUFFER LOOP"); // PanicAlert("loop now"); } diff --git a/Source/Core/Core/Src/HW/GPFifo.cpp b/Source/Core/Core/Src/HW/GPFifo.cpp index 55eca024e7..e0fd743da5 100644 --- a/Source/Core/Core/Src/HW/GPFifo.cpp +++ b/Source/Core/Core/Src/HW/GPFifo.cpp @@ -66,28 +66,39 @@ void ResetGatherPipe() void STACKALIGN CheckGatherPipe() { + // HyperIris: Memory::GetPointer is an expensive call, call it less, run faster + u8* pGatherPipe = Memory::GetPointer(CPeripheralInterface::Fifo_CPUWritePointer); + while (m_gatherPipeCount >= GATHER_PIPE_SIZE) { // copy the GatherPipe - memcpy(Memory::GetPointer(CPeripheralInterface::Fifo_CPUWritePointer), m_gatherPipe, GATHER_PIPE_SIZE); + memcpy(pGatherPipe, m_gatherPipe, GATHER_PIPE_SIZE); // [F|RES]: i thought GP is forced to mem1 ... strange // move back the spill bytes m_gatherPipeCount -= GATHER_PIPE_SIZE; - for (u32 i=0; i < m_gatherPipeCount; i++) - m_gatherPipe[i] = m_gatherPipe[i + GATHER_PIPE_SIZE]; + + // HyperIris: dunno why, but I use memcpy + //for (u32 i=0; i < m_gatherPipeCount; i++) + // m_gatherPipe[i] = m_gatherPipe[i + GATHER_PIPE_SIZE]; + memcpy(m_gatherPipe, m_gatherPipe + GATHER_PIPE_SIZE, m_gatherPipeCount); // increase the CPUWritePointer CPeripheralInterface::Fifo_CPUWritePointer += GATHER_PIPE_SIZE; + // adjust + pGatherPipe += GATHER_PIPE_SIZE; if (CPeripheralInterface::Fifo_CPUWritePointer > CPeripheralInterface::Fifo_CPUEnd) _assert_msg_(DYNA_REC, 0, "Fifo_CPUWritePointer out of bounds: %08x (end = %08x)", CPeripheralInterface::Fifo_CPUWritePointer, CPeripheralInterface::Fifo_CPUEnd); if (CPeripheralInterface::Fifo_CPUWritePointer >= CPeripheralInterface::Fifo_CPUEnd) + { CPeripheralInterface::Fifo_CPUWritePointer = CPeripheralInterface::Fifo_CPUBase; - + // adjust, take care + pGatherPipe = Memory::GetPointer(CPeripheralInterface::Fifo_CPUWritePointer); + } CommandProcessor::GatherPipeBursted(); } }