- 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.
This commit is contained in:
Christoph Oelckers 2019-10-21 01:01:38 +02:00
parent 5333f6adc1
commit 64959be33e
2 changed files with 6 additions and 9 deletions

View file

@ -634,17 +634,15 @@ bool tileLoad(int tileNum)
auto tex = TileFiles.tiles[tileNum]; auto tex = TileFiles.tiles[tileNum];
if (!tex || tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false; if (!tex || tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false;
if (tex->Get8BitPixels()) return true; if (tex->Get8BitPixels()) return true;
tex->CacheLock = 199;
if (!tex->CacheHandle) if (!tex->CachedPixels.Size())
{ {
// Allocate storage if necessary. // Allocate storage if necessary.
int size = tex->GetWidth() * tex->GetHeight(); tex->CachedPixels.Resize(tex->GetWidth() * tex->GetHeight());
cacheAllocateBlock(&tex->CacheHandle, size, &tex->CacheLock); tex->Create8BitPixels(tex->CachedPixels.Data());
tex->Create8BitPixels((uint8_t*)tex->CacheHandle);
} }
return true; return true;
} }
//========================================================================== //==========================================================================

View file

@ -304,8 +304,7 @@ protected:
UseType useType = Image; UseType useType = Image;
PalEntry FloorSkyColor; PalEntry FloorSkyColor;
PalEntry CeilingSkyColor; PalEntry CeilingSkyColor;
intptr_t CacheHandle = 0; // For tiles that do not have a static image but get accessed by the software renderer. TArray<uint8_t> CachedPixels;
uint8_t CacheLock = 0;
TArray<HightileReplacement> Hightiles; TArray<HightileReplacement> 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. // 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<int, FHardwareTexture*> 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. TMap<int, FHardwareTexture*> 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 tex = TileFiles.tiles[num];
auto p = tex->Get8BitPixels(); auto p = tex->Get8BitPixels();
if (p) return p; if (p) return p;
return (const uint8_t*)tex->CacheHandle; return tex->CachedPixels.Data();
} }
inline uint8_t* tileData(int num) inline uint8_t* tileData(int num)