Revert "do some lööp unrolling for software span drawers"
This reverts commit 782e3172ad.
This commit is contained in:
1 parent
b21586a698
commit
bc2b85df0f
1 file changed
+54
-54
+54
-54
@@ -744,14 +744,17 @@ void R_DrawSpan_8 (void)
|
||||
fixed_t xstep, ystep;
|
||||
register UINT32 bit;
|
||||
|
||||
const UINT8 *source = ds_source;
|
||||
const UINT8 *colormap = ds_colormap;
|
||||
register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
register UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
register size_t count = (ds_x2 - ds_x1 + 1);
|
||||
size_t i;
|
||||
|
||||
xposition = ds_xfrac; yposition = ds_yfrac;
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
@@ -759,8 +762,12 @@ void R_DrawSpan_8 (void)
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
if (dest+8 > deststop)
|
||||
{
|
||||
@@ -772,27 +779,13 @@ void R_DrawSpan_8 (void)
|
||||
// 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
|
||||
// need!
|
||||
for (i = 0; i < 8; i += 8)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
dest[i] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + xstep) >> nflatxshift);
|
||||
dest[i+1] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + 2 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 2 * xstep) >> nflatxshift);
|
||||
dest[i+2] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + 3 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 3 * xstep) >> nflatxshift);
|
||||
dest[i+3] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + 4 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 4 * xstep) >> nflatxshift);
|
||||
dest[i+4] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + 5 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 5 * xstep) >> nflatxshift);
|
||||
dest[i+5] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + 6 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 6 * xstep) >> nflatxshift);
|
||||
dest[i+6] = colormap[source[bit]];
|
||||
bit = (((UINT32)(yposition + 7 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 7 * xstep) >> nflatxshift);
|
||||
dest[i+7] = colormap[source[bit]];
|
||||
|
||||
xposition += 8 * xstep;
|
||||
yposition += 8 * ystep;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
|
||||
dest += 8;
|
||||
@@ -815,13 +808,14 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
|
||||
{
|
||||
// ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version
|
||||
// of this function. Here's my own.
|
||||
INT32 i;
|
||||
INT32 left = ds_x1, right = ds_x2;
|
||||
fixed_t step = (end-start)/(ds_x2-ds_x1+1);
|
||||
INT32 i;
|
||||
|
||||
// I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once,
|
||||
// but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now...
|
||||
|
||||
for (i = ds_x1; i <= ds_x2; i++)
|
||||
for (i = left; i <= right; i++)
|
||||
{
|
||||
tiltlighting[i] = (start += step) >> FRACBITS;
|
||||
|
||||
@@ -843,6 +837,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
|
||||
*/
|
||||
void R_DrawTiltedSpan_8(void)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds_x2 - ds_x1;
|
||||
double iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
@@ -878,6 +873,7 @@ void R_DrawTiltedSpan_8(void)
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
source = ds_source;
|
||||
//colormap = ds_colormap;
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
@@ -905,6 +901,7 @@ void R_DrawTiltedSpan_8(void)
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
@@ -981,6 +978,7 @@ void R_DrawTiltedSpan_8(void)
|
||||
*/
|
||||
void R_DrawTiltedTranslucentSpan_8(void)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds_x2 - ds_x1;
|
||||
double iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
@@ -1016,6 +1014,7 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
source = ds_source;
|
||||
//colormap = ds_colormap;
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
@@ -1043,6 +1042,7 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
@@ -1120,6 +1120,7 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
||||
*/
|
||||
void R_DrawTiltedTranslucentWaterSpan_8(void)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds_x2 - ds_x1;
|
||||
double iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
@@ -1157,6 +1158,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
|
||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
|
||||
source = ds_source;
|
||||
//colormap = ds_colormap;
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
@@ -1184,6 +1186,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
@@ -1555,14 +1558,17 @@ void R_DrawTranslucentSpan_8 (void)
|
||||
fixed_t xstep, ystep;
|
||||
register UINT32 bit;
|
||||
|
||||
const UINT8 *source = ds_source;
|
||||
const UINT8 *colormap = ds_colormap;
|
||||
register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
register UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
register size_t count = (ds_x2 - ds_x1 + 1);
|
||||
size_t i;
|
||||
|
||||
xposition = ds_xfrac; yposition = ds_yfrac;
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
@@ -1570,27 +1576,24 @@ void R_DrawTranslucentSpan_8 (void)
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
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
|
||||
// need!
|
||||
for (i = 0; i < 8; i += 4)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
dest[i] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[i]);
|
||||
bit = (((UINT32)(yposition + ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + xstep) >> nflatxshift);
|
||||
dest[i+1] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[i+1]);
|
||||
bit = (((UINT32)(yposition + 2 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 2 * xstep) >> nflatxshift);
|
||||
dest[i+2] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[i+2]);
|
||||
bit = (((UINT32)(yposition + 3 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 3 * xstep) >> nflatxshift);
|
||||
dest[i+3] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[i+3]);
|
||||
|
||||
xposition += 4 * xstep;
|
||||
yposition += 4 * ystep;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
|
||||
dest += 8;
|
||||
@@ -1614,10 +1617,10 @@ void R_DrawTranslucentWaterSpan_8(void)
|
||||
UINT32 xstep, ystep;
|
||||
register UINT32 bit;
|
||||
|
||||
const UINT8 *source = ds_source;
|
||||
const UINT8 *colormap = ds_colormap;
|
||||
register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
register UINT8 *dsrc;
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
register UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
|
||||
register size_t count;
|
||||
size_t i;
|
||||
@@ -1632,6 +1635,9 @@ void R_DrawTranslucentWaterSpan_8(void)
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
@@ -1640,19 +1646,12 @@ void R_DrawTranslucentWaterSpan_8(void)
|
||||
// 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
|
||||
// need!
|
||||
for (i = 0; i < 8; i += 4)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
dest[i] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
|
||||
bit = (((UINT32)(yposition + ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + xstep) >> nflatxshift);
|
||||
dest[i+1] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
|
||||
bit = (((UINT32)(yposition + 2 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 2 * xstep) >> nflatxshift);
|
||||
dest[i+2] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
|
||||
bit = (((UINT32)(yposition + 3 * ystep) >> nflatyshift) & nflatmask) | ((UINT32)(xposition + 3 * xstep) >> nflatxshift);
|
||||
dest[i+3] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
|
||||
|
||||
xposition += 4 * xstep;
|
||||
yposition += 4 * ystep;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
|
||||
dest += 8;
|
||||
@@ -1680,6 +1679,7 @@ void R_DrawFogSpan_8(void)
|
||||
register size_t count;
|
||||
|
||||
colormap = ds_colormap;
|
||||
//dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dest = &topleft[ds_y *vid.width + ds_x1];
|
||||
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
Reference in new issue
Block a user