From 53663c00b931c675199ab9f0eb0d0af18083995d Mon Sep 17 00:00:00 2001 From: mimimi085181 Date: Thu, 29 Jun 2017 23:09:32 +0200 Subject: 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. --- Source/Core/VideoCommon/BPStructs.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Source/Core/VideoCommon/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index cd6f84f446..204c637b94 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -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: -- cgit v1.2.3