From 58563324bd3f82eaba83f1bf3b834d65eb23c94f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 14 Mar 2015 11:06:03 -0700 Subject: [PATCH] Include texture size in cache key. This makes Tales of Destiny 2's towns significantly faster. It may however cause us to keep textures around for longer - but we still account for them in our metrics and invalidation. --- GPU/Directx9/TextureCacheDX9.cpp | 9 +++++---- GPU/GLES/TextureCache.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index cc8639c6be..95f8b4b0c6 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -1022,7 +1022,8 @@ bool TextureCacheDX9::SetOffsetTexture(u32 offset) { return false; } - u64 cachekey = (u64)(texaddr & 0x3FFFFFFF) << 32; + const u16 dim = gstate.getTextureDimension(0); + u64 cachekey = ((u64)(texaddr & 0x3FFFFFFF) << 32) | dim; TexCache::iterator iter = cache.find(cachekey); if (iter == cache.end()) { return false; @@ -1068,6 +1069,7 @@ void TextureCacheDX9::SetTexture(bool force) { return; } + const u16 dim = gstate.getTextureDimension(0); int w = gstate.getTextureWidth(0); int h = gstate.getTextureHeight(0); @@ -1080,7 +1082,7 @@ void TextureCacheDX9::SetTexture(bool force) { bool hasClut = gstate.isTextureFormatIndexed(); // Ignore uncached/kernel when caching. - u64 cachekey = (u64)(texaddr & 0x3FFFFFFF) << 32; + u64 cachekey = ((u64)(texaddr & 0x3FFFFFFF) << 32) | dim; u32 cluthash; if (hasClut) { if (clutLastFormat_ != gstate.clutformat) { @@ -1088,7 +1090,7 @@ void TextureCacheDX9::SetTexture(bool force) { UpdateCurrentClut(); } cluthash = GetCurrentClutHash() ^ gstate.clutformat; - cachekey |= cluthash; + cachekey ^= cluthash; } else { cluthash = 0; } @@ -1111,7 +1113,6 @@ void TextureCacheDX9::SetTexture(bool force) { if (iter != cache.end()) { entry = &iter->second; // Validate the texture still matches the cache entry. - u16 dim = gstate.getTextureDimension(0); bool match = entry->Matches(dim, format, maxLevel); // Check for FBO - slow! diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 28ad071d47..b6bc270cb3 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -1195,7 +1195,8 @@ bool TextureCache::SetOffsetTexture(u32 offset) { return false; } - u64 cachekey = (u64)(texaddr & 0x3FFFFFFF) << 32; + const u16 dim = gstate.getTextureDimension(0); + u64 cachekey = ((u64)(texaddr & 0x3FFFFFFF) << 32) | dim; TexCache::iterator iter = cache.find(cachekey); if (iter == cache.end()) { return false; @@ -1241,6 +1242,7 @@ void TextureCache::SetTexture(bool force) { return; } + const u16 dim = gstate.getTextureDimension(0); int w = gstate.getTextureWidth(0); int h = gstate.getTextureHeight(0); @@ -1253,7 +1255,7 @@ void TextureCache::SetTexture(bool force) { bool hasClut = gstate.isTextureFormatIndexed(); // Ignore uncached/kernel when caching. - u64 cachekey = (u64)(texaddr & 0x3FFFFFFF) << 32; + u64 cachekey = ((u64)(texaddr & 0x3FFFFFFF) << 32) | dim; u32 cluthash; if (hasClut) { if (clutLastFormat_ != gstate.clutformat) { @@ -1261,7 +1263,7 @@ void TextureCache::SetTexture(bool force) { UpdateCurrentClut(); } cluthash = GetCurrentClutHash() ^ gstate.clutformat; - cachekey |= cluthash; + cachekey ^= cluthash; } else { cluthash = 0; } @@ -1282,7 +1284,6 @@ void TextureCache::SetTexture(bool force) { if (iter != cache.end()) { entry = &iter->second; // Validate the texture still matches the cache entry. - u16 dim = gstate.getTextureDimension(0); bool match = entry->Matches(dim, format, maxLevel); // Check for FBO - slow!