cache holey columns for R_DrawWallColumn

kinda wasteful memory wise, and didnt even give that much of a speedup, so idk
maybe should just keep doing it at runtime and use vector storage or smth to avoid reallocs
This commit is contained in:
alufolie91 committed 2026-04-04 18:49:14 +02:00
1 parent c083a12c71
commit c885ecef39
5 files changed
+78 -33

No files matched your search

+64
View File
@@ -504,6 +504,45 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col)
return texturecache[tex] + LONG(texturecolumnofs[tex][wrap_column(tex, col)]);
}
static UINT8 ***holecols;
// used for R_DrawWallColumn
// convert "holey" columns into contigous columns
// filled with cyan in place of holes
UINT8 *R_GetHoleColumn(INT32 tex, INT32 col)
{
col = wrap_column(tex, col);
if (!holecols[tex][col])
{
UINT8 *src = texturecache[tex] + LONG(texturecolumnofs[tex][col]);
column_t *coldata = (column_t *)(src - 3);
INT32 texheight = textureheight[tex] >> FRACBITS;
UINT8 *holecole = Z_Malloc(texheight, PU_STATIC, NULL);
// fill in everything with cyan so we can skip it
memset(holecole, TRANSPARENTPIXEL, texheight);
// shamelessly copy pasted from R_GenerateTexture
INT32 topdelta, prevdelta = -1;
while (coldata->topdelta != 0xff)
{
topdelta = coldata->topdelta;
if (topdelta <= prevdelta)
topdelta += prevdelta;
prevdelta = topdelta;
memcpy(holecole + topdelta, (UINT8*)coldata + 4, coldata->length);
coldata = (column_t *)((UINT8*)coldata + coldata->length + 4);
}
holecols[tex][col] = holecole;
}
return holecols[tex][col];
}
// convert flats to hicolor as they are requested
//
UINT8 *R_GetFlat(lumpnum_t flatlumpnum)
@@ -679,6 +718,30 @@ static INT32 R_CountTextures(UINT16 wadnum)
return count;
}
static void R_AllocHoleColes(INT32 add)
{
// only needed for software
if (rendermode != render_soft)
return;
const INT32 newtextures = (numtextures + add);
Z_Realloc(holecols, newtextures * sizeof(UINT8**), PU_STATIC, &holecols);
for (INT32 tex = numtextures; tex < newtextures; tex++)
{
// FIXME: kinda wasteful but idk how to make shit not die skipping textures without holes....
INT32 width = texturewidth[tex];
holecols[tex] = Z_Malloc(width * sizeof(UINT8*), PU_STATIC, NULL);
for (INT32 col = 0; col < width; col++)
{
holecols[tex][col] = NULL;
}
}
}
static void R_AllocateTextures(INT32 add)
{
const INT32 newtextures = (numtextures + add);
@@ -723,6 +786,7 @@ static INT32 R_DefineTextures(INT32 i, UINT16 w)
static void R_FinishLoadingTextures(INT32 add)
{
R_AllocHoleColes(add);
numtextures += add;
#ifdef HWRENDER
+1
View File
@@ -81,6 +81,7 @@ void R_CheckTextureCache(INT32 tex);
// Retrieve column data for span blitting.
UINT8 *R_GetColumn(fixed_t tex, INT32 col);
UINT8 *R_GetHoleColumn(INT32 tex, INT32 col);
UINT8 *R_GetFlat(lumpnum_t flatnum);
+2
View File
@@ -123,6 +123,8 @@ enum
COLDRAWFUNC_TRANSTRANS,
COLDRAWFUNC_TWOSMULTIPATCH,
COLDRAWFUNC_TWOSMULTIPATCHTRANS,
COLDRAWFUNC_TWOSMULTIPATCH_DIRECT,
COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT,
COLDRAWFUNC_FOG,
COLDRAWFUNC_MAX
+4 -31
View File
@@ -1168,7 +1168,6 @@ static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bott
static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t mid, fixed_t texturecolumn, INT32 texture, boolean remap)
{
UINT8 *holecol = NULL;
const INT32 itexturecolumn = texturecolumn >> FRACBITS;
dc->yl = yl;
dc->yh = yh;
@@ -1180,42 +1179,18 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m
R_SetColumnFunc(colfunctype);
coldrawfunc_t* colfunccopy = colfunc;
// ok so this thing cannot handle "holey" textures
// since it just reads the data as pixels directly
// but the holey ones dont have any data there or smth
// plug missing "data" with cyan so multipatch drawer can cut them
// fixes reading oob garbo and the "melty" effect on maps like spelunky or hyakaykuykiukikykooekyk streets
// caveat: this is mostly done on single sided walls which may cause some other issues, but mostly seems to work fineish
// this is probably inefficient as hell but oh well
if (textures[texture]->holes)
{
holecol = static_cast<UINT8*>(malloc(dc->texheight));
column_t *col = (column_t *)(dc->source - 3);
// fill in everything with cyan so we can skip it
memset(holecol, TRANSPARENTPIXEL, dc->texheight);
dc->source = R_GetHoleColumn(texture, itexturecolumn);
// shamelessly copy pasted from R_GenerateTexture
INT32 topdelta, prevdelta = -1;
while (col->topdelta != 0xff)
{
topdelta = col->topdelta;
if (topdelta <= prevdelta)
topdelta += prevdelta;
prevdelta = topdelta;
memcpy(holecol + topdelta, (UINT8*)col + 4, col->length);
col = (column_t *)((UINT8*)col + col->length + 4);
}
dc->source = holecol;
// so it can cut the "holes"
// need to use multipatch drawers to cut cyan pixels
if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true)
{
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS];
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT];
}
else
{
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH];
colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH_DIRECT];
}
}
@@ -1227,8 +1202,6 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m
}
colfunccopy(const_cast<drawcolumndata_t*>(&dc_copy));
free(holecol);
}
static boolean didsolidcol; // True if at least one column was marked solid
+7 -2
View File
@@ -106,6 +106,8 @@ static void SCR_SetDrawFuncs(enum columncontext_e _columncontext)
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_Flush;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_Flush;
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn_Flush;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_Flush;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_Flush;
}
else
{
@@ -114,10 +116,13 @@ static void SCR_SetDrawFuncs(enum columncontext_e _columncontext)
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed;
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn;
}
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn;
// gotta keep a copy of those for R_DrawWallColumn.....
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH_DIRECT] = R_Draw2sMultiPatchColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT] = R_Draw2sMultiPatchTranslucentColumn;
colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn;