fix: evict oldest minimap tile textures when cache exceeds 128 entries

Prevents unbounded GPU memory growth in long play sessions where the player
visits many zones. Tiles are inserted into a FIFO deque; when the count of
successfully-loaded tiles exceeds MAX_TILE_CACHE (128), the oldest entry is
destroyed and removed from both the cache map and the deque.

At 256×256×4 bytes per tile this caps minimap GPU usage at ~32 MB.
This commit is contained in:
Kelsi 2026-03-17 13:38:18 -07:00
parent 217edc81d9
commit a43a43ed8e
2 changed files with 14 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#include <memory>
#include <string>
#include <unordered_map>
#include <deque>
#include <algorithm>
namespace wowee {
@ -73,7 +74,10 @@ private:
bool trsParsed = false;
// Tile texture cache: hash → VkTexture
// Evicted (FIFO) when the count of successfully-loaded tiles exceeds MAX_TILE_CACHE.
static constexpr size_t MAX_TILE_CACHE = 128;
std::unordered_map<std::string, std::unique_ptr<VkTexture>> tileTextureCache;
std::deque<std::string> tileInsertionOrder; // hashes of successfully loaded tiles, oldest first
std::unique_ptr<VkTexture> noDataTexture;
// Composite render target (3x3 tiles = 768x768)