Add floor32, ceil32, round32 compatibility functions for burnings renderer.

To avoid changing burnings now those functions have no IRRLICHT_FAST_MATH anymore, 
there's a new header irrMathFastCompat.h which has ..._fast functions doing the old behavior.
With the troubles they have documented.
I changed burnings to use those functions throughout.
Or as much as possible... Burnings probably also uses classes like SColor which also have functions 
using those, but I don't plan  to adapt them.
Maybe IRRLICHT_FAST_MATH should be a flag exlusive to burnings in the future, I don't think it makes 
much sense otherwise anymore (it often expects 32-bit asm).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6012 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2019-12-16 16:15:04 +00:00
parent 3acf725ae3
commit 3280b3319e
25 changed files with 289 additions and 161 deletions

@ -690,8 +690,8 @@ REALINLINE void CBurningShader_Raster_Reference::depthWrite ()
REALINLINE void CBurningShader_Raster_Reference::scanline2()
{
// apply top-left fill-convention, left
pShader.xStart = core::ceil32( line.x[0] );
pShader.xEnd = core::ceil32( line.x[1] ) - 1;
pShader.xStart = core::ceil32_fast( line.x[0] );
pShader.xEnd = core::ceil32_fast( line.x[1] ) - 1;
pShader.dx = pShader.xEnd - pShader.xStart;
if ( pShader.dx < 0 )
@ -755,8 +755,8 @@ REALINLINE void CBurningShader_Raster_Reference::scanline ()
u32 i;
// apply top-left fill-convention, left
pShader.xStart = core::ceil32( line.x[0] );
pShader.xEnd = core::ceil32( line.x[1] ) - 1;
pShader.xStart = core::ceil32_fast( line.x[0] );
pShader.xEnd = core::ceil32_fast( line.x[1] ) - 1;
pShader.dx = pShader.xEnd - pShader.xStart;
if ( pShader.dx < 0 )
@ -929,8 +929,8 @@ void CBurningShader_Raster_Reference::drawTriangle ( const s4DVertex *a,const s4
}
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -1043,8 +1043,8 @@ void CBurningShader_Raster_Reference::drawTriangle ( const s4DVertex *a,const s4
}
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
subPixel = ( (f32) yStart ) - b->Pos.y;

@ -1884,8 +1884,8 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core
core::recti clip=ViewPort;
if (ViewPort.getSize().Width != ScreenSize.Width)
{
dest.X=ViewPort.UpperLeftCorner.X+core::round32(destPos.X*ViewPort.getWidth()/(f32)ScreenSize.Width);
dest.Y=ViewPort.UpperLeftCorner.Y+core::round32(destPos.Y*ViewPort.getHeight()/(f32)ScreenSize.Height);
dest.X=ViewPort.UpperLeftCorner.X+core::round32_fast(destPos.X*ViewPort.getWidth()/(f32)ScreenSize.Width);
dest.Y=ViewPort.UpperLeftCorner.Y+core::round32_fast(destPos.Y*ViewPort.getHeight()/(f32)ScreenSize.Height);
if (clipRect)
{
clip.constrainTo(*clipRect);

@ -136,8 +136,8 @@ void CTRGouraud2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -351,8 +351,8 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -510,8 +510,8 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -142,8 +142,8 @@ void CTRGouraudAlpha2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -365,8 +365,8 @@ void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -524,8 +524,8 @@ void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -138,8 +138,8 @@ void CTRGouraudAlphaNoZ2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -363,8 +363,8 @@ void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,c
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -522,8 +522,8 @@ void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,c
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -145,8 +145,8 @@ void CTRNormalMap::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -476,8 +476,8 @@ void CTRNormalMap::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -683,8 +683,8 @@ void CTRNormalMap::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -169,8 +169,8 @@ void CTRStencilShadow::fragment_zfail_decr ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -326,8 +326,8 @@ void CTRStencilShadow::fragment_zfail_incr()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -559,8 +559,8 @@ void CTRStencilShadow::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -766,8 +766,8 @@ void CTRStencilShadow::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -255,8 +255,8 @@ void CTRTextureBlend::fragment_dst_color_src_alpha ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -439,8 +439,8 @@ void CTRTextureBlend::fragment_src_color_src_alpha ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -619,8 +619,8 @@ void CTRTextureBlend::fragment_one_one_minus_src_alpha()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -816,8 +816,8 @@ void CTRTextureBlend::fragment_one_minus_dst_alpha_one ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -1012,8 +1012,8 @@ void CTRTextureBlend::fragment_src_alpha_one ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -1239,8 +1239,8 @@ void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -1435,8 +1435,8 @@ void CTRTextureBlend::fragment_dst_color_zero ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -1629,8 +1629,8 @@ void CTRTextureBlend::fragment_dst_color_one ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -1826,8 +1826,8 @@ void CTRTextureBlend::fragment_zero_one_minus_scr_color ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -2092,8 +2092,8 @@ void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -2251,8 +2251,8 @@ void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -138,8 +138,8 @@ void CTRTextureDetailMap2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -360,8 +360,8 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -519,8 +519,8 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -137,8 +137,8 @@ void CTRTextureGouraud2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -380,8 +380,8 @@ void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,co
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -539,8 +539,8 @@ void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,co
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -137,8 +137,8 @@ void CTRTextureGouraudAdd2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -373,8 +373,8 @@ void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -532,8 +532,8 @@ void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -137,8 +137,8 @@ void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -348,8 +348,8 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -507,8 +507,8 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -115,9 +115,9 @@ CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(CBurningVideoDriver* driver)
void CTRTextureGouraudAlpha2::setParam ( u32 index, f32 value)
{
#ifdef BURNINGVIDEO_RENDERER_FAST
AlphaRef = core::floor32 ( value * 256.f );
AlphaRef = core::floor32_fast( value * 256.f );
#else
AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) );
AlphaRef = u32_to_fixPoint ( core::floor32_fast( value * 256.f ) );
#endif
}
@ -154,8 +154,8 @@ void CTRTextureGouraudAlpha2::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -441,8 +441,8 @@ void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -600,8 +600,8 @@ void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -115,9 +115,9 @@ CTRTextureGouraudAlphaNoZ::CTRTextureGouraudAlphaNoZ(CBurningVideoDriver* driver
void CTRTextureGouraudAlphaNoZ::setParam ( u32 index, f32 value)
{
#ifdef BURNINGVIDEO_RENDERER_FAST
AlphaRef = core::floor32 ( value * 256.f );
AlphaRef = core::floor32_fast( value * 256.f );
#else
AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) );
AlphaRef = u32_to_fixPoint ( core::floor32_fast( value * 256.f ) );
#endif
}
@ -154,8 +154,8 @@ void CTRTextureGouraudAlphaNoZ::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -440,8 +440,8 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVerte
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -599,8 +599,8 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVerte
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -142,8 +142,8 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -348,8 +348,8 @@ void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -507,8 +507,8 @@ void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -136,8 +136,8 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -384,8 +384,8 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -543,8 +543,8 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -137,8 +137,8 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -365,8 +365,8 @@ void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -524,8 +524,8 @@ void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -115,8 +115,8 @@ REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 ()
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
if ( dx < 0 )
@ -345,8 +345,8 @@ void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -505,8 +505,8 @@ void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -115,8 +115,8 @@ REALINLINE void CTRTextureLightMap2_M2::scanline_bilinear2 ()
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
if ( dx < 0 )
@ -345,8 +345,8 @@ void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -505,8 +505,8 @@ void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -115,8 +115,8 @@ REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_mag ()
fp24 *z;
// apply top-left fill-convention, left
const s32 xStart = irr::core::ceil32( line.x[0] );
const s32 xEnd = irr::core::ceil32( line.x[1] ) - 1;
const s32 xStart = irr::core::ceil32_fast( line.x[0] );
const s32 xEnd = irr::core::ceil32_fast( line.x[1] ) - 1;
s32 dx;
s32 i;
@ -260,8 +260,8 @@ REALINLINE void CTRTextureLightMap2_M4::scanline_bilinear2_min ()
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
if ( dx < 0 )
@ -481,8 +481,8 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -641,8 +641,8 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL
@ -855,8 +855,8 @@ void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -1015,8 +1015,8 @@ void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -137,8 +137,8 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
xStart = core::ceil32_fast( line.x[0] );
xEnd = core::ceil32_fast( line.x[1] ) - 1;
dx = xEnd - xStart;
@ -379,8 +379,8 @@ void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
yStart = core::ceil32_fast( a->Pos.y );
yEnd = core::ceil32_fast( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
@ -540,8 +540,8 @@ void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
yStart = core::ceil32_fast( b->Pos.y );
yEnd = core::ceil32_fast( c->Pos.y ) - 1;
#ifdef SUBTEXEL

@ -8,6 +8,7 @@
#include "SoftwareDriver2_compile_config.h"
#include "IReferenceCounted.h"
#include "irrMath.h"
#include "irrMathFastCompat.h"
#include "IImage.h"
#include "S2DVertex.h"
#include "rect.h"

@ -88,10 +88,10 @@ struct sCompressedVec4
void setColorf ( const video::SColorf & color )
{
argb = core::floor32 ( color.a * 255.f ) << 24 |
core::floor32 ( color.r * 255.f ) << 16 |
core::floor32 ( color.g * 255.f ) << 8 |
core::floor32 ( color.b * 255.f );
argb = core::floor32_fast( color.a * 255.f ) << 24 |
core::floor32_fast( color.r * 255.f ) << 16 |
core::floor32_fast( color.g * 255.f ) << 8 |
core::floor32_fast( color.b * 255.f );
}
void setVec4 ( const sVec4 & v );
@ -99,7 +99,7 @@ struct sCompressedVec4
// f = a * t + b * ( 1 - t )
void interpolate(const sCompressedVec4& a, const sCompressedVec4& b, const f32 t)
{
argb = PixelBlend32 ( b.argb, a.argb, core::floor32 ( t * 256.f ) );
argb = PixelBlend32 ( b.argb, a.argb, core::floor32_fast( t * 256.f ) );
}
@ -390,10 +390,10 @@ struct sVec3
inline void sCompressedVec4::setVec4 ( const sVec4 & v )
{
argb = core::floor32 ( v.x * 255.f ) << 24 |
core::floor32 ( v.y * 255.f ) << 16 |
core::floor32 ( v.z * 255.f ) << 8 |
core::floor32 ( v.w * 255.f );
argb = core::floor32_fast( v.x * 255.f ) << 24 |
core::floor32_fast( v.y * 255.f ) << 16 |
core::floor32_fast( v.z * 255.f ) << 8 |
core::floor32_fast( v.w * 255.f );
}

@ -12,6 +12,7 @@
#include "SoftwareDriver2_compile_config.h"
#include "irrMath.h"
#include "irrMathFastCompat.h"
#include "CSoftwareTexture2.h"
#include "SMaterial.h"

@ -0,0 +1,126 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_FAST_MATH_COMPAT_H_INCLUDED__
#define __IRR_FAST_MATH_COMPAT_H_INCLUDED__
#include "irrMath.h"
namespace irr
{
namespace core
{
// IRRLICHT_FAST_MATH functions which I wanted to kick out because they return
// wrong results. But last time I proposed that I've been asked to keep them for
// Burnings software renderer. So to avoid changing that accidentally or messing up
// it's speed I'll keep them around, but only as internal header.
// They should not be used otherwise any longer.
// Some examples for unexpected results when using this with IRRLICHT_FAST_MATH:
// Input 1, expected 1, got 0
// Input 3, expected 3, got 2
// Input -1.40129846e-45, expected -1, got 0
REALINLINE s32 floor32_fast(f32 x)
{
#ifdef IRRLICHT_FAST_MATH
const f32 h = 0.5f;
s32 t;
#if defined(_MSC_VER) && !defined(_WIN64)
__asm
{
fld x
fsub h
fistp t
}
#elif defined(__GNUC__)
__asm__ __volatile__ (
"fsub %2 \n\t"
"fistpl %0"
: "=m" (t)
: "t" (x), "f" (h)
: "st"
);
#else
return (s32) floorf ( x );
#endif
return t;
#else // no fast math
return (s32) floorf ( x );
#endif
}
// Some examples for unexpected results when using this with IRRLICHT_FAST_MATH:
// Input 1.40129846e-45, expected 1, got 0
// Input -1, expected -1, got 0
// Input -3, expected -3, got -2
REALINLINE s32 ceil32_fast ( f32 x )
{
#ifdef IRRLICHT_FAST_MATH
const f32 h = 0.5f;
s32 t;
#if defined(_MSC_VER) && !defined(_WIN64)
__asm
{
fld x
fadd h
fistp t
}
#elif defined(__GNUC__)
__asm__ __volatile__ (
"fadd %2 \n\t"
"fistpl %0 \n\t"
: "=m"(t)
: "t"(x), "f"(h)
: "st"
);
#else
return (s32) ceilf ( x );
#endif
return t;
#else // not fast math
return (s32) ceilf ( x );
#endif
}
// Some examples for unexpected results when using this with IRRLICHT_FAST_MATH:
// Input 0.5, expected 1, got 0
// Input 2.5, expected 3, got 2
// Input -1.40129846e-45, expected -nan(ind), got -inf
// Input -2.80259693e-45, expected -nan(ind), got -inf
REALINLINE s32 round32_fast(f32 x)
{
#if defined(IRRLICHT_FAST_MATH)
s32 t;
#if defined(_MSC_VER) && !defined(_WIN64)
__asm
{
fld x
fistp t
}
#elif defined(__GNUC__)
__asm__ __volatile__ (
"fistpl %0 \n\t"
: "=m"(t)
: "t"(x)
: "st"
);
#else
return (s32) round_(x);
#endif
return t;
#else // no fast math
return (s32) round_(x);
#endif
}
} // end namespace core
} // end namespace irr
#endif // __IRR_FAST_MATH_COMPAT_H_INCLUDED__