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

@ -5,6 +5,7 @@
#pragma once
#include <array>
#include <bitset>
#include <map>
#include <memory>
#include <tuple>
@ -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<TCacheEntry*, 8> bound_textures{};
static std::bitset<8> valid_bind_points;
private:
// Minimal version of TCacheEntry just for TexPool