From a1b7da413a511eb1d9dd1075efc0f1c69795d6fd Mon Sep 17 00:00:00 2001 From: aquanull Date: Wed, 5 Jun 2013 00:43:42 +0800 Subject: [PATCH] TextureCache::Invalidate()/InvalidateAll() small corrections and optimizations. I think the ranges are [start_addr, end_addr). --- GPU/GLES/TextureCache.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 133ebcc475..ae61f851ad 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -123,10 +123,7 @@ void TextureCache::Invalidate(u32 addr, int size, GPUInvalidationType type) { u32 texAddr = iter->second.addr; u32 texEnd = iter->second.addr + iter->second.sizeInRAM; - bool invalidate = (texAddr >= addr && texAddr < addr_end) || (texEnd >= addr && texEnd < addr_end); - invalidate = invalidate || (addr >= texAddr && addr < texEnd) || (addr_end >= texAddr && addr_end < texEnd); - - if (invalidate) { + if (texAddr < addr_end && addr < texEnd) { if ((iter->second.status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_RELIABLE) { // Clear status -> STATUS_HASHING. iter->second.status &= ~TexCacheEntry::STATUS_MASK; @@ -143,8 +140,14 @@ void TextureCache::Invalidate(u32 addr, int size, GPUInvalidationType type) { } } -void TextureCache::InvalidateAll(GPUInvalidationType type) { - Invalidate(0, 0xFFFFFFFF, type); +void TextureCache::InvalidateAll(GPUInvalidationType /*unused*/) { + for (TexCache::iterator iter = cache.begin(), end = cache.end(); iter != end; ++iter) { + if ((iter->second.status & TexCacheEntry::STATUS_MASK) == TexCacheEntry::STATUS_RELIABLE) { + // Clear status -> STATUS_HASHING. + iter->second.status &= ~TexCacheEntry::STATUS_MASK; + } + iter->second.invalidHint++; + } } void TextureCache::ClearNextFrame() {