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
This commit is contained in:
hyperiris 2009-02-08 04:52:19 +00:00
parent 553656966b
commit c4ff501808
2 changed files with 23 additions and 7 deletions

View File

@ -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,14 +665,14 @@ 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;
@ -677,6 +680,8 @@ void CatchUpGPU()
if (fifo.CPReadPointer >= fifo.CPEnd)
{
fifo.CPReadPointer = fifo.CPBase;
// adjust, take care
ptr = Memory::GetPointer(fifo.CPReadPointer);
LOG(COMMANDPROCESSOR, "BUFFER LOOP");
// PanicAlert("loop now");
}

View File

@ -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();
}
}