diff --git a/source/Irrlicht/CBurningShader_Raster_Reference.cpp b/source/Irrlicht/CBurningShader_Raster_Reference.cpp index 4f1a4474..d12ed6c8 100644 --- a/source/Irrlicht/CBurningShader_Raster_Reference.cpp +++ b/source/Irrlicht/CBurningShader_Raster_Reference.cpp @@ -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; diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 47ce9396..2456a6f5 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -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); diff --git a/source/Irrlicht/CTRGouraud2.cpp b/source/Irrlicht/CTRGouraud2.cpp index fce5e494..194cc68b 100644 --- a/source/Irrlicht/CTRGouraud2.cpp +++ b/source/Irrlicht/CTRGouraud2.cpp @@ -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 diff --git a/source/Irrlicht/CTRGouraudAlpha2.cpp b/source/Irrlicht/CTRGouraudAlpha2.cpp index 889df1d0..837ab3e4 100644 --- a/source/Irrlicht/CTRGouraudAlpha2.cpp +++ b/source/Irrlicht/CTRGouraudAlpha2.cpp @@ -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 diff --git a/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp b/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp index e03fb192..b5453df0 100644 --- a/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp +++ b/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp @@ -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 diff --git a/source/Irrlicht/CTRNormalMap.cpp b/source/Irrlicht/CTRNormalMap.cpp index 61fc258e..bc72b75c 100644 --- a/source/Irrlicht/CTRNormalMap.cpp +++ b/source/Irrlicht/CTRNormalMap.cpp @@ -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 diff --git a/source/Irrlicht/CTRStencilShadow.cpp b/source/Irrlicht/CTRStencilShadow.cpp index 45a4c19e..02ed525d 100644 --- a/source/Irrlicht/CTRStencilShadow.cpp +++ b/source/Irrlicht/CTRStencilShadow.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureBlend.cpp b/source/Irrlicht/CTRTextureBlend.cpp index 472cd924..e3ba0791 100644 --- a/source/Irrlicht/CTRTextureBlend.cpp +++ b/source/Irrlicht/CTRTextureBlend.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureDetailMap2.cpp b/source/Irrlicht/CTRTextureDetailMap2.cpp index 88eb4c69..f5653ab5 100644 --- a/source/Irrlicht/CTRTextureDetailMap2.cpp +++ b/source/Irrlicht/CTRTextureDetailMap2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraud2.cpp b/source/Irrlicht/CTRTextureGouraud2.cpp index e1788a99..7bcc512b 100644 --- a/source/Irrlicht/CTRTextureGouraud2.cpp +++ b/source/Irrlicht/CTRTextureGouraud2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraudAdd2.cpp b/source/Irrlicht/CTRTextureGouraudAdd2.cpp index 1042341a..0f54928f 100644 --- a/source/Irrlicht/CTRTextureGouraudAdd2.cpp +++ b/source/Irrlicht/CTRTextureGouraudAdd2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp b/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp index e0fa1f97..1c7f586b 100644 --- a/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp +++ b/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraudAlpha.cpp b/source/Irrlicht/CTRTextureGouraudAlpha.cpp index f83a8d1a..37bb477c 100644 --- a/source/Irrlicht/CTRTextureGouraudAlpha.cpp +++ b/source/Irrlicht/CTRTextureGouraudAlpha.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp b/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp index d2104700..2830247e 100644 --- a/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp +++ b/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraudNoZ2.cpp b/source/Irrlicht/CTRTextureGouraudNoZ2.cpp index 3b10abff..6abc6e11 100644 --- a/source/Irrlicht/CTRTextureGouraudNoZ2.cpp +++ b/source/Irrlicht/CTRTextureGouraudNoZ2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp b/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp index 65e24b2a..8da8e872 100644 --- a/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp +++ b/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureLightMap2_Add.cpp b/source/Irrlicht/CTRTextureLightMap2_Add.cpp index 2aaa9f9b..db49d530 100644 --- a/source/Irrlicht/CTRTextureLightMap2_Add.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_Add.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureLightMap2_M1.cpp b/source/Irrlicht/CTRTextureLightMap2_M1.cpp index b5d741b5..71952749 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M1.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M1.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureLightMap2_M2.cpp b/source/Irrlicht/CTRTextureLightMap2_M2.cpp index f2bc7d4e..f748990b 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M2.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M2.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureLightMap2_M4.cpp b/source/Irrlicht/CTRTextureLightMap2_M4.cpp index c98f7cc7..3fd726cf 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M4.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M4.cpp @@ -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 diff --git a/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp b/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp index 742de513..64a14ab4 100644 --- a/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp +++ b/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp @@ -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 diff --git a/source/Irrlicht/IBurningShader.h b/source/Irrlicht/IBurningShader.h index 8e734ac3..0fffff7c 100644 --- a/source/Irrlicht/IBurningShader.h +++ b/source/Irrlicht/IBurningShader.h @@ -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" diff --git a/source/Irrlicht/S4DVertex.h b/source/Irrlicht/S4DVertex.h index b0f0436a..7ad6b83d 100644 --- a/source/Irrlicht/S4DVertex.h +++ b/source/Irrlicht/S4DVertex.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 ); } diff --git a/source/Irrlicht/SoftwareDriver2_helper.h b/source/Irrlicht/SoftwareDriver2_helper.h index 7a300da3..01e2f4f7 100644 --- a/source/Irrlicht/SoftwareDriver2_helper.h +++ b/source/Irrlicht/SoftwareDriver2_helper.h @@ -12,6 +12,7 @@ #include "SoftwareDriver2_compile_config.h" #include "irrMath.h" +#include "irrMathFastCompat.h" #include "CSoftwareTexture2.h" #include "SMaterial.h" diff --git a/source/Irrlicht/irrMathFastCompat.h b/source/Irrlicht/irrMathFastCompat.h new file mode 100644 index 00000000..19ce1ed6 --- /dev/null +++ b/source/Irrlicht/irrMathFastCompat.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__