Fix GLENCORE memory leak, re-enable

This commit is contained in:
Eidolon 2023-12-12 07:10:32 -06:00
parent 66d3561fe8
commit b2b03ecbb5
4 changed files with 12 additions and 31 deletions

View file

@ -452,9 +452,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
UINT8 *pdata; UINT8 *pdata;
INT32 blockwidth, blockheight, blocksize; INT32 blockwidth, blockheight, blocksize;
#ifdef GLENCORE
UINT8 *colormap = colormaps; UINT8 *colormap = colormaps;
#endif
INT32 i; INT32 i;
boolean skyspecial = false; //poor hack for Legacy large skies.. boolean skyspecial = false; //poor hack for Legacy large skies..
@ -479,14 +477,12 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
grtex->mipmap.height = (UINT16)texture->height; grtex->mipmap.height = (UINT16)texture->height;
grtex->mipmap.format = textureformat; grtex->mipmap.format = textureformat;
#ifdef GLENCORE
if (encoremap) if (encoremap)
colormap += COLORMAP_REMAPOFFSET; colormap += COLORMAP_REMAPOFFSET;
grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL);
grtex->mipmap.colormap->source = colormap; grtex->mipmap.colormap->source = colormap;
M_Memcpy(grtex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); M_Memcpy(grtex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
#endif
blockwidth = texture->width; blockwidth = texture->width;
blockheight = texture->height; blockheight = texture->height;
@ -816,10 +812,8 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex)
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
{ {
#ifdef GLENCORE
UINT8 *flat; UINT8 *flat;
size_t steppy; size_t steppy;
#endif
size_t size, pflatsize; size_t size, pflatsize;
@ -861,12 +855,10 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
PU_HWRCACHE, &grMipmap->data)); PU_HWRCACHE, &grMipmap->data));
#ifdef GLENCORE
flat = grMipmap->data; flat = grMipmap->data;
for (steppy = 0; steppy < size; steppy++) for (steppy = 0; steppy < size; steppy++)
if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX) if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX)
flat[steppy] = grMipmap->colormap->source[flat[steppy]]; flat[steppy] = grMipmap->colormap->source[flat[steppy]];
#endif
} }
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
@ -895,9 +887,7 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap)
GLMipmap_t *grmip; GLMipmap_t *grmip;
patch_t *patch; patch_t *patch;
#ifdef GLENCORE
UINT8 *colormap = colormaps; UINT8 *colormap = colormaps;
#endif
if (flatlumpnum == LUMPERROR) if (flatlumpnum == LUMPERROR)
return; return;
@ -905,19 +895,17 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap)
patch = HWR_GetCachedGLPatch(flatlumpnum); patch = HWR_GetCachedGLPatch(flatlumpnum);
grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap;
#ifdef GLENCORE if (!grmip->downloaded && !grmip->data)
{
if (!noencoremap && encoremap) if (!noencoremap && encoremap)
colormap += COLORMAP_REMAPOFFSET; colormap += COLORMAP_REMAPOFFSET;
grmip->colormap = Z_Calloc(sizeof(*grmip->colormap), PU_HWRPATCHCOLMIPMAP, NULL); grmip->colormap = Z_Calloc(sizeof(*grmip->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
grmip->colormap->source = colormap; grmip->colormap->source = colormap;
M_Memcpy(grmip->colormap->data, colormap, 256 * sizeof(UINT8)); M_Memcpy(grmip->colormap->data, colormap, 256 * sizeof(UINT8));
#else
(void)noencoremap;
#endif
if (!grmip->downloaded && !grmip->data)
HWR_CacheFlat(grmip, flatlumpnum); HWR_CacheFlat(grmip, flatlumpnum);
}
// If hardware does not have the texture, then call pfnSetTexture to upload it // If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded) if (!grmip->downloaded)

View file

@ -30,7 +30,6 @@ extern "C" {
//#define HWR_LOADING_SCREEN //#define HWR_LOADING_SCREEN
// SRB2Kart // SRB2Kart
//#define GLENCORE
// ----------- // -----------
// structures // structures

View file

@ -5038,10 +5038,8 @@ static void HWR_ProjectSprite(mobj_t *thing)
{ {
vis->colormap = colormaps; vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP)) if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += COLORMAP_REMAPOFFSET; vis->colormap += COLORMAP_REMAPOFFSET;
#endif
} }
// set top/bottom coords // set top/bottom coords
@ -5176,10 +5174,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->colormap = NULL; vis->colormap = NULL;
#ifdef GLENCORE
if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += COLORMAP_REMAPOFFSET; vis->colormap += COLORMAP_REMAPOFFSET;
#endif
// set top/bottom coords // set top/bottom coords
vis->gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale); vis->gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale);

View file

@ -897,16 +897,14 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
#undef ALPHA2INT #undef ALPHA2INT
#undef HEX2INT #undef HEX2INT
#ifdef GLENCORE
if (encoremap) if (encoremap)
{ {
j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)]; UINT8 j = encoremap[NearestColor((UINT8)cr, (UINT8)cg, (UINT8)cb)];
//CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]);
cr = pLocalPalette[j].s.red; cr = pLocalPalette[j].s.red;
cg = pLocalPalette[j].s.green; cg = pLocalPalette[j].s.green;
cb = pLocalPalette[j].s.blue; cb = pLocalPalette[j].s.blue;
} }
#endif
// Pack rgba values into combined var // Pack rgba values into combined var
// OpenGL also uses this instead of lighttables for rendering // OpenGL also uses this instead of lighttables for rendering