Implement minimal emulation of TMEM caching

This is a remake of https://github.com/dolphin-emu/dolphin/pull/3749

Full credit goes to phire.

Old message:
"If none of the texture registers have changed and TMEM hasn't been invalidated or changed in other ways, we can blindly reuse the old texture cache entries without rehashing.

Not only does this fix the bloom effect in Spyro: A Hero's Tail (The game abused texture cache) but it will also provide speedups for other games which use the same texture over multiple draw calls, especially when safe texture cache is in use."

Changed the pr per phire's instructions to only return the current texture(s) if none of the texture registers were changed. If any texture register was changed, fall back to the default hashing and rebuilding textures from memory.
This commit is contained in:
mimimi085181
2017-06-29 23:09:32 +02:00
parent 07ab81e1bd
commit 53663c00b9
4 changed files with 60 additions and 12 deletions

View File

@ -285,6 +285,8 @@ static void BPWritten(const BPCmd& bp)
if (g_bRecordFifoData)
FifoRecorder::GetInstance().UseMemory(addr, tlutXferCount, MemoryUpdate::TMEM);
TextureCacheBase::InvalidateAllBindPoints();
return;
}
case BPMEM_FOGRANGE: // Fog Settings Control
@ -397,6 +399,7 @@ static void BPWritten(const BPCmd& bp)
return;
case BPMEM_TEXINVALIDATE:
// TODO: Needs some restructuring in TextureCacheBase.
TextureCacheBase::InvalidateAllBindPoints();
return;
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
@ -499,6 +502,8 @@ static void BPWritten(const BPCmd& bp)
if (g_bRecordFifoData)
FifoRecorder::GetInstance().UseMemory(src_addr, bytes_read, MemoryUpdate::TMEM);
TextureCacheBase::InvalidateAllBindPoints();
}
return;
@ -582,10 +587,12 @@ static void BPWritten(const BPCmd& bp)
// ------------------------
case BPMEM_TX_SETMODE0: // (0x90 for linear)
case BPMEM_TX_SETMODE0_4:
TextureCacheBase::InvalidateAllBindPoints();
return;
case BPMEM_TX_SETMODE1:
case BPMEM_TX_SETMODE1_4:
TextureCacheBase::InvalidateAllBindPoints();
return;
// --------------------------------------------
// BPMEM_TX_SETIMAGE0 - Texture width, height, format
@ -602,6 +609,7 @@ static void BPWritten(const BPCmd& bp)
case BPMEM_TX_SETIMAGE2_4:
case BPMEM_TX_SETIMAGE3:
case BPMEM_TX_SETIMAGE3_4:
TextureCacheBase::InvalidateAllBindPoints();
return;
// -------------------------------
// Set a TLUT
@ -609,6 +617,7 @@ static void BPWritten(const BPCmd& bp)
// -------------------------------
case BPMEM_TX_SETTLUT:
case BPMEM_TX_SETTLUT_4:
TextureCacheBase::InvalidateAllBindPoints();
return;
default: