WIP: transpose software renderer
so far, level renders correctly some patches also render correctly everything else is still broken
This commit is contained in:
1 parent
513613d83b
commit
f10470fadf
5 files changed
+75
-44
No files matched your search
+1
-1
@@ -30,7 +30,7 @@ extern INT32 linesize;
|
||||
|
||||
FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py)
|
||||
{
|
||||
return renderscreen + (py + viewwindowy) * linesize + (viewwindowx + px);
|
||||
return renderscreen + (py + viewwindowy) + (viewwindowx + px) * vid.height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
const intptr_t heightmask = dc->sourcelength-1;
|
||||
constexpr INT32 npow2min = -1;
|
||||
const INT32 npow2max = dc->sourcelength;
|
||||
const INT32 stride = vid.width;
|
||||
const INT32 stride = 1;
|
||||
|
||||
const UINT8 * restrict source = dc->source;
|
||||
const lighttable_t * restrict colormap = dc->colormap;
|
||||
@@ -343,7 +343,7 @@ void R_DrawFogColumn(drawcolumndata_t* dc)
|
||||
// Framebuffer destination address.
|
||||
dest = R_Address(dc->x, dc->yl);
|
||||
|
||||
const INT32 stride = vid.width;
|
||||
const INT32 stride = 1;
|
||||
const lighttable_t * restrict colormap = dc->colormap;
|
||||
|
||||
// Determine scaling, which is the only mapping to be done.
|
||||
|
||||
+26
-13
@@ -107,9 +107,9 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
|
||||
UINT8 * restrict dsrc;
|
||||
|
||||
const UINT8 * restrict deststop = vid.screens[0] + vid.width * vid.height;
|
||||
const UINT8 * restrict deststop = vid.screens[0] + vid.height *vid.width;
|
||||
|
||||
if (dest+8 > deststop)
|
||||
if (dest > deststop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -140,14 +140,14 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
dsrc = vid.screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
|
||||
dsrc = vid.screens[1] + (ds->y + ds->bgofs) + ds->x1 * vid.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsrc = dest;
|
||||
}
|
||||
|
||||
while (count >= 8)
|
||||
/*while (count >= 8)
|
||||
{
|
||||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
@@ -167,7 +167,7 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
dsrc += 8;
|
||||
|
||||
count -= 8;
|
||||
}
|
||||
}*/
|
||||
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
@@ -175,8 +175,8 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
|
||||
dest++;
|
||||
dsrc++;
|
||||
dest += vid.height;
|
||||
dsrc += vid.height;
|
||||
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
@@ -239,7 +239,7 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
const INT32 nflatxshift = ds->nflatxshift;
|
||||
const INT32 nflatyshift = ds->nflatyshift;
|
||||
const INT32 nflatmask = ds->nflatmask;
|
||||
const INT32 stride = vid.width;
|
||||
const INT32 stride = vid.height;
|
||||
local_for_thread std::vector<INT32> tiltlighting;
|
||||
|
||||
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
@@ -309,16 +309,29 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
|
||||
x1 = ds->x1;
|
||||
|
||||
// not sure which one does a better job
|
||||
|
||||
/*for (i = SPANSIZE-1; i >= 0; i--)
|
||||
{
|
||||
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
dest += stride;
|
||||
dsrc += stride;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}*/
|
||||
|
||||
for (i = 0; i < SPANSIZE; i++)
|
||||
{
|
||||
bit = (((v + stepv * i) >> nflatyshift) & nflatmask) | ((u + stepu * i) >> nflatxshift);
|
||||
colormap = ds->planezlight[tiltlighting[x1 + i]] + (ds->colormap - colormaps);
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
|
||||
dest[i * stride] = R_DrawSpanPixel<Type>(ds, &dsrc[i * stride], colormap, bit, source);
|
||||
}
|
||||
|
||||
ds->x1 += SPANSIZE;
|
||||
dest += SPANSIZE;
|
||||
dsrc += SPANSIZE;
|
||||
dest += SPANSIZE * stride;
|
||||
dsrc += SPANSIZE * stride;
|
||||
startu = endu;
|
||||
startv = endv;
|
||||
width -= SPANSIZE;
|
||||
@@ -356,9 +369,9 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
dest++;
|
||||
dest += stride;
|
||||
ds->x1++;
|
||||
dsrc++;
|
||||
dsrc += stride;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
|
||||
+16
-7
@@ -1304,7 +1304,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
SDL_DestroyTexture(texture);
|
||||
}
|
||||
|
||||
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, height, width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1339,6 +1339,7 @@ void I_UpdateNoBlit(void)
|
||||
// I_FinishUpdate
|
||||
//
|
||||
static SDL_Rect src_rect = { 0, 0, 0, 0 };
|
||||
static SDL_Rect dst_rect = { 0, 0, 0, 0 };
|
||||
|
||||
void I_FinishUpdate(void)
|
||||
{
|
||||
@@ -1368,13 +1369,13 @@ void I_FinishUpdate(void)
|
||||
void *pixels;
|
||||
int pitch;
|
||||
SDL_LockTexture(texture, NULL, &pixels, &pitch);
|
||||
int step = pitch / 4 - vid.width;
|
||||
int step = pitch / 4 - vid.height;
|
||||
UINT32 *restrict dst = pixels;
|
||||
UINT8 *restrict src = vid.screens[0];
|
||||
UINT32 *restrict palette = localPalette;
|
||||
for (INT32 y = 0; y < vid.height; y++)
|
||||
for (INT32 y = 0; y < vid.width; y++)
|
||||
{
|
||||
UINT8 *restrict end = src + vid.width;
|
||||
UINT8 *restrict end = src + vid.height;
|
||||
do *dst++ = palette[*src++];
|
||||
while (src < end);
|
||||
dst += step;
|
||||
@@ -1382,7 +1383,8 @@ void I_FinishUpdate(void)
|
||||
SDL_UnlockTexture(texture);
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, &src_rect, NULL);
|
||||
//SDL_RenderCopy(renderer, texture, &src_rect, NULL);
|
||||
SDL_RenderCopyEx(renderer, texture, NULL, &dst_rect, 90.0, NULL, SDL_FLIP_VERTICAL);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
@@ -1562,8 +1564,15 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||
|
||||
src_rect.w = vid.width;
|
||||
src_rect.h = vid.height;
|
||||
src_rect.w = vid.height;
|
||||
src_rect.h = vid.width;
|
||||
|
||||
|
||||
dst_rect.x = (vid.width - vid.height) / 2;
|
||||
dst_rect.y = (vid.height - vid.width) / 2;
|
||||
dst_rect.w = vid.height;
|
||||
dst_rect.h = vid.width;
|
||||
|
||||
|
||||
refresh_rate = VID_GetRefreshRate();
|
||||
|
||||
|
||||
+30
-21
@@ -614,9 +614,12 @@ static void CV_constextsize_OnChange(void)
|
||||
// --------------------------------------------------------------------------
|
||||
void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes)
|
||||
{
|
||||
if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)width)
|
||||
//:skull:
|
||||
return;
|
||||
|
||||
if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)height)
|
||||
{
|
||||
size_t i = srcrowbytes * height;
|
||||
size_t i = srcrowbytes * width;
|
||||
#if defined(__SSE__)
|
||||
while (i >= 16)
|
||||
{
|
||||
@@ -631,9 +634,9 @@ void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr,
|
||||
}
|
||||
else
|
||||
{
|
||||
while (height--)
|
||||
while (width--)
|
||||
{
|
||||
M_Memcpy(destptr, srcptr, width);
|
||||
M_Memcpy(destptr, srcptr, height);
|
||||
|
||||
destptr += destrowbytes;
|
||||
srcptr += srcrowbytes;
|
||||
@@ -791,13 +794,10 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||
if (!desttop)
|
||||
return;
|
||||
|
||||
deststop = desttop + vid.width * vid.height;
|
||||
|
||||
if (scrn & V_NOSCALESTART)
|
||||
{
|
||||
x >>= FRACBITS;
|
||||
y >>= FRACBITS;
|
||||
desttop += (y*vid.width) + x;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -843,9 +843,9 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||
y += (vid.height - (BASEVIDHEIGHT * dup)) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
desttop += (y*vid.width) + x;
|
||||
}
|
||||
desttop += (x*vid.height) + y;
|
||||
|
||||
|
||||
if (pscale != FRACUNIT) // scale width properly
|
||||
{
|
||||
@@ -858,11 +858,11 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||
pwidth = patch->width * dup;
|
||||
|
||||
deststart = desttop;
|
||||
destend = desttop + pwidth;
|
||||
destend = desttop + pwidth*vid.height;
|
||||
|
||||
const INT32 stride = vid.width;
|
||||
|
||||
for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop++)
|
||||
for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop += vid.height)
|
||||
{
|
||||
INT32 topdelta, prevdelta = -1;
|
||||
if (scrn & V_FLIP) // offx is measured from right edge instead of left
|
||||
@@ -894,13 +894,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||
dest = desttop;
|
||||
if (scrn & V_FLIP)
|
||||
dest = deststart + (destend - desttop);
|
||||
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
|
||||
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
|
||||
|
||||
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
|
||||
deststop = col_start + vid.height;
|
||||
|
||||
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
|
||||
{
|
||||
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
|
||||
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
|
||||
*dest = source[ofs>>FRACBITS];
|
||||
dest += stride;
|
||||
dest++;
|
||||
}
|
||||
column = (const column_t *)((const UINT8 *)column + column->length + 4);
|
||||
}
|
||||
@@ -917,13 +920,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||
dest = desttop;
|
||||
if (scrn & V_FLIP)
|
||||
dest = deststart + (destend - desttop);
|
||||
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
|
||||
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
|
||||
|
||||
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
|
||||
deststop = col_start + vid.height;
|
||||
|
||||
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
|
||||
{
|
||||
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
|
||||
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
|
||||
*dest = *(v_colormap + source[ofs>>FRACBITS]);
|
||||
dest += stride;
|
||||
dest++;
|
||||
}
|
||||
column = (const column_t *)((const UINT8 *)column + column->length + 4);
|
||||
}
|
||||
@@ -940,13 +946,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
|
||||
dest = desttop;
|
||||
if (scrn & V_FLIP)
|
||||
dest = deststart + (destend - desttop);
|
||||
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
|
||||
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
|
||||
|
||||
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
|
||||
deststop = col_start + vid.height;
|
||||
|
||||
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
|
||||
{
|
||||
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
|
||||
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
|
||||
*dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff));
|
||||
dest += stride;
|
||||
dest++;
|
||||
}
|
||||
column = (const column_t *)((const UINT8 *)column + column->length + 4);
|
||||
}
|
||||
@@ -3810,7 +3819,7 @@ UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b)
|
||||
void V_Init(void)
|
||||
{
|
||||
INT32 i;
|
||||
INT32 screensize = vid.width * vid.height;
|
||||
INT32 screensize = vid.height * vid.width;
|
||||
|
||||
for (i = 0; i < NUMSCREENS; i++)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user