mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 20:50:58 +00:00
Merge branch 'sw-npo2-span-opt' into 'next'
NPO2 span function optimization See merge request STJr/SRB2!1201
This commit is contained in:
commit
135d0f91b0
1 changed files with 160 additions and 54 deletions
|
@ -23,6 +23,8 @@ void R_DrawSpan_NPO2_8 (void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT8 *source;
|
UINT8 *source;
|
||||||
UINT8 *colormap;
|
UINT8 *colormap;
|
||||||
|
@ -41,19 +43,39 @@ void R_DrawSpan_NPO2_8 (void)
|
||||||
if (dest+8 > deststop)
|
if (dest+8 > deststop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
|
while (xposition < 0)
|
||||||
|
xposition += fixedwidth;
|
||||||
|
else
|
||||||
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
|
if (ystep < 0)
|
||||||
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
// Carefully align all of my Friends.
|
x = (xposition >> FRACBITS);
|
||||||
if (x < 0)
|
y = (yposition >> FRACBITS);
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
||||||
if (y < 0)
|
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
||||||
|
|
||||||
x %= ds_flatwidth;
|
|
||||||
y %= ds_flatheight;
|
|
||||||
|
|
||||||
*dest++ = colormap[source[((y * ds_flatwidth) + x)]];
|
*dest++ = colormap[source[((y * ds_flatwidth) + x)]];
|
||||||
xposition += xstep;
|
xposition += xstep;
|
||||||
|
@ -668,6 +690,8 @@ void R_DrawSplat_NPO2_8 (void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT8 *source;
|
UINT8 *source;
|
||||||
UINT8 *colormap;
|
UINT8 *colormap;
|
||||||
|
@ -684,20 +708,39 @@ void R_DrawSplat_NPO2_8 (void)
|
||||||
colormap = ds_colormap;
|
colormap = ds_colormap;
|
||||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
// Carefully align all of my Friends.
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
if (x < 0)
|
while (xposition < 0)
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
xposition += fixedwidth;
|
||||||
if (y < 0)
|
else
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
x %= ds_flatwidth;
|
if (ystep < 0)
|
||||||
y %= ds_flatheight;
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
|
x = (xposition >> FRACBITS);
|
||||||
|
y = (yposition >> FRACBITS);
|
||||||
val = source[((y * ds_flatwidth) + x)];
|
val = source[((y * ds_flatwidth) + x)];
|
||||||
if (val != TRANSPARENTPIXEL)
|
if (val != TRANSPARENTPIXEL)
|
||||||
*dest = colormap[val];
|
*dest = colormap[val];
|
||||||
|
@ -715,6 +758,8 @@ void R_DrawTranslucentSplat_NPO2_8 (void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT8 *source;
|
UINT8 *source;
|
||||||
UINT8 *colormap;
|
UINT8 *colormap;
|
||||||
|
@ -731,20 +776,39 @@ void R_DrawTranslucentSplat_NPO2_8 (void)
|
||||||
colormap = ds_colormap;
|
colormap = ds_colormap;
|
||||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
// Carefully align all of my Friends.
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
if (x < 0)
|
while (xposition < 0)
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
xposition += fixedwidth;
|
||||||
if (y < 0)
|
else
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
x %= ds_flatwidth;
|
if (ystep < 0)
|
||||||
y %= ds_flatheight;
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
|
x = (xposition >> FRACBITS);
|
||||||
|
y = (yposition >> FRACBITS);
|
||||||
val = source[((y * ds_flatwidth) + x)];
|
val = source[((y * ds_flatwidth) + x)];
|
||||||
if (val != TRANSPARENTPIXEL)
|
if (val != TRANSPARENTPIXEL)
|
||||||
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
||||||
|
@ -762,6 +826,8 @@ void R_DrawTranslucentSpan_NPO2_8 (void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT8 *source;
|
UINT8 *source;
|
||||||
UINT8 *colormap;
|
UINT8 *colormap;
|
||||||
|
@ -778,20 +844,39 @@ void R_DrawTranslucentSpan_NPO2_8 (void)
|
||||||
colormap = ds_colormap;
|
colormap = ds_colormap;
|
||||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
// Carefully align all of my Friends.
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
if (x < 0)
|
while (xposition < 0)
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
xposition += fixedwidth;
|
||||||
if (y < 0)
|
else
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
x %= ds_flatwidth;
|
if (ystep < 0)
|
||||||
y %= ds_flatheight;
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
|
x = (xposition >> FRACBITS);
|
||||||
|
y = (yposition >> FRACBITS);
|
||||||
val = ((y * ds_flatwidth) + x);
|
val = ((y * ds_flatwidth) + x);
|
||||||
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
||||||
dest++;
|
dest++;
|
||||||
|
@ -806,6 +891,8 @@ void R_DrawTranslucentWaterSpan_NPO2_8(void)
|
||||||
fixed_t xposition;
|
fixed_t xposition;
|
||||||
fixed_t yposition;
|
fixed_t yposition;
|
||||||
fixed_t xstep, ystep;
|
fixed_t xstep, ystep;
|
||||||
|
fixed_t x, y;
|
||||||
|
fixed_t fixedwidth, fixedheight;
|
||||||
|
|
||||||
UINT8 *source;
|
UINT8 *source;
|
||||||
UINT8 *colormap;
|
UINT8 *colormap;
|
||||||
|
@ -823,20 +910,39 @@ void R_DrawTranslucentWaterSpan_NPO2_8(void)
|
||||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||||
|
|
||||||
|
fixedwidth = ds_flatwidth << FRACBITS;
|
||||||
|
fixedheight = ds_flatheight << FRACBITS;
|
||||||
|
|
||||||
|
// Fix xposition and yposition if they are out of bounds.
|
||||||
|
if (xposition < 0)
|
||||||
|
xposition = fixedwidth - ((UINT32)(fixedwidth - xposition) % fixedwidth);
|
||||||
|
else if (xposition >= fixedwidth)
|
||||||
|
xposition %= fixedwidth;
|
||||||
|
if (yposition < 0)
|
||||||
|
yposition = fixedheight - ((UINT32)(fixedheight - yposition) % fixedheight);
|
||||||
|
else if (yposition >= fixedheight)
|
||||||
|
yposition %= fixedheight;
|
||||||
|
|
||||||
while (count-- && dest <= deststop)
|
while (count-- && dest <= deststop)
|
||||||
{
|
{
|
||||||
fixed_t x = (xposition >> FRACBITS);
|
// The loops here keep the texture coordinates within the texture.
|
||||||
fixed_t y = (yposition >> FRACBITS);
|
// They will rarely iterate multiple times, and are cheaper than a modulo operation,
|
||||||
|
// even if using libdivide.
|
||||||
// Carefully align all of my Friends.
|
if (xstep < 0) // These if statements are hopefully hoisted by the compiler to above this loop
|
||||||
if (x < 0)
|
while (xposition < 0)
|
||||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
xposition += fixedwidth;
|
||||||
if (y < 0)
|
else
|
||||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
while (xposition >= fixedwidth)
|
||||||
|
xposition -= fixedwidth;
|
||||||
x %= ds_flatwidth;
|
if (ystep < 0)
|
||||||
y %= ds_flatheight;
|
while (yposition < 0)
|
||||||
|
yposition += fixedheight;
|
||||||
|
else
|
||||||
|
while (yposition >= fixedheight)
|
||||||
|
yposition -= fixedheight;
|
||||||
|
|
||||||
|
x = (xposition >> FRACBITS);
|
||||||
|
y = (yposition >> FRACBITS);
|
||||||
*dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)];
|
*dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)];
|
||||||
xposition += xstep;
|
xposition += xstep;
|
||||||
yposition += ystep;
|
yposition += ystep;
|
||||||
|
|
Loading…
Reference in a new issue