Handle flush heuristics

This commit is contained in:
Exzap 2024-12-06 20:53:52 +01:00
parent d59e17b105
commit 04cad5677b
1 changed files with 15 additions and 0 deletions

View File

@ -141,6 +141,14 @@ private:
void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx); void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx);
// called whenever the GPU runs out of commands or hits a wait condition (semaphores, HLE waits)
void LatteCP_signalEnterWait()
{
// based on the assumption that games won't do a rugpull and swap out buffer data in the middle of an uninterrupted sequence of drawcalls,
// we only flush caches when the GPU goes idle or has to wait for any operation
LatteIndices_invalidateAll();
}
/* /*
* Read a U32 from the command buffer * Read a U32 from the command buffer
* If no data is available then wait in a busy loop * If no data is available then wait in a busy loop
@ -466,6 +474,8 @@ LatteCMDPtr LatteCP_itWaitRegMem(LatteCMDPtr cmd, uint32 nWords)
const uint32 GPU7_WAIT_MEM_OP_GREATER = 6; const uint32 GPU7_WAIT_MEM_OP_GREATER = 6;
const uint32 GPU7_WAIT_MEM_OP_NEVER = 7; const uint32 GPU7_WAIT_MEM_OP_NEVER = 7;
LatteCP_signalEnterWait();
bool stalls = false; bool stalls = false;
if ((word0 & 0x10) != 0) if ((word0 & 0x10) != 0)
{ {
@ -594,6 +604,7 @@ LatteCMDPtr LatteCP_itMemSemaphore(LatteCMDPtr cmd, uint32 nWords)
else if(SEM_SIGNAL == 7) else if(SEM_SIGNAL == 7)
{ {
// wait // wait
LatteCP_signalEnterWait();
size_t loopCount = 0; size_t loopCount = 0;
while (true) while (true)
{ {
@ -1305,11 +1316,13 @@ void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx)
} }
case IT_HLE_TRIGGER_SCANBUFFER_SWAP: case IT_HLE_TRIGGER_SCANBUFFER_SWAP:
{ {
LatteCP_signalEnterWait();
LatteCP_itHLESwapScanBuffer(cmdData, nWords); LatteCP_itHLESwapScanBuffer(cmdData, nWords);
break; break;
} }
case IT_HLE_WAIT_FOR_FLIP: case IT_HLE_WAIT_FOR_FLIP:
{ {
LatteCP_signalEnterWait();
LatteCP_itHLEWaitForFlip(cmdData, nWords); LatteCP_itHLEWaitForFlip(cmdData, nWords);
break; break;
} }
@ -1594,12 +1607,14 @@ void LatteCP_ProcessRingbuffer()
} }
case IT_HLE_TRIGGER_SCANBUFFER_SWAP: case IT_HLE_TRIGGER_SCANBUFFER_SWAP:
{ {
LatteCP_signalEnterWait();
LatteCP_itHLESwapScanBuffer(cmd, nWords); LatteCP_itHLESwapScanBuffer(cmd, nWords);
timerRecheck += CP_TIMER_RECHECK / 64; timerRecheck += CP_TIMER_RECHECK / 64;
break; break;
} }
case IT_HLE_WAIT_FOR_FLIP: case IT_HLE_WAIT_FOR_FLIP:
{ {
LatteCP_signalEnterWait();
LatteCP_itHLEWaitForFlip(cmd, nWords); LatteCP_itHLEWaitForFlip(cmd, nWords);
timerRecheck += CP_TIMER_RECHECK / 1; timerRecheck += CP_TIMER_RECHECK / 1;
break; break;