From 27b4013c185722ff1a2089e86324d2621c76d269 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 9 Feb 2024 19:46:45 -0800 Subject: [PATCH] R_DrawColumn_Template: fix non-po2 column drawing - Fix for efd017085 - To preserve tutti-frutti fix, offset drawing with texheight, but detect po2 with sourcelength --- src/r_draw_column.cpp | 21 +++++---------------- src/r_plane.cpp | 1 + src/r_segs.cpp | 4 ++-- src/r_things.cpp | 2 -- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index 58aa7cf59..d9c1cf244 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -221,24 +221,13 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - heightmask = dc->texheight-1; - if (dc->sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc->sourcelength; - } + heightmask = dc->sourcelength-1; + npow2min = -1; + npow2max = dc->sourcelength; - if (dc->texheight & heightmask) // not a power of 2 -- killough + if (dc->sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; + heightmask = dc->texheight << FRACBITS; if (frac < 0) { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 5f43a5872..fba7de8a3 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -707,6 +707,7 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc)(drawcolumndata_t*), bo dc.texturemid = skytexturemid; dc.texheight = textureheight[skytexture] >>FRACBITS; + dc.sourcelength = dc.texheight; x = pl->minx; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index f27875f6f..6f0ca5224 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -131,7 +131,7 @@ static void R_Render2sidedMultiPatchColumn(drawcolumndata_t* dc, column_t *colum if (dc->yl <= dc->yh && dc->yh < vid.height && dc->yh > 0) { dc->source = (UINT8 *)column + 3; - dc->sourcelength = 0; + dc->sourcelength = lengthcol; if (brightmap != NULL) { dc->brightmap = (UINT8 *)brightmap + 3; @@ -1378,7 +1378,7 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m dc->source = R_GetColumn(texture, texturecolumn); dc->brightmap = (brightmapped ? R_GetBrightmapColumn(texture, texturecolumn) : NULL); dc->texheight = textureheight[texture] >> FRACBITS; - dc->sourcelength = 0; + dc->sourcelength = dc->texheight; R_SetColumnFunc(colfunctype, dc->brightmap != NULL); coldrawfunc_t* colfunccopy = colfunc; drawcolumndata_t dc_copy = *dc; diff --git a/src/r_things.cpp b/src/r_things.cpp index 3c2e9576f..2e948db57 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -689,7 +689,6 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t *bright { dc->source = (UINT8 *)column + 3; dc->sourcelength = column->length; - dc->texheight = column->length; if (brightmap != NULL) { dc->brightmap = (UINT8 *)brightmap + 3; @@ -776,7 +775,6 @@ void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t { dc->source = static_cast(ZZ_Alloc(column->length)); dc->sourcelength = column->length; - dc->texheight = column->length; for (s = (UINT8 *)column+2+column->length, d = dc->source; d < dc->source+column->length; --s) *d++ = *s;