burning v0.53

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6364 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
engineer_apple
2022-04-30 22:57:17 +00:00
parent 2d5673a1d4
commit 4fe6a16165
113 changed files with 4567 additions and 2853 deletions

View File

@ -9,26 +9,28 @@
#include "SoftwareDriver2_helper.h"
#include "irrAllocator.h"
#include "EPrimitiveTypes.h"
#include "SVertexIndex.h"
namespace irr
{
burning_namespace_start
namespace video
{
struct sVec4;
//! sVec2 used in BurningShader texture coordinates
struct sVec2
{
f32 x;
f32 y;
union
{
struct { f32 x, y; };
struct { f32 s, t; } st;
};
sVec2 () {}
sVec2() {}
sVec2 ( f32 s) : x ( s ), y ( s ) {}
sVec2 ( f32 _x, f32 _y )
: x ( _x ), y ( _y ) {}
sVec2(f32 s) : x(s), y(s) {}
sVec2(f32 _x, f32 _y)
: x(_x), y(_y) {}
void set ( f32 _x, f32 _y )
void set(f32 _x, f32 _y)
{
x = _x;
y = _y;
@ -37,8 +39,8 @@ struct sVec2
// f = a * t + b * ( 1 - t )
void interpolate(const sVec2& burning_restrict a, const sVec2& burning_restrict b, const ipoltype t)
{
x = (f32)(b.x + ( ( a.x - b.x ) * t ));
y = (f32)(b.y + ( ( a.y - b.y ) * t ));
x = (f32)(b.x + ((a.x - b.x) * t));
y = (f32)(b.y + ((a.y - b.y) * t));
}
sVec2 operator-(const sVec2& other) const
@ -59,10 +61,10 @@ struct sVec2
sVec2 operator*(const f32 s) const
{
return sVec2(x * s , y * s);
return sVec2(x * s, y * s);
}
void operator*=( const f32 s)
void operator*=(const f32 s)
{
x *= s;
y *= s;
@ -74,11 +76,29 @@ struct sVec2
y = other.y;
}
// shader
/*
void operator=(const core::vector2df& other)
{
x = other.X;
y = other.Y;
}
*/
sVec2 st_op() const
{
return sVec2(x,y);
}
sVec2& st_op()
{
return *this;
}
void operator=(const sVec4& other);
};
#include "irrpack.h"
//! sVec2Pack is Irrlicht S3DVertex,S3DVertex2TCoords,S3DVertexTangents Texutre Coordinates.
//! sVec2Pack is Irrlicht S3DVertex,S3DVertex2TCoords,S3DVertexTangents Texture Coordinates.
// Start address is not 4 byte aligned
struct sVec2Pack
{
@ -137,35 +157,36 @@ struct sVec3Pack
#include "irrunpack.h"
//! sVec4 used in Driver,BurningShader, direction/color
struct sVec4
struct ALIGN(16) sVec4
{
union
{
struct { f32 x, y, z, w; };
struct { f32 a, r, g, b; };
struct { f32 r, g, b, a; };
struct { f32 s, t, p, q; };
};
sVec4 () {}
sVec4 ( f32 _x, f32 _y, f32 _z, f32 _w )
: x ( _x ), y ( _y ), z( _z ), w ( _w ){}
sVec4() {}
sVec4(f32 _x, f32 _y, f32 _z, f32 _w)
: x(_x), y(_y), z(_z), w(_w) {}
// f = a * t + b * ( 1 - t )
void interpolate(const sVec4& burning_restrict a, const sVec4& burning_restrict b, const ipoltype t)
REALINLINE void interpolate(const sVec4& burning_restrict a, const sVec4& burning_restrict b, const ipoltype t)
{
x = (f32)(b.x + ( ( a.x - b.x ) * t ));
y = (f32)(b.y + ( ( a.y - b.y ) * t ));
z = (f32)(b.z + ( ( a.z - b.z ) * t ));
w = (f32)(b.w + ( ( a.w - b.w ) * t ));
x = (f32)(b.x + ((a.x - b.x) * t));
y = (f32)(b.y + ((a.y - b.y) * t));
z = (f32)(b.z + ((a.z - b.z) * t));
w = (f32)(b.w + ((a.w - b.w) * t));
}
sVec4 operator-(const sVec4& other) const
{
return sVec4(x - other.x, y - other.y, z - other.z,w - other.w);
return sVec4(x - other.x, y - other.y, z - other.z, w - other.w);
}
sVec4 operator+(const sVec4& other) const
{
return sVec4(x + other.x, y + other.y, z + other.z,w + other.w);
return sVec4(x + other.x, y + other.y, z + other.z, w + other.w);
}
void operator+=(const sVec4& other)
@ -178,15 +199,15 @@ struct sVec4
sVec4 operator*(const f32 s) const
{
return sVec4(x * s , y * s, z * s,w * s);
return sVec4(x * s, y * s, z * s, w * s);
}
sVec4 operator*(const sVec4 &other) const
sVec4 operator*(const sVec4& other) const
{
return sVec4(x * other.x , y * other.y, z * other.z,w * other.w);
return sVec4(x * other.x, y * other.y, z * other.z, w * other.w);
}
void operator*=(const sVec4 &other)
void operator*=(const sVec4& other)
{
x *= other.x;
y *= other.y;
@ -194,12 +215,13 @@ struct sVec4
w *= other.w;
}
void operator=(const sVec4& other)
sVec4& operator=(const sVec4& other)
{
x = other.x;
y = other.y;
z = other.z;
w = other.w;
return *this;
}
//outside shader
@ -210,13 +232,7 @@ struct sVec4
z = _z;
w = _w;
}
void setA8R8G8B8(const u32 argb)
{
a = ((argb & 0xFF000000) >> 24) * (1.f / 255.f);
r = ((argb & 0x00FF0000) >> 16) * (1.f / 255.f);
g = ((argb & 0x0000FF00) >> 8 ) * (1.f / 255.f);
b = ((argb & 0x000000FF) ) * (1.f / 255.f);
}
REALINLINE ipoltype dot_xyzw(const sVec4& other) const
{
@ -230,7 +246,7 @@ struct sVec4
REALINLINE f32 dot_minus_xyz(const sVec4& other) const
{
return -x * other.x + -y * other.y + -z * other.z;
return x * -other.x + y * -other.y + z * -other.z;
}
void mul_xyz(const f32 s)
@ -249,12 +265,41 @@ struct sVec4
{
//const f32 l = core::reciprocal_squareroot(x * x + y * y + z * z);
f32 l = x * x + y * y + z * z;
l = l > 0.0000001f ? 1.f / sqrtf(l) : 1.f;
x *= l;
y *= l;
z *= l;
if (l > 0.00000001f)
{
l = 1.f / sqrtf(l);
x *= l;
y *= l;
z *= l;
}
else
{
x = 0.f;
y = -1.f;
z = 0.f;
}
}
void normalize_dir_xyz_zero()
{
//const f32 l = core::reciprocal_squareroot(x * x + y * y + z * z);
f32 l = x * x + y * y + z * z;
if (l > 0.00000001f)
{
l = 1.f / sqrtf(l);
x *= l;
y *= l;
z *= l;
}
else
{
x = 0.f;
y = 0.f;
z = 0.f;
}
}
//unpack sVec3 to aligned during runtime
sVec4(const sVec3Pack& other)
@ -271,20 +316,36 @@ struct sVec4
f32 l = x * x + y * y + z * z;
l = l > 0.0000001f ? len / sqrtf(l) : 0.f;
out.x = (x*l) + ofs;
out.y = (y*l) + ofs;
out.z = (z*l) + ofs;
out.x = (x * l) + ofs;
out.y = (y * l) + ofs;
out.z = (z * l) + ofs;
}
};
//shader suppport
sVec4(const sVec4& a, double w)
{
x = a.x;
y = a.y;
z = a.z;
this->w = (float)w;
}
sVec4 xyz() const
{
return sVec4(x, y, z, 0.f);
}
//!during runtime sVec3Pack
typedef sVec4 sVec3Pack_unpack;
//operator f32* () { return &x; }
//!sVec4 is argb. sVec3Color is rgba
struct sVec3Color
{
f32 r, g, b,a;
void clampf01()
{
if (x < 0.f) x = 0.f; else if (x > 1.f) x = 1.f;
if (y < 0.f) y = 0.f; else if (y > 1.f) y = 1.f;
if (z < 0.f) z = 0.f; else if (z > 1.f) z = 1.f;
if (w < 0.f) w = 0.f; else if (w > 1.f) w = 1.f;
}
//Color
void setA8R8G8B8(const u32 argb);
void set(const f32 s)
{
@ -294,15 +355,101 @@ struct sVec3Color
a = s;
}
void setA8R8G8B8(const u32 argb)
void setColorf(const video::SColorf& color)
{
r = ((argb & 0x00FF0000) >> 16) * (1.f / 255.f);
g = ((argb & 0x0000FF00) >> 8 ) * (1.f / 255.f);
b = ((argb & 0x000000FF) ) * (1.f / 255.f);
a = ((argb & 0xFF000000) >> 24) * (1.f / 255.f);
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
void setColorf(const video::SColorf & color)
void add_rgb(const sVec4& other)
{
r += other.r;
g += other.g;
b += other.b;
}
void mad_rgb(const sVec4& other, const f32 v)
{
r += other.r * v;
g += other.g * v;
b += other.b * v;
}
void mad_rgbv(const sVec4& v0, const sVec4& v1)
{
r += v0.r * v1.r;
g += v0.g * v1.g;
b += v0.b * v1.b;
}
//sVec4 is a,r,g,b, alpha pass
/*
void sat(sVec4& dest, const u32 argb) const
{
dest.a = ((argb & 0xFF000000) >> 24) * (1.f / 255.f);
dest.r = r <= 1.f ? r : 1.f;
dest.g = g <= 1.f ? g : 1.f;
dest.b = b <= 1.f ? b : 1.f;
}
*/
void sat_alpha_pass(sVec4& dest, const f32 vertex_alpha) const
{
dest.a = vertex_alpha;
dest.r = r <= 1.f ? r : 1.f;
dest.g = g <= 1.f ? g : 1.f;
dest.b = b <= 1.f ? b : 1.f;
}
void sat_mul_xyz(sVec4& dest, const sVec4& v1) const
{
f32 v;
dest.a = 1.f;
v = r * v1.r; dest.r = v < 1.f ? v : 1.f;
v = g * v1.g; dest.g = v < 1.f ? v : 1.f;
v = b * v1.b; dest.b = v < 1.f ? v : 1.f;
}
void sat_mul_xyz(sVec3Pack& dest, const sVec4& v1) const
{
f32 v;
v = r * v1.r; dest.x = v < 1.f ? v : 1.f;
v = g * v1.g; dest.y = v < 1.f ? v : 1.f;
v = b * v1.b; dest.z = v < 1.f ? v : 1.f;
}
};
//shader
inline void irr::video::sVec2::operator=(const sVec4& b)
{
x = b.x;
y = b.y;
}
//!during runtime sVec3Pack
typedef sVec4 sVec3Pack_unpack;
typedef sVec4 sVec3Color;
#if 0
//!sVec4 is argb. sVec3Color is rgba
struct sVec3Color
{
f32 r, g, b, a;
void set(const f32 s)
{
r = s;
g = s;
b = s;
a = s;
}
void setColorf(const video::SColorf& color)
{
r = color.r;
g = color.g;
@ -332,7 +479,7 @@ struct sVec3Color
}
//sVec4 is a,r,g,b, alpha pass
void sat(sVec4 &dest, const u32 argb) const
void sat(sVec4& dest, const u32 argb) const
{
dest.a = ((argb & 0xFF000000) >> 24) * (1.f / 255.f);
dest.r = r <= 1.f ? r : 1.f;
@ -340,7 +487,7 @@ struct sVec3Color
dest.b = b <= 1.f ? b : 1.f;
}
void sat_xyz(sVec3Pack &dest, const sVec3Color& v1) const
void sat_xyz(sVec3Pack& dest, const sVec3Color& v1) const
{
f32 v;
v = r * v1.r; dest.x = v < 1.f ? v : 1.f;
@ -348,7 +495,7 @@ struct sVec3Color
v = b * v1.b; dest.z = v < 1.f ? v : 1.f;
}
void sat_xyz(sVec4 &dest, const sVec3Color& v1) const
void sat_xyz(sVec4& dest, const sVec3Color& v1) const
{
f32 v;
dest.a = 1.f;
@ -357,46 +504,47 @@ struct sVec3Color
v = b * v1.b; dest.b = v < 1.f ? v : 1.f;
}
};
#endif
//internal BurningShaderFlag for a Vertex
enum e4DVertexFlag
{
VERTEX4D_CLIPMASK = 0x0000003F,
VERTEX4D_CLIP_NEAR = 0x00000001,
VERTEX4D_CLIP_FAR = 0x00000002,
VERTEX4D_CLIP_LEFT = 0x00000004,
VERTEX4D_CLIP_RIGHT = 0x00000008,
VERTEX4D_CLIP_BOTTOM = 0x00000010,
VERTEX4D_CLIP_TOP = 0x00000020,
VERTEX4D_INSIDE = 0x0000003F,
VERTEX4D_CLIPMASK = 0x0000003F,
VERTEX4D_CLIP_NEAR = 0x00000001,
VERTEX4D_CLIP_FAR = 0x00000002,
VERTEX4D_CLIP_LEFT = 0x00000004,
VERTEX4D_CLIP_RIGHT = 0x00000008,
VERTEX4D_CLIP_BOTTOM = 0x00000010,
VERTEX4D_CLIP_TOP = 0x00000020,
VERTEX4D_INSIDE = 0x0000003F,
VERTEX4D_PROJECTED = 0x00000100,
VERTEX4D_VAL_ZERO = 0x00000200,
VERTEX4D_VAL_ONE = 0x00000400,
VERTEX4D_PROJECTED = 0x00000100,
//VERTEX4D_VAL_ZERO = 0x00000200,
//VERTEX4D_VAL_ONE = 0x00000400,
VERTEX4D_FORMAT_MASK = 0xFFFF0000,
VERTEX4D_FORMAT_MASK = 0xFFFF0000,
VERTEX4D_FORMAT_MASK_TEXTURE = 0x000F0000,
VERTEX4D_FORMAT_TEXTURE_1 = 0x00010000,
VERTEX4D_FORMAT_TEXTURE_2 = 0x00020000,
VERTEX4D_FORMAT_TEXTURE_3 = 0x00030000,
VERTEX4D_FORMAT_TEXTURE_4 = 0x00040000,
VERTEX4D_FORMAT_MASK_TEXTURE = 0x000F0000,
VERTEX4D_FORMAT_TEXTURE_1 = 0x00010000,
VERTEX4D_FORMAT_TEXTURE_2 = 0x00020000,
VERTEX4D_FORMAT_TEXTURE_3 = 0x00030000,
VERTEX4D_FORMAT_TEXTURE_4 = 0x00040000,
VERTEX4D_FORMAT_MASK_COLOR = 0x00F00000,
VERTEX4D_FORMAT_COLOR_1 = 0x00100000,
VERTEX4D_FORMAT_COLOR_2_FOG = 0x00200000,
VERTEX4D_FORMAT_COLOR_3 = 0x00300000,
VERTEX4D_FORMAT_COLOR_4 = 0x00400000,
VERTEX4D_FORMAT_MASK_COLOR = 0x00F00000,
VERTEX4D_FORMAT_COLOR_1 = 0x00100000,
VERTEX4D_FORMAT_COLOR_2_FOG = 0x00200000,
VERTEX4D_FORMAT_COLOR_3 = 0x00300000,
VERTEX4D_FORMAT_COLOR_4 = 0x00400000,
VERTEX4D_FORMAT_MASK_LIGHT = 0x0F000000,
VERTEX4D_FORMAT_LIGHT_1 = 0x01000000,
VERTEX4D_FORMAT_LIGHT_2 = 0x02000000,
VERTEX4D_FORMAT_MASK_LIGHT = 0x0F000000,
VERTEX4D_FORMAT_LIGHT_1 = 0x01000000,
VERTEX4D_FORMAT_LIGHT_2 = 0x02000000,
VERTEX4D_FORMAT_MASK_TANGENT = 0xF0000000,
VERTEX4D_FORMAT_BUMP_DOT3 = 0x10000000,
VERTEX4D_FORMAT_SPECULAR = 0x20000000,
VERTEX4D_FORMAT_MASK_TANGENT = 0xF0000000,
VERTEX4D_FORMAT_BUMP_DOT3 = 0x10000000,
VERTEX4D_FORMAT_SPECULAR = 0x20000000,
};
@ -418,28 +566,28 @@ enum e4DIndexType
{
E4IT_16BIT = 1, // EIT_16BIT,
E4IT_32BIT = 2, // EIT_32BIT,
E4IT_NONE = 4, //
E4IT_NONE = 4, //
};
#ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL
#define BURNING_MATERIAL_MAX_TEXTURES 4
#define BURNING_MATERIAL_MAX_COLORS 4
#define BURNING_MATERIAL_MAX_LIGHT_TANGENT 1
#if defined(BURNINGVIDEO_RENDERER_BEAUTIFUL) || defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
#define BURNING_MATERIAL_MAX_TEXTURES 4
#define BURNING_MATERIAL_MAX_COLORS 4
#define BURNING_MATERIAL_MAX_LIGHT_TANGENT 1
//ensure handcrafted sizeof(s4DVertex)
#define sizeof_s4DVertex 128
//ensure handcrafted sizeof(s4DVertex)
#define sizeof_s4DVertex 128
#else
#define BURNING_MATERIAL_MAX_TEXTURES 2
#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
#define BURNING_MATERIAL_MAX_COLORS 1
#else
#define BURNING_MATERIAL_MAX_COLORS 0
#endif
#define BURNING_MATERIAL_MAX_LIGHT_TANGENT 1
#define BURNING_MATERIAL_MAX_TEXTURES 2
#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
#define BURNING_MATERIAL_MAX_COLORS 1
#else
#define BURNING_MATERIAL_MAX_COLORS 0
#endif
#define BURNING_MATERIAL_MAX_LIGHT_TANGENT 1
//ensure handcrafted sizeof(s4DVertex)
#define sizeof_s4DVertex 64
//ensure handcrafted sizeof(s4DVertex)
#define sizeof_s4DVertex 64
#endif
// dummy Vertex. used for calculation vertex memory size
@ -467,10 +615,10 @@ struct s4DVertex
{
sVec4 Pos;
#if BURNING_MATERIAL_MAX_TEXTURES > 0
sVec2 Tex[ BURNING_MATERIAL_MAX_TEXTURES ];
sVec2 Tex[BURNING_MATERIAL_MAX_TEXTURES];
#endif
#if BURNING_MATERIAL_MAX_COLORS > 0
sVec4 Color[ BURNING_MATERIAL_MAX_COLORS ];
sVec4 Color[BURNING_MATERIAL_MAX_COLORS];
#endif
#if BURNING_MATERIAL_MAX_LIGHT_TANGENT > 0
sVec3Pack LightTangent[BURNING_MATERIAL_MAX_LIGHT_TANGENT];
@ -480,13 +628,13 @@ struct s4DVertex
#if BURNING_MATERIAL_MAX_COLORS < 1 || BURNING_MATERIAL_MAX_LIGHT_TANGENT < 1
u8 __align [sizeof_s4DVertex - sizeof (s4DVertex_proxy) ];
u8 __align[sizeof_s4DVertex - sizeof(s4DVertex_proxy)];
#endif
// f = a * t + b * ( 1 - t )
void interpolate(const s4DVertex& burning_restrict b, const s4DVertex& burning_restrict a, const ipoltype t)
REALINLINE void interpolate(const s4DVertex& burning_restrict b, const s4DVertex& burning_restrict a, const ipoltype t)
{
Pos.interpolate ( a.Pos, b.Pos, t );
Pos.interpolate(a.Pos, b.Pos, t);
#if 0
Tex[0].interpolate(a.Tex[0], b.Tex[0], t);
Tex[1].interpolate(a.Tex[1], b.Tex[1], t);
@ -499,45 +647,103 @@ struct s4DVertex
#if BURNING_MATERIAL_MAX_TEXTURES > 0
size = (flag & VERTEX4D_FORMAT_MASK_TEXTURE) >> 16;
for ( i = 0; i!= size; ++i )
for (i = 0; i != size; ++i)
{
Tex[i].interpolate ( a.Tex[i], b.Tex[i], t );
Tex[i].interpolate(a.Tex[i], b.Tex[i], t);
}
#endif
#if BURNING_MATERIAL_MAX_COLORS > 0
size = (flag & VERTEX4D_FORMAT_MASK_COLOR) >> 20;
for ( i = 0; i!= size; ++i )
for (i = 0; i != size; ++i)
{
Color[i].interpolate ( a.Color[i], b.Color[i], t );
Color[i].interpolate(a.Color[i], b.Color[i], t);
}
#endif
#if BURNING_MATERIAL_MAX_LIGHT_TANGENT > 0
size = (flag & VERTEX4D_FORMAT_MASK_LIGHT) >> 24;
for ( i = 0; i!= size; ++i )
for (i = 0; i != size; ++i)
{
LightTangent[i].interpolate ( a.LightTangent[i], b.LightTangent[i], t );
LightTangent[i].interpolate(a.LightTangent[i], b.LightTangent[i], t);
}
#endif
}
REALINLINE void reset_interpolate()
{
#if 1
#if BURNING_MATERIAL_MAX_TEXTURES > 0
Tex[0].x = 0.f;
Tex[0].y = 0.f;
#endif
#if BURNING_MATERIAL_MAX_TEXTURES > 1
Tex[1].x = 0.f;
Tex[1].y = 0.f;
#endif
#if BURNING_MATERIAL_MAX_TEXTURES > 2
Tex[2].x = 0.f;
Tex[2].y = 0.f;
#endif
#if BURNING_MATERIAL_MAX_TEXTURES > 3
Tex[3].x = 0.f;
Tex[3].y = 0.f;
#endif
#endif
#if BURNING_MATERIAL_MAX_COLORS > 0
Color[0].r = 0.f;
Color[0].g = 0.f;
Color[0].b = 0.f;
Color[0].a = 1.f;
#endif
#if BURNING_MATERIAL_MAX_COLORS > 1
//specular
Color[1].r = 0.f;
Color[1].g = 0.f;
Color[1].b = 0.f;
Color[1].a = 1.f;
#endif
#if BURNING_MATERIAL_MAX_COLORS > 2
Color[2].r = 0.f;
Color[2].g = 0.f;
Color[2].b = 0.f;
Color[2].a = 1.f;
#endif
#if BURNING_MATERIAL_MAX_COLORS > 3
Color[3].r = 0.f;
Color[3].g = 0.f;
Color[3].b = 0.f;
Color[3].a = 1.f;
#endif
#if BURNING_MATERIAL_MAX_LIGHT_TANGENT > 0
LightTangent[0].x = 0.f;
LightTangent[0].y = 0.f;
LightTangent[0].z = 0.f;
#endif
}
};
// ----------------- Vertex Cache ---------------------------
// Buffer is used as pairs of S4DVertex (0 ... ndc, 1 .. dc and projected)
// Buffer is used as interleaved pairs of S4DVertex (0 ... ndc, 1 .. dc and projected)
typedef s4DVertex s4DVertexPair;
#define sizeof_s4DVertexPairRel 2
#define s4DVertex_ofs(index) ((index)*sizeof_s4DVertexPairRel)
#define s4DVertex_proj(index) ((index)*sizeof_s4DVertexPairRel) + 1
#define s4DVertex_ofs(index) ((index)*sizeof_s4DVertexPairRel)
#define s4DVertex_pro(index) (((index)*sizeof_s4DVertexPairRel) + 1)
struct SAligned4DVertex
{
SAligned4DVertex()
:data(0),ElementSize(0),mem(0) {}
:data(0), ElementSize(0), mem(0) {}
virtual ~SAligned4DVertex ()
virtual ~SAligned4DVertex()
{
if (mem)
{
@ -581,17 +787,17 @@ static REALINLINE void memcpy_s4DVertexPair(void* burning_restrict dst, const vo
u64* burning_restrict dst64 = (u64*)dst;
const u64* burning_restrict src64 = (const u64*)src;
dst64[0] = src64[0];
dst64[1] = src64[1];
dst64[2] = src64[2];
dst64[3] = src64[3];
dst64[4] = src64[4];
dst64[5] = src64[5];
dst64[6] = src64[6];
dst64[7] = src64[7];
dst64[0] = src64[0];
dst64[1] = src64[1];
dst64[2] = src64[2];
dst64[3] = src64[3];
dst64[4] = src64[4];
dst64[5] = src64[5];
dst64[6] = src64[6];
dst64[7] = src64[7];
dst64[8] = src64[8];
dst64[9] = src64[9];
dst64[8] = src64[8];
dst64[9] = src64[9];
dst64[10] = src64[10];
dst64[11] = src64[11];
dst64[12] = src64[12];
@ -603,17 +809,17 @@ static REALINLINE void memcpy_s4DVertexPair(void* burning_restrict dst, const vo
u64* burning_restrict dst64 = (u64*)dst;
const u64* burning_restrict src64 = (const u64*)src;
dst64[0] = src64[0];
dst64[1] = src64[1];
dst64[2] = src64[2];
dst64[3] = src64[3];
dst64[4] = src64[4];
dst64[5] = src64[5];
dst64[6] = src64[6];
dst64[7] = src64[7];
dst64[0] = src64[0];
dst64[1] = src64[1];
dst64[2] = src64[2];
dst64[3] = src64[3];
dst64[4] = src64[4];
dst64[5] = src64[5];
dst64[6] = src64[6];
dst64[7] = src64[7];
dst64[8] = src64[8];
dst64[9] = src64[9];
dst64[8] = src64[8];
dst64[9] = src64[9];
dst64[10] = src64[10];
dst64[11] = src64[11];
dst64[12] = src64[12];
@ -656,13 +862,13 @@ static REALINLINE void memcpy_s4DVertexPair(void* burning_restrict dst, const vo
*dst32++ = *src32++;
len -= 32;
}
/*
while (len >= 4)
{
*dst32++ = *src32++;
len -= 4;
}
*/
/*
while (len >= 4)
{
*dst32++ = *src32++;
len -= 4;
}
*/
#endif
}
@ -670,14 +876,14 @@ static REALINLINE void memcpy_s4DVertexPair(void* burning_restrict dst, const vo
//! hold info for different Vertex Types
struct SVSize
{
size_t Format; // e4DVertexFlag VERTEX4D_FORMAT_MASK_TEXTURE
size_t Pitch; // sizeof Vertex
size_t TexSize; // amount Textures
size_t TexCooSize; // sizeof TextureCoordinates
u32 Format; // e4DVertexFlag VERTEX4D_FORMAT_MASK_TEXTURE
u32 Pitch; // sizeof Vertex
u32 TexSize; // amount Textures
u32 TexCooSize; // sizeof TextureCoordinates
};
// a cache info
// index cache info
struct SCacheInfo
{
u32 index;
@ -687,18 +893,14 @@ struct SCacheInfo
//must at least hold all possible (clipped) vertices of primitive.
#define VERTEXCACHE_ELEMENT 16
#define VERTEXCACHE_MISS 0xFFFFFFFF
struct SVertexCache
struct SVertexShader
{
SVertexCache () {}
~SVertexCache() {}
SVertexShader() {}
~SVertexShader() {}
//VertexType
SVSize vSize[E4VT_COUNT];
SCacheInfo info[VERTEXCACHE_ELEMENT];
SCacheInfo info_temp[VERTEXCACHE_ELEMENT];
// Transformed and lite, clipping state
// + Clipped, Projected
SAligned4DVertex mem;
@ -714,12 +916,50 @@ struct SVertexCache
u32 indicesPitch;
// primitives consist of x vertices
size_t primitiveHasVertex;
u32 primitiveHasVertex;
u32 primitiveRun;
e4DVertexType vType; //E_VERTEX_TYPE
scene::E_PRIMITIVE_TYPE pType; //scene::E_PRIMITIVE_TYPE
e4DIndexType iType; //E_INDEX_TYPE iType
REALINLINE u32 index(u32 i) const
{
u32 o;
if (i >= indexCount)
i = 0;
switch (iType)
{
case E4IT_16BIT: o = ((u16*)indices)[i]; break;
case E4IT_32BIT: o = ((u32*)indices)[i]; break;
default: case E4IT_NONE: o = i; break;
}
return o;
}
REALINLINE s4DVertexPair* vertex(const u32 sourceIndex) const
{
for (size_t i = 0; i < VERTEXCACHE_ELEMENT; ++i)
{
if (info[i].index == sourceIndex)
{
return mem.data + s4DVertex_ofs(i);
}
}
return mem.data; //error
}
void setPrimitiveType(const scene::E_PRIMITIVE_TYPE pType, const u32 primitiveCount);
void setIndices(const void* indices, const video::E_INDEX_TYPE iType);
SCacheInfo info[VERTEXCACHE_ELEMENT];
SCacheInfo info_temp[VERTEXCACHE_ELEMENT];
void set_info_miss();
u32 fillIndex;
void get_next_index_cacheline();
void getPrimitive(s4DVertexPair* face[4],CBurningVideoDriver* driver);
};
@ -804,8 +1044,8 @@ struct sScanLineData
// passed to pixel Shader
struct sPixelShaderData
{
tVideoSample *dst;
fp24 *z;
tVideoSample* dst;
fp24* z;
s32 xStart;
s32 xEnd;
@ -816,7 +1056,7 @@ struct sPixelShaderData
/*
load a color value
*/
REALINLINE void getTexel_plain2 ( tFixPoint &r, tFixPoint &g, tFixPoint &b,const sVec4 &v )
REALINLINE void getTexel_plain2(tFixPoint& r, tFixPoint& g, tFixPoint& b, const sVec4& v)
{
r = tofix(v.r, FIX_POINT_F32_MUL);
g = tofix(v.g, FIX_POINT_F32_MUL);
@ -827,22 +1067,22 @@ REALINLINE void getTexel_plain2 ( tFixPoint &r, tFixPoint &g, tFixPoint &b,const
/*
load a color value
*/
REALINLINE void getSample_color ( tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, const sVec4 &v )
REALINLINE void getSample_color(tFixPoint& a, tFixPoint& r, tFixPoint& g, tFixPoint& b, const sVec4& v)
{
a = tofix ( v.a, FIX_POINT_F32_MUL);
r = tofix ( v.r, COLOR_MAX * FIX_POINT_F32_MUL);
g = tofix ( v.g, COLOR_MAX * FIX_POINT_F32_MUL);
b = tofix ( v.b, COLOR_MAX * FIX_POINT_F32_MUL);
a = tofix(v.a, FIX_POINT_F32_MUL);
r = tofix(v.r, COLOR_MAX * FIX_POINT_F32_MUL);
g = tofix(v.g, COLOR_MAX * FIX_POINT_F32_MUL);
b = tofix(v.b, COLOR_MAX * FIX_POINT_F32_MUL);
}
/*
load a color value
*/
REALINLINE void getSample_color ( tFixPoint &r, tFixPoint &g, tFixPoint &b,const sVec4 &v )
REALINLINE void getSample_color(tFixPoint& r, tFixPoint& g, tFixPoint& b, const sVec4& v)
{
r = tofix ( v.r, COLOR_MAX * FIX_POINT_F32_MUL);
g = tofix ( v.g, COLOR_MAX * FIX_POINT_F32_MUL);
b = tofix ( v.b, COLOR_MAX * FIX_POINT_F32_MUL);
r = tofix(v.r, COLOR_MAX * FIX_POINT_F32_MUL);
g = tofix(v.g, COLOR_MAX * FIX_POINT_F32_MUL);
b = tofix(v.b, COLOR_MAX * FIX_POINT_F32_MUL);
}
#endif
@ -850,14 +1090,15 @@ REALINLINE void getSample_color ( tFixPoint &r, tFixPoint &g, tFixPoint &b,const
load a color value. mulby controls [0;1] or [0;ColorMax]
aka getSample_color
*/
REALINLINE void vec4_to_fix(tFixPoint &r, tFixPoint &g, tFixPoint &b,const sVec4 &v, const f32 mulby )
REALINLINE void vec4_to_fix(tFixPoint& r, tFixPoint& g, tFixPoint& b, const sVec4& v, const f32 mulby)
{
r = tofix(v.r, mulby);
g = tofix(v.g, mulby);
b = tofix(v.b, mulby);
}
REALINLINE void vec4_to_fix(tFixPoint &a,tFixPoint &r, tFixPoint &g, tFixPoint &b,const sVec4 &v, const f32 mulby)
REALINLINE void vec4_to_fix(tFixPoint& a, tFixPoint& r, tFixPoint& g, tFixPoint& b, const sVec4& v, const f32 mulby)
{
a = tofix(v.a, mulby);
r = tofix(v.r, mulby);
@ -865,9 +1106,5 @@ REALINLINE void vec4_to_fix(tFixPoint &a,tFixPoint &r, tFixPoint &g, tFixPoint &
b = tofix(v.b, mulby);
}
}
}
burning_namespace_end
#endif