Commit af48d4e0 authored by engineer_apple's avatar engineer_apple

fix:wrong software shader used for alpha-blending

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5040 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 05839bee
This diff is collapsed.
......@@ -30,8 +30,6 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name,
DriverType = EDT_BURNINGSVIDEO;
ColorFormat = BURNINGSHADER_COLOR_FORMAT;
HasMipMaps = (Flags & GEN_MIPMAP) != 0;
HasAlpha = (Flags & HAS_ALPHA) != 0;
IsRenderTarget = (Flags & IS_RENDERTARGET) != 0;
memset32 ( MipMap, 0, sizeof ( MipMap ) );
......@@ -91,6 +89,9 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name,
OrigImageDataSizeInPixels = (f32) 0.3f * MipMap[0]->getImageDataSizeInPixels();
}
HasMipMaps = (Flags & GEN_MIPMAP) != 0;
HasAlpha = (Flags & HAS_ALPHA) != 0;
regenerateMipMapLevels(mipmapData);
}
......
......@@ -210,9 +210,7 @@ void CTRNormalMap::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
tFixPoint tx0, tx1;
tFixPoint ty0, ty1;
......@@ -256,10 +254,11 @@ void CTRNormalMap::scanline_bilinear ()
#endif
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
tx1 = tofix ( line.t[1][0].x );
ty1 = tofix ( line.t[1][0].y );
inversew = FIX_POINT_F32_MUL;
tx0 = tofix(line.t[0][0].x, inversew);
ty0 = tofix(line.t[0][0].y, inversew);
tx1 = tofix(line.t[1][0].x, inversew);
ty1 = tofix(line.t[1][0].y, inversew);
#ifdef IPOL_C0
r3 = tofix ( line.c[0][0].y );
......
......@@ -336,8 +336,8 @@ void CTRTextureBlend::fragment_dst_color_src_alpha ()
getSample_texture ( a0,r0,g0,b0,
&IT[0],
tofix ( line.t[0][0].x,iw),
tofix ( line.t[0][0].y,iw)
tofix(line.t[0][0].x, iw),
tofix(line.t[0][0].y, iw)
);
color_to_fix ( r1, g1, b1, dst[i] );
......
......@@ -191,9 +191,7 @@ void CTRTextureDetailMap2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0, tx1;
tFixPoint ty0, ty1;
......@@ -215,18 +213,12 @@ void CTRTextureDetailMap2::scanline_bilinear ()
{
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
tx1 = tofix ( line.t[1][0].x,inversew);
ty1 = tofix ( line.t[1][0].y,inversew);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
tx1 = tofix ( line.t[1][0].x );
ty1 = tofix ( line.t[1][0].y );
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
getSample_texture ( r1, g1, b1, &IT[1], tx1,ty1 );
......
......@@ -190,9 +190,7 @@ void CTRTextureGouraud2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0;
tFixPoint ty0;
......@@ -236,8 +234,8 @@ void CTRTextureGouraud2::scanline_bilinear ()
#endif
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
tx0 = tofix(line.t[0][0].x, inversew);
ty0 = tofix(line.t[0][0].y, inversew);
#ifdef IPOL_C0
getTexel_plain2 ( r1, g1, b1, line.c[0][0] );
#endif
......
......@@ -190,9 +190,7 @@ void CTRTextureGouraudAdd2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
......@@ -226,31 +224,19 @@ void CTRTextureGouraudAdd2::scanline_bilinear ()
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
dst[i] = PixelAdd32 (
dst[i],
getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
d + tofix ( line.t[0][0].y,inversew) )
);
#else
dst[i] = PixelAdd32 (
dst[i],
getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y) )
);
#endif
#else
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
color_to_fix ( r1, g1, b1, dst[i] );
......
......@@ -190,9 +190,7 @@ void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
#endif
#ifdef IPOL_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0;
tFixPoint ty0;
......@@ -211,13 +209,9 @@ void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
{
#ifdef IPOL_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
......
......@@ -207,9 +207,7 @@ void CTRTextureGouraudAlpha2::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
u32 dIndex = ( line.y & 3 ) << 2;
......@@ -240,21 +238,13 @@ void CTRTextureGouraudAlpha2::scanline_bilinear ()
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
d + tofix ( line.t[0][0].y,inversew)
);
#else
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y)
);
#endif
const u32 alpha = ( argb >> 24 );
if ( alpha > AlphaRef )
{
......
......@@ -207,9 +207,7 @@ void CTRTextureGouraudAlphaNoZ::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
u32 dIndex = ( line.y & 3 ) << 2;
......@@ -240,21 +238,12 @@ void CTRTextureGouraudAlphaNoZ::scanline_bilinear ()
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
d + tofix ( line.t[0][0].y,inversew)
);
#else
u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y)
);
#endif
const u32 alpha = ( argb >> 24 );
if ( alpha > AlphaRef )
{
......
......@@ -195,9 +195,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0;
tFixPoint ty0;
......@@ -215,13 +213,9 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( )
{
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
dst[i] = getTexel_plain ( &IT[0], tx0, ty0 );
/*
......
......@@ -189,9 +189,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
//#define __TEST_THIS
......@@ -236,23 +234,12 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( )
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
#ifdef IPOL_C0
a3 = tofix ( line.c[0][0].y,inversew );
#endif
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#ifdef IPOL_C0
a3 = tofix ( line.c[0][0].y );
#endif
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
......
......@@ -190,6 +190,7 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
#endif
f32 inversew = FIX_POINT_F32_MUL;
#ifdef BURNINGVIDEO_RENDERER_FAST
......@@ -223,9 +224,8 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
#ifdef BURNINGVIDEO_RENDERER_FAST
#ifdef INVERSE_W
const f32 inversew = fix_inverse32 ( line.w[0] );
inversew = fix_inverse32 ( line.w[0] );
#endif
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
dst[i] = PixelAdd32 (
......@@ -234,17 +234,6 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x,inversew),
d + tofix ( line.t[1][0].y,inversew) )
);
#else
const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
dst[i] = PixelAdd32 (
getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
d + tofix ( line.t[0][0].y) ),
getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x),
d + tofix ( line.t[1][0].y) )
);
#endif
#else
const f32 inversew = fix_inverse32 ( line.w[0] );
......
......@@ -190,9 +190,7 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
#endif
#ifdef INVERSE_W
f32 inversew;
#endif
f32 inversew = FIX_POINT_F32_MUL;
tFixPoint tx0, tx1;
tFixPoint ty0, ty1;
......@@ -216,7 +214,7 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
{
#ifdef INVERSE_W
inversew = fix_inverse32 ( line.w[0] );
#endif
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
tx1 = tofix ( line.t[1][0].x,inversew);
......@@ -228,19 +226,6 @@ void CTRGTextureLightMap2_M4::scanline_bilinear ()
b3 = tofix ( line.c[0][0].w ,inversew );
#endif
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
tx1 = tofix ( line.t[1][0].x );
ty1 = tofix ( line.t[1][0].y );
#ifdef IPOL_C0
r3 = tofix ( line.c[0][0].y );
g3 = tofix ( line.c[0][0].z );
b3 = tofix ( line.c[0][0].w );
#endif
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 );
getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 );
......
......@@ -644,9 +644,9 @@ inline void getTexel_plain2 ( tFixPoint &r, tFixPoint &g, tFixPoint &b,
const sVec4 &v
)
{
r = tofix ( v.y );
g = tofix ( v.z );
b = tofix ( v.w );
r = tofix(v.y, FIX_POINT_F32_MUL);
g = tofix(v.z, FIX_POINT_F32_MUL);
b = tofix(v.w, FIX_POINT_F32_MUL);
}
/*
......@@ -656,7 +656,7 @@ inline void getSample_color ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoin
const sVec4 &v
)
{
a = tofix ( v.x );
a = tofix(v.x, FIX_POINT_F32_MUL);
r = tofix ( v.y, COLOR_MAX * FIX_POINT_F32_MUL);
g = tofix ( v.z, COLOR_MAX * FIX_POINT_F32_MUL);
b = tofix ( v.w, COLOR_MAX * FIX_POINT_F32_MUL);
......
......@@ -77,7 +77,7 @@
// mip mapping
#if defined ( SOFTWARE_DRIVER_2_MIPMAPPING )
#if defined( BURNINGVIDEO_RENDERER_BEAUTIFUL )
#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8
#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 16
#define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0
#elif defined ( BURNINGVIDEO_RENDERER_CE )
#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4
......@@ -91,7 +91,7 @@
#define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0
#endif
#define SOFTWARE_DRIVER_2_MIPMAPPING_SCALE (8/SOFTWARE_DRIVER_2_MIPMAPPING_MAX)
#define SOFTWARE_DRIVER_2_MIPMAPPING_SCALE (16/SOFTWARE_DRIVER_2_MIPMAPPING_MAX)
#ifndef REALINLINE
#ifdef _MSC_VER
......
......@@ -461,10 +461,7 @@ inline u32 fixPointu_to_u32 (const tFixPointu x)
// 1/x * FIX_POINT
REALINLINE f32 fix_inverse32 ( const f32 x )
{
return FIX_POINT_F32_MUL / x;
}
#define fix_inverse32(x) (FIX_POINT_F32_MUL / (x))
/*
......@@ -483,11 +480,11 @@ static inline int f_round2(f32 f)
convert f32 to Fix Point.
multiply is needed anyway, so scale mulby
*/
REALINLINE tFixPoint tofix (const f32 x, const f32 mulby = FIX_POINT_F32_MUL )
REALINLINE tFixPoint tofix0 (const f32 x, const f32 mulby = FIX_POINT_F32_MUL )
{
return (tFixPoint) (x * mulby);
}
#define tofix(x,y) (tFixPoint)(x * y)
/*
Fix Point , Fix Point Multiply
......@@ -820,7 +817,7 @@ inline void getSample_texture ( tFixPoint &r, tFixPoint &g, tFixPoint &b,
(tFixPointu &) b = (t00 & MASK_B) << ( FIX_POINT_PRE - SHIFT_B );
}
inline void getSample_texture ( tFixPointu &a, tFixPointu &r, tFixPointu &g, tFixPointu &b,
inline void getSample_texture ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b,
const sInternalTexture * t, const tFixPointu tx, const tFixPointu ty
)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment