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/TextureCacheBase.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.h') diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 23f25f48fc..56bf6fb849 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include #include @@ -39,6 +40,7 @@ public: bool is_efb_copy; bool is_custom_tex; bool may_have_overlapping_textures = true; + bool tmem_only = false; // indicates that this texture only exists in the tmem cache unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view @@ -125,8 +127,9 @@ public: virtual void DeleteShaders() = 0; TCacheEntry* Load(const u32 stage); - void UnbindTextures(); - virtual void BindTextures(); + static void InvalidateAllBindPoints() { valid_bind_points.reset(); } + static bool IsValidBindPoint(u32 i) { return valid_bind_points.test(i); } + void BindTextures(); void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, u32 dstStride, bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf); @@ -158,6 +161,7 @@ protected: size_t temp_size = 0; std::array bound_textures{}; + static std::bitset<8> valid_bind_points; private: // Minimal version of TCacheEntry just for TexPool -- cgit v1.2.3