From 5a81bfd1fbf10f416558277f455812bbba2992ce Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 11 May 2013 15:52:41 -0700 Subject: [PATCH] Don't invalidate textures based on the clutaddr. The cluthash should be sufficient, and this is less to pass around. --- GPU/GLES/TextureCache.cpp | 15 +++++---------- GPU/GLES/TextureCache.h | 3 +-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 5a640d1080..d40e2c321b 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -120,12 +120,10 @@ void TextureCache::Invalidate(u32 addr, int size, GPUInvalidationType type) { for (TexCache::iterator iter = cache.begin(), end = cache.end(); iter != end; ++iter) { u32 texAddr = iter->second.addr; u32 texEnd = iter->second.addr + iter->second.sizeInRAM; - // Clear if either the addr or clutaddr is in the range. + bool invalidate = (texAddr >= addr && texAddr < addr_end) || (texEnd >= addr && texEnd < addr_end); invalidate = invalidate || (addr >= texAddr && addr < texEnd) || (addr_end >= texAddr && addr_end < texEnd); - invalidate = invalidate || (iter->second.clutaddr >= addr && iter->second.clutaddr < addr_end); - if (invalidate) { if ((iter->second.status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_RELIABLE) { // Clear status -> STATUS_HASHING. @@ -769,7 +767,7 @@ inline bool TextureCache::TexCacheEntry::Matches(u16 dim2, u32 hash2, u8 format2 return dim == dim2 && hash == hash2 && format == format2 && maxLevel == maxLevel2; } -inline bool TextureCache::TexCacheEntry::MatchesClut(bool hasClut, u8 clutformat2, u32 clutaddr2) { +inline bool TextureCache::TexCacheEntry::MatchesClut(bool hasClut, u8 clutformat2) { if (!hasClut) return true; return clutformat == clutformat2; @@ -817,7 +815,7 @@ void TextureCache::SetTexture() { u64 cachekey = texaddr; - u32 clutformat, clutaddr, cluthash; + u32 clutformat, cluthash; if (hasClut) { if (gstate_c.clutChanged) { UpdateCurrentClut(); @@ -825,12 +823,10 @@ void TextureCache::SetTexture() { } clutformat = gstate.clutformat & 3; - clutaddr = GetClutAddr(clutformat == GE_CMODE_32BIT_ABGR8888 ? 4 : 2); cluthash = GetCurrentClutHash(); cachekey |= (u64)cluthash << 32; } else { clutformat = 0; - clutaddr = 0; cluthash = 0; } @@ -877,7 +873,7 @@ void TextureCache::SetTexture() { //Validate the texture here (width, height etc) int dim = gstate.texsize[0] & 0xF0F; - bool match = entry->Matches(dim, texhash, format, maxLevel) && entry->MatchesClut(hasClut, clutformat, clutaddr); + bool match = entry->Matches(dim, texhash, format, maxLevel) && entry->MatchesClut(hasClut, clutformat); bool rehash = (entry->status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_UNRELIABLE; bool doDelete = true; @@ -915,7 +911,7 @@ void TextureCache::SetTexture() { TexCache::iterator secondIter = secondCache.find(secondKey); if (secondIter != secondCache.end()) { TexCacheEntry *secondEntry = &secondIter->second; - if (secondEntry->Matches(dim, texhash, format, maxLevel) && secondEntry->MatchesClut(hasClut, clutformat, clutaddr)) { + if (secondEntry->Matches(dim, texhash, format, maxLevel) && secondEntry->MatchesClut(hasClut, clutformat)) { // Reset the numInvalidated value lower, we got a match. if (entry->numInvalidated > 8) { --entry->numInvalidated; @@ -995,7 +991,6 @@ void TextureCache::SetTexture() { entry->clutformat = clutformat; - entry->clutaddr = clutaddr; entry->cluthash = cluthash; diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index 3b8f8d916b..9d76ae9071 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -83,7 +83,6 @@ private: u8 clutformat; u32 cluthash; u16 dim; - u32 clutaddr; u32 texture; //GLuint int invalidHint; u32 fullhash; @@ -98,7 +97,7 @@ private: bool tClamp; bool Matches(u16 dim2, u32 hash2, u8 format2, int maxLevel2); - bool MatchesClut(bool hasClut, u8 clutformat2, u32 clutaddr2); + bool MatchesClut(bool hasClut, u8 clutformat2); }; void Decimate(); // Run this once per frame to get rid of old textures.