optimise span drawers a little
This commit is contained in:
1 parent
ccb2c4ef18
commit
34933fdf82
1 file changed
+40
-33
+40
-33
@@ -542,16 +542,19 @@ void R_DrawTranslatedColumn_8(void)
|
||||
*/
|
||||
void R_DrawSpan_8 (void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
|
||||
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
|
||||
@@ -560,13 +563,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];
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
if (dest+8 > deststop)
|
||||
return;
|
||||
@@ -576,35 +578,35 @@ 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!
|
||||
dest[0] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[0] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[1] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[1] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[2] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[2] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[3] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[3] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[4] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[4] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[5] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[5] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[6] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[6] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[7] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
dest[7] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
@@ -613,7 +615,7 @@ void R_DrawSpan_8 (void)
|
||||
}
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
*dest++ = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
*dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
@@ -1281,15 +1283,20 @@ void R_DrawTranslucentSplat_8 (void)
|
||||
*/
|
||||
void R_DrawTranslucentSpan_8 (void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
UINT32 val;
|
||||
|
||||
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
|
||||
@@ -1298,57 +1305,57 @@ 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];
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
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!
|
||||
dest[0] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[0]);
|
||||
dest[0] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[0]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[1] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[1]);
|
||||
dest[1] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[1]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[2] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[2]);
|
||||
dest[2] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[2]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[3] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[3]);
|
||||
dest[3] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[3]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[4] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[4]);
|
||||
dest[4] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[4]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[5] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[5]);
|
||||
dest[5] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[5]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[6] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[6]);
|
||||
dest[6] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[6]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[7] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[7]);
|
||||
dest[7] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[7]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest += 8;
|
||||
count -= 8;
|
||||
}
|
||||
while (count--)
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
*dest = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + *dest);
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
Reference in new issue
Block a user