From f7576185cc0c12e37aa0eb22f3a1361702b1b61f Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 15 Sep 2016 15:44:55 -0700 Subject: [PATCH] Fix Texture Cache slow down and crashes --- src/Textures.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Textures.cpp b/src/Textures.cpp index 2526ed85..d61e8381 100644 --- a/src/Textures.cpp +++ b/src/Textures.cpp @@ -526,12 +526,14 @@ void TextureCache::_checkCacheSize() #ifdef VC const size_t maxCacheSize = 15000; #else - const size_t maxCacheSize = 128000; + const size_t maxCacheSize = 16384; #endif - // Clear cache if its size is too large. if (m_textures.size() >= maxCacheSize) { - _clear(); - return; + CachedTexture& clsTex = m_textures.back(); + m_cachedBytes -= clsTex.textureBytes; + glDeleteTextures(1, &clsTex.glName); + m_lruTextureLocations.erase(clsTex.crc); + m_textures.pop_back(); } if (m_cachedBytes <= m_maxBytes)