diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index df10c28527..a9e8208b16 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -38,6 +38,9 @@ // Not used in lowmem mode. #define TEXTURE_SECOND_KILL_AGE 100 +// Try to be prime to other decimation intervals. +#define TEXCACHE_DECIMATION_INTERVAL 13 + extern int g_iNumVideos; u32 RoundUpToPowerOf2(u32 v) @@ -61,6 +64,7 @@ static inline u32 GetLevelBufw(int level, u32 texaddr) { TextureCache::TextureCache() : clearCacheNextFrame_(false), lowMemoryMode_(false), clutBuf_(NULL) { lastBoundTexture = -1; + decimationCounter_ = TEXCACHE_DECIMATION_INTERVAL; // This is 5MB of temporary storage. Might be possible to shrink it. tmpTexBuf32.resize(1024 * 512); // 2MB tmpTexBuf16.resize(1024 * 512); // 1MB @@ -97,6 +101,12 @@ void TextureCache::Clear(bool delete_them) { // Removes old textures. void TextureCache::Decimate() { + if (--decimationCounter_ <= 0) { + decimationCounter_ = TEXCACHE_DECIMATION_INTERVAL; + } else { + return; + } + glBindTexture(GL_TEXTURE_2D, 0); lastBoundTexture = -1; int killAge = lowMemoryMode_ ? TEXTURE_KILL_AGE_LOWMEM : TEXTURE_KILL_AGE; diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index 6b3dbfd80e..bf0fa3149d 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -147,5 +147,7 @@ private: u32 lastBoundTexture; float maxAnisotropyLevel; + + int decimationCounter_; }; diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index aa5d82d9f9..3577580d74 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -55,6 +55,9 @@ enum { TRANSFORMED_VERTEX_BUFFER_SIZE = 65536 * sizeof(TransformedVertex) }; + +#define VERTEXCACHE_DECIMATION_INTERVAL 17 + inline float clamp(float in, float min, float max) { return in < min ? min : (in > max ? max : in); } @@ -70,6 +73,7 @@ TransformDrawEngine::TransformDrawEngine() framebufferManager_(0), numDrawCalls(0), uvScale(0) { + decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL; // Allocate nicely aligned memory. Maybe graphics drivers will // appreciate it. // All this is a LOT of memory, need to see if we can cut down somehow. @@ -1095,6 +1099,12 @@ void TransformDrawEngine::ClearTrackedVertexArrays() { } void TransformDrawEngine::DecimateTrackedVertexArrays() { + if (--decimationCounter_ <= 0) { + decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL; + } else { + return; + } + int threshold = gpuStats.numFrames - VAI_KILL_AGE; for (auto iter = vai_.begin(); iter != vai_.end(); ) { if (iter->second->lastFrame < threshold) { diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index 226a3a9fe6..8e953d4217 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -181,6 +181,8 @@ private: DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS]; int numDrawCalls; + int decimationCounter_; + UVScale *uvScale; };