fix columnbuf crashes
-our buffered uhh buffer needs to be only advanced per column not per screenwidth, caused the buffer to advance beyond its boundaries -brightmap drawers get the DC_DIRECT flag to make sure they never attempt to draw buffered removed tempbuffer alignment for now as reported by ubsan
This commit is contained in:
parent
2ce83bb48d
commit
e8e72db32f
4 changed files with 12 additions and 24 deletions
|
|
@ -546,22 +546,12 @@ void R_InitViewBuffer(INT32 width, INT32 height)
|
|||
|
||||
if (temp_dc.buf)
|
||||
{
|
||||
#if defined(__SSE__)
|
||||
aligned_free(temp_dc.buf);
|
||||
#else
|
||||
Z_Free(temp_dc.buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
memset(&temp_dc, 0, sizeof(temp_dc));
|
||||
|
||||
#if defined(__SSE__)
|
||||
while (bufsize & 15)
|
||||
bufsize++;
|
||||
temp_dc.buf = static_cast<UINT8*>(aligned_alloc(16, bufsize));
|
||||
#else
|
||||
temp_dc.buf = static_cast<UINT8*>(Z_Calloc(bufsize, PU_STATIC, NULL));
|
||||
#endif
|
||||
|
||||
linesize = vid.width; // killough 11/98
|
||||
renderscreen = vid.screens[0]; // haleyjd 07/02/14
|
||||
|
|
|
|||
|
|
@ -96,15 +96,9 @@ FUNCINLINE static ATTRINLINE constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t*
|
|||
}
|
||||
}
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_DIRECT)
|
||||
{ // if we dont buffer our columns, we need to handle translucency again
|
||||
// if we dont buffer our columns, we need to handle translucency again
|
||||
return R_GetColumnTranslucent<Type>(dc, dest, bit, col);
|
||||
}
|
||||
else
|
||||
{
|
||||
return R_GetColumnTranslated<Type>(dc, col);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief The R_DrawColumn function
|
||||
Experiment to make software go faster. Taken from the Boom source
|
||||
|
|
@ -115,7 +109,6 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
|||
INT32 count;
|
||||
UINT8 *dest;
|
||||
const INT32 vidheight = vid.height;
|
||||
const INT32 vidwidth = vid.width;
|
||||
|
||||
// leban 1/17/99:
|
||||
// removed the + 1 here, adjusted the if test, and added an increment
|
||||
|
|
@ -134,7 +127,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vidheight)
|
||||
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vidheight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -247,6 +240,11 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
|||
else
|
||||
dest = R_GetBufferOpaque(dc);
|
||||
|
||||
INT32 vidwidth = 8; //SoM: Oh, Oh it's MAGIC! You know...
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_DIRECT)
|
||||
vidwidth = vid.width;
|
||||
|
||||
count++;
|
||||
|
||||
// Determine scaling, which is the only mapping to be done.
|
||||
|
|
@ -367,7 +365,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
|||
|
||||
#define DEFINE_COLUMN_COMBO(name, flags) \
|
||||
DEFINE_COLUMN_FUNC(name, flags) \
|
||||
DEFINE_COLUMN_FUNC(name ## _Brightmap, flags|DC_BRIGHTMAP)
|
||||
DEFINE_COLUMN_FUNC(name ## _Brightmap, flags|DC_DIRECT|DC_BRIGHTMAP)
|
||||
|
||||
DEFINE_COLUMN_COMBO(R_DrawColumn, DC_DIRECT|DC_BASIC)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslucentColumn, DC_DIRECT|DC_TRANSMAP)
|
||||
|
|
|
|||
Loading…
Reference in a new issue