diff --git a/GPU/GLES/FragmentTestCache.cpp b/GPU/GLES/FragmentTestCache.cpp index 283f0ce404..cbf36834a7 100644 --- a/GPU/GLES/FragmentTestCache.cpp +++ b/GPU/GLES/FragmentTestCache.cpp @@ -22,6 +22,7 @@ // These are small, let's give them plenty of frames. static const int FRAGTEST_TEXTURE_OLD_AGE = 307; +static const int FRAGTEST_DECIMATION_INTERVAL = 113; FragmentTestCache::FragmentTestCache() : textureCache_(NULL), lastTexture_(0) { scratchpad_ = new u8[256 * 4]; @@ -161,13 +162,18 @@ void FragmentTestCache::Clear(bool deleteThem) { } void FragmentTestCache::Decimate() { - for (auto tex = cache_.begin(); tex != cache_.end(); ) { - if (tex->second.lastFrame + FRAGTEST_TEXTURE_OLD_AGE < gpuStats.numFlips) { - glDeleteTextures(1, &tex->second.texture); - cache_.erase(tex++); - } else { - ++tex; + if (--decimationCounter_ <= 0) { + for (auto tex = cache_.begin(); tex != cache_.end(); ) { + if (tex->second.lastFrame + FRAGTEST_TEXTURE_OLD_AGE < gpuStats.numFlips) { + glDeleteTextures(1, &tex->second.texture); + cache_.erase(tex++); + } else { + ++tex; + } } + + decimationCounter_ = FRAGTEST_DECIMATION_INTERVAL; } + lastTexture_ = 0; } diff --git a/GPU/GLES/FragmentTestCache.h b/GPU/GLES/FragmentTestCache.h index eff4f4740a..1600161b24 100644 --- a/GPU/GLES/FragmentTestCache.h +++ b/GPU/GLES/FragmentTestCache.h @@ -80,4 +80,5 @@ private: std::map cache_; u8 *scratchpad_; GLuint lastTexture_; + int decimationCounter_; };