From 64959be33e1a6b4e18706774edb0fddf4c37ee3f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Oct 2019 01:01:38 +0200 Subject: [PATCH] - Don't use the global cache for caching tiles Sincce the cache is scheduled for removal anyway this makes no sense, this should be handled by a more generic texture eviction logic that's needed anyway to deal with accumulating texture data. --- source/common/textures/buildtiles.cpp | 10 ++++------ source/common/textures/textures.h | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/source/common/textures/buildtiles.cpp b/source/common/textures/buildtiles.cpp index b2ebeee74..6ab20ffd9 100644 --- a/source/common/textures/buildtiles.cpp +++ b/source/common/textures/buildtiles.cpp @@ -634,17 +634,15 @@ bool tileLoad(int tileNum) auto tex = TileFiles.tiles[tileNum]; if (!tex || tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false; if (tex->Get8BitPixels()) return true; - tex->CacheLock = 199; - if (!tex->CacheHandle) + if (!tex->CachedPixels.Size()) { // Allocate storage if necessary. - int size = tex->GetWidth() * tex->GetHeight(); - cacheAllocateBlock(&tex->CacheHandle, size, &tex->CacheLock); - tex->Create8BitPixels((uint8_t*)tex->CacheHandle); + tex->CachedPixels.Resize(tex->GetWidth() * tex->GetHeight()); + tex->Create8BitPixels(tex->CachedPixels.Data()); } return true; - } +} //========================================================================== diff --git a/source/common/textures/textures.h b/source/common/textures/textures.h index 7d9d35472..382c39a0b 100644 --- a/source/common/textures/textures.h +++ b/source/common/textures/textures.h @@ -304,8 +304,7 @@ protected: UseType useType = Image; PalEntry FloorSkyColor; PalEntry CeilingSkyColor; - intptr_t CacheHandle = 0; // For tiles that do not have a static image but get accessed by the software renderer. - uint8_t CacheLock = 0; + TArray CachedPixels; TArray Hightiles; // Don't waste too much effort on efficient storage here. Polymost performs so many calculations on a single draw call that the minor map lookup hardly matters. TMap HardwareTextures; // Note: These must be deleted by the backend. When the texture manager is taken down it may already be too late to delete them. @@ -576,7 +575,7 @@ inline const uint8_t* tilePtr(int num) auto tex = TileFiles.tiles[num]; auto p = tex->Get8BitPixels(); if (p) return p; - return (const uint8_t*)tex->CacheHandle; + return tex->CachedPixels.Data(); } inline uint8_t* tileData(int num)