diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 790054c2dd..201a5a2fb0 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -802,7 +802,8 @@ TextureApplyResult TextureCacheCommon::ApplyTexture(bool doBind) { DEBUG_LOG(Log::TexCache, "%08x: Texture was not a match (%s), recreating.", texaddr, reason); // Wasn't a match even in format. Let's just delete it right away, since we know we need to rebuild it, // and it's unlikely that putting it in the secondary cache will do us any good. We do that for things we rehash, though. - DeleteTexture(entryIter); + ReleaseTexture(entryIter->second.get(), true); + cache_.erase(entryIter); entryIter = cache_.end(); // make sure we don't look at it again. entry = nullptr; } @@ -1069,7 +1070,8 @@ void TextureCacheCommon::Decimate(const TexCacheEntry *const exceptThisOne, bool if (iter->second->lastFrame + killAge < gpuStats.totals.numFlips) { DEBUG_LOG(Log::TexCache, "Decimating cached texture at %08x (hash: %08x)", iter->second->addr, iter->second->fullhash); cacheSizeEstimate -= iter->second->EstimateTexMemoryUsage(); - DeleteTexture(iter++); + ReleaseTexture(iter->second.get(), true); + iter = cache_.erase(iter); } else { ++iter; } @@ -1120,10 +1122,7 @@ void TextureCacheCommon::Decimate(const TexCacheEntry *const exceptThisOne, bool bool TextureCacheCommon::IsVideo(u32 texaddr) const { texaddr &= 0x3FFFFFFF; for (const VideoInfo &info : videos_) { - if (texaddr < info.addr) { - continue; - } - if (texaddr < info.addr + info.size) { + if (texaddr >= info.addr && texaddr < info.addr + info.size) { return true; } } @@ -2653,7 +2652,6 @@ void TextureCacheCommon::DeviceRestore(Draw::DrawContext *draw) { void TextureCacheCommon::Clear(bool delete_them) { textureShaderCache_.Clear(); - for (TexCache::iterator iter = cache_.begin(); iter != cache_.end(); ++iter) { ReleaseTexture(iter->second.get(), delete_them); } @@ -2662,7 +2660,7 @@ void TextureCacheCommon::Clear(bool delete_them) { ReleaseTexture(iter->second.get(), delete_them); } if (cache_.size() + secondCache_.size()) { - INFO_LOG(Log::G3D, "Texture cached cleared from %i textures", (int)(cache_.size() + secondCache_.size())); + INFO_LOG(Log::G3D, "Texture cached cleared from %d (s: %d) textures", (int)cache_.size(), (int)secondCache_.size()); cache_.clear(); secondCache_.clear(); } @@ -2678,11 +2676,6 @@ void TextureCacheCommon::Clear(bool delete_them) { } } -void TextureCacheCommon::DeleteTexture(TexCache::iterator it) { - ReleaseTexture(it->second.get(), true); - cache_.erase(it); -} - // One type of texture update can happen without the involvement of the CPU: Block transfers. // This is done for example for the text rendering in Gran Turismo, where it only uses a single letter // worth of texture memory, and for each letter drawn, it just replaces it and then draws. diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index fbe9492840..f2bc5bf49f 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -414,7 +414,6 @@ protected: virtual void BuildTexture(TexCacheEntry *const entry) = 0; virtual void ReleaseTexture(TexCacheEntry *entry, bool delete_them) = 0; VirtualFramebuffer *SetTextureFramebuffer(const AttachCandidate &candidate, RasterChannel *framebufferTextureChannel); - void DeleteTexture(TexCache::iterator it); void Decimate(const TexCacheEntry *const exceptThisOne, bool forcePressure); // forcePressure defaults to false. void ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer, GETextureFormat texFormat, RasterChannel channel); @@ -422,7 +421,6 @@ protected: virtual void ApplySamplerByKey(const SamplerCacheKey &key) = 0; virtual void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple); // only overridden in GLES - bool CheckFullHash(TexCacheEntry *entry, bool &doDelete); virtual void BindAsClutTexture(Draw::Texture *tex, bool smooth) {}