diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 46966d52b4..1cd97926b7 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -125,7 +125,7 @@ struct PPGeTextDrawerImage { TextStringEntry entry; u32 ptr; }; -std::map textDrawerImages; +static std::map textDrawerImages; void PPGeSetDrawContext(Draw::DrawContext *draw) { g_draw = draw; @@ -199,9 +199,16 @@ static void EndVertexDataAndDraw(int prim) { static u32 __PPGeDoAlloc(u32 &size, bool fromTop, const char *name) { u32 ptr = kernelMemory.Alloc(size, fromTop, name); - // Didn't get it. - if (ptr == (u32)-1) - return 0; + // Didn't get it, try again after decimating images. + if (ptr == (u32)-1) { + PPGeDecimateTextImages(4); + PPGeImage::Decimate(4); + + ptr = kernelMemory.Alloc(size, fromTop, name); + if (ptr == (u32)-1) { + return 0; + } + } return ptr; } @@ -1283,9 +1290,8 @@ void PPGeImage::CompatLoad(u32 texture, int width, int height) { height_ = height; } -void PPGeImage::Decimate() { - static const int TOO_OLD_AGE = 30; - int tooOldFrame = gpuStats.numFlips - TOO_OLD_AGE; +void PPGeImage::Decimate(int age) { + int tooOldFrame = gpuStats.numFlips - age; for (size_t i = 0; i < loadedTextures_.size(); ++i) { if (loadedTextures_[i]->lastFrame_ < tooOldFrame) { loadedTextures_[i]->Free(); diff --git a/Core/Util/PPGeDraw.h b/Core/Util/PPGeDraw.h index 564f1e27ec..18f5867f15 100644 --- a/Core/Util/PPGeDraw.h +++ b/Core/Util/PPGeDraw.h @@ -133,7 +133,7 @@ public: return height_; } - static void Decimate(); + static void Decimate(int age = 30); private: static std::vector loadedTextures_;