From 9147aeaac70751bda3203b53e33baab8f29c6c96 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 14 Dec 2023 17:26:21 -0600 Subject: [PATCH] Add encoremap to textures-as-flats --- src/hardware/hw_cache.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 636836a64..bdb692fbb 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -895,7 +895,7 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap) patch = HWR_GetCachedGLPatch(flatlumpnum); grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; - if (!grmip->downloaded && !grmip->data) + if (!grmip->colormap) { if (!noencoremap && encoremap) colormap += COLORMAP_REMAPOFFSET; @@ -903,7 +903,10 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap) grmip->colormap = Z_Calloc(sizeof(*grmip->colormap), PU_HWRPATCHCOLMIPMAP, NULL); grmip->colormap->source = colormap; M_Memcpy(grmip->colormap->data, colormap, 256 * sizeof(UINT8)); + } + if (!grmip->downloaded && !grmip->data) + { HWR_CacheFlat(grmip, flatlumpnum); } @@ -942,8 +945,17 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap) // Generate flat if missing from the cache if (!grtex->mipmap.data && !grtex->mipmap.downloaded) + { HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum); + if (!noencoremap && encoremap) + { + grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); + grtex->mipmap.colormap->source = colormaps + COLORMAP_REMAPOFFSET; + M_Memcpy(grtex->mipmap.colormap->data, colormaps + COLORMAP_REMAPOFFSET, 256); + } + } + // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap);