1
0

Merging r6364 through r6379 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6380 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2022-05-04 21:38:12 +00:00
parent 993f990036
commit 67a488fc5c
227 changed files with 19006 additions and 5574 deletions

View File

@@ -26,11 +26,11 @@
// define render case
#ifdef BURNINGVIDEO_RENDERER_FAST
#define SUBTEXEL
#define INVERSE_W
#define SUBTEXEL
#define INVERSE_W
#else
#define SUBTEXEL
#define INVERSE_W
#define SUBTEXEL
#define INVERSE_W
#endif
//#define USE_ZBUFFER
@@ -43,42 +43,37 @@
//#define IPOL_T1
#if BURNING_MATERIAL_MAX_COLORS < 1
#undef IPOL_C0
#undef IPOL_C0
#endif
// apply global override
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
#undef INVERSE_W
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
#undef IPOL_W
#endif
#undef INVERSE_W
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
#undef IPOL_W
#endif
#endif
#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
#undef SUBTEXEL
#undef SUBTEXEL
#endif
#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
#define IPOL_Z
#define IPOL_Z
#ifdef CMP_W
#undef CMP_W
#define CMP_Z
#endif
#ifdef CMP_W
#undef CMP_W
#define CMP_Z
#endif
#ifdef WRITE_W
#undef WRITE_W
#define WRITE_Z
#endif
#ifdef WRITE_W
#undef WRITE_W
#define WRITE_Z
#endif
#endif
namespace irr
{
namespace video
{
burning_namespace_start
class CTRTextureGouraudNoZ2 : public IBurningShader
{
@@ -89,32 +84,34 @@ public:
//! draws an indexed triangle list
virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) IRR_OVERRIDE;
virtual void OnSetMaterial(const SBurningShaderMaterial& material) IRR_OVERRIDE;
virtual void OnSetMaterialBurning(const SBurningShaderMaterial& material) IRR_OVERRIDE;
virtual bool canWireFrame() IRR_OVERRIDE { return true; }
private:
// fragment shader
typedef void (CTRTextureGouraudNoZ2::* tFragmentShader) ();
void fragment_bilinear();
void fragment_no_filter();
void fragment_linear();
void fragment_nearest();
tFragmentShader fragmentShader;
};
//! constructor
CTRTextureGouraudNoZ2::CTRTextureGouraudNoZ2(CBurningVideoDriver* driver)
: IBurningShader(driver)
: IBurningShader(driver,EMT_SOLID)
{
#ifdef _DEBUG
#ifdef _DEBUG
setDebugName("CTRTextureGouraudNoZ2");
#endif
#endif
fragmentShader = &CTRTextureGouraudNoZ2::fragment_bilinear;
fragmentShader = &CTRTextureGouraudNoZ2::fragment_linear;
}
/*!
*/
void CTRTextureGouraudNoZ2::OnSetMaterial(const SBurningShaderMaterial& material)
void CTRTextureGouraudNoZ2::OnSetMaterialBurning(const SBurningShaderMaterial& material)
{
if (material.org.TextureLayer[0].BilinearFilter ||
@@ -122,23 +119,23 @@ void CTRTextureGouraudNoZ2::OnSetMaterial(const SBurningShaderMaterial& material
material.org.TextureLayer[0].AnisotropicFilter
)
{
fragmentShader = &CTRTextureGouraudNoZ2::fragment_bilinear;
fragmentShader = &CTRTextureGouraudNoZ2::fragment_linear;
}
else
{
fragmentShader = &CTRTextureGouraudNoZ2::fragment_no_filter;
fragmentShader = &CTRTextureGouraudNoZ2::fragment_nearest;
}
}
/*!
*/
void CTRTextureGouraudNoZ2::fragment_bilinear()
void CTRTextureGouraudNoZ2::fragment_linear()
{
tVideoSample *dst;
tVideoSample* dst;
#ifdef USE_ZBUFFER
fp24 *z;
fp24* z;
#endif
s32 xStart;
@@ -164,16 +161,15 @@ void CTRTextureGouraudNoZ2::fragment_bilinear()
#endif
// apply top-left fill-convention, left
xStart = fill_convention_left( line.x[0] );
xEnd = fill_convention_right( line.x[1] );
xStart = fill_convention_left(line.x[0]);
xEnd = fill_convention_right(line.x[1]);
dx = xEnd - xStart;
if ( dx < 0 )
if (dx < 0)
return;
// slopes
const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] );
const f32 invDeltaX = fill_step_x(line.x[1] - line.x[0]);
#ifdef IPOL_Z
slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
@@ -211,10 +207,10 @@ void CTRTextureGouraudNoZ2::fragment_bilinear()
#endif
SOFTWARE_DRIVER_2_CLIPCHECK;
dst = (tVideoSample*)RenderTarget->getData() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
dst = (tVideoSample*)RenderTarget->getData() + (line.y * RenderTarget->getDimension().Width) + xStart;
#ifdef USE_ZBUFFER
z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
z = (fp24*)DepthBuffer->lock() + (line.y * RenderTarget->getDimension().Width) + xStart;
#endif
@@ -224,34 +220,37 @@ void CTRTextureGouraudNoZ2::fragment_bilinear()
tFixPoint ty0;
tFixPoint r0, g0, b0;
for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X)
for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X)
{
//if test active only first pixel
if ((0 == EdgeTestPass) & (i > line.x_edgetest)) break;
#ifdef CMP_Z
if ( line.z[0] < z[i] )
if (line.z[0] < z[i])
#endif
#ifdef CMP_W
if ( line.w[0] >= z[i] )
if (line.w[0] >= z[i])
#endif
scissor_test_x
{
#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);
//skybox
//dst[i] = getTexel_plain ( &IT[0], tx0, ty0 );
if_scissor_test_x
{
#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);
//skybox
//dst[i] = getTexel_plain ( &IT[0], tx0, ty0 );
getSample_texture ( r0, g0, b0, IT+0, tx0, ty0 );
dst[i] = fix_to_sample( r0, g0, b0 );
getSample_texture(r0, g0, b0, IT + 0, tx0, ty0);
dst[i] = fix_to_sample(r0, g0, b0);
#ifdef WRITE_Z
z[i] = line.z[0];
#endif
#ifdef WRITE_W
z[i] = line.w[0];
#endif
}
#ifdef WRITE_Z
z[i] = line.z[0];
#endif
#ifdef WRITE_W
z[i] = line.w[0];
#endif
}
#ifdef IPOL_Z
line.z[0] += slopeZ;
@@ -274,7 +273,7 @@ void CTRTextureGouraudNoZ2::fragment_bilinear()
/*!
*/
void CTRTextureGouraudNoZ2::fragment_no_filter()
void CTRTextureGouraudNoZ2::fragment_nearest()
{
tVideoSample* dst;
@@ -372,25 +371,25 @@ void CTRTextureGouraudNoZ2::fragment_no_filter()
#ifdef CMP_W
if (line.w[0] >= z[i])
#endif
//scissor_test_x
//scissor_test_x
{
#ifdef INVERSE_W
#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);
#endif
tx0 = tofix(line.t[0][0].x, inversew);
ty0 = tofix(line.t[0][0].y, inversew);
//skybox
dst[i] = getTexel_plain(&IT[0], tx0, ty0);
//getSample_texture ( r0, g0, b0, IT+0, tx0, ty0 );
//dst[i] = fix_to_sample( r0, g0, b0 );
#ifdef WRITE_Z
#ifdef WRITE_Z
z[i] = line.z[0];
#endif
#ifdef WRITE_W
#endif
#ifdef WRITE_W
z[i] = line.w[0];
#endif
#endif
}
#ifdef IPOL_Z
@@ -415,20 +414,20 @@ void CTRTextureGouraudNoZ2::fragment_no_filter()
void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c)
{
// sort on height, y
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
if (F32_A_GREATER_B(a->Pos.y, b->Pos.y)) swapVertexPointer(&a, &b);
if (F32_A_GREATER_B(b->Pos.y, c->Pos.y)) swapVertexPointer(&b, &c);
if (F32_A_GREATER_B(a->Pos.y, b->Pos.y)) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = fill_step_y( ca );
scan.invDeltaY[1] = fill_step_y( ba );
scan.invDeltaY[2] = fill_step_y( cb );
scan.invDeltaY[0] = fill_step_y(ca);
scan.invDeltaY[1] = fill_step_y(ba);
scan.invDeltaY[2] = fill_step_y(cb);
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
if (F32_LOWER_EQUAL_0(scan.invDeltaY[0]))
return;
// find if the major edge is left or right aligned
@@ -439,7 +438,7 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.left = (temp[0] * temp[3] - temp[1] * temp[2]) < 0.f ? 1 : 0;
scan.right = 1 - scan.left;
// calculate slopes for the major edge
@@ -480,7 +479,7 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
#endif
// rasterize upper sub-triangle
if (F32_GREATER_0(scan.invDeltaY[1]) )
if (F32_GREATER_0(scan.invDeltaY[1]))
{
// calculate slopes for top edge
scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1];
@@ -512,11 +511,11 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
#endif
// apply top-left fill convention, top part
yStart = fill_convention_left( a->Pos.y );
yEnd = fill_convention_right( b->Pos.y );
yStart = fill_convention_top(a->Pos.y);
yEnd = fill_convention_down(b->Pos.y);
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
subPixel = ((f32)yStart) - a->Pos.y;
// correct to pixel center
scan.x[0] += scan.slopeX[0] * subPixel;
@@ -550,7 +549,9 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
#endif
// rasterize the edge scanlines
for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y)
line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]);
for (line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y)
{
line.x[scan.left] = scan.x[0];
line.x[scan.right] = scan.x[1];
@@ -582,9 +583,10 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
// render a scanline
interlace_scanline
scissor_test_y
if_interlace_scanline
if_scissor_test_y
(this->*fragmentShader) ();
if (EdgeTestPass & edge_test_first_line) break;
scan.x[0] += scan.slopeX[0];
scan.x[1] += scan.slopeX[1];
@@ -618,10 +620,10 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
}
// rasterize lower sub-triangle
if (F32_GREATER_0(scan.invDeltaY[2]) )
if (F32_GREATER_0(scan.invDeltaY[2]))
{
// advance to middle point
if(F32_GREATER_0(scan.invDeltaY[1]) )
if (F32_GREATER_0(scan.invDeltaY[1]))
{
temp[0] = b->Pos.y - a->Pos.y; // dy
@@ -674,12 +676,12 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
#endif
// apply top-left fill convention, top part
yStart = fill_convention_left( b->Pos.y );
yEnd = fill_convention_right( c->Pos.y );
yStart = fill_convention_top(b->Pos.y);
yEnd = fill_convention_down(c->Pos.y);
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - b->Pos.y;
subPixel = ((f32)yStart) - b->Pos.y;
// correct to pixel center
scan.x[0] += scan.slopeX[0] * subPixel;
@@ -713,7 +715,9 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
#endif
// rasterize the edge scanlines
for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y)
line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]);
for (line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y)
{
line.x[scan.left] = scan.x[0];
line.x[scan.right] = scan.x[1];
@@ -744,9 +748,10 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
#endif
// render a scanline
interlace_scanline
scissor_test_y
if_interlace_scanline
if_scissor_test_y
(this->*fragmentShader) ();
if (EdgeTestPass & edge_test_first_line) break;
scan.x[0] += scan.slopeX[0];
scan.x[1] += scan.slopeX[1];
@@ -782,30 +787,21 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co
}
} // end namespace video
} // end namespace irr
burning_namespace_end
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
namespace irr
{
namespace video
{
burning_namespace_start
//! creates a flat triangle renderer
IBurningShader* createTRTextureGouraudNoZ2(CBurningVideoDriver* driver)
{
// ETR_TEXTURE_GOURAUD_NOZ
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CTRTextureGouraudNoZ2( driver );
#else
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CTRTextureGouraudNoZ2(driver);
#else
return 0;
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
}
} // end namespace video
} // end namespace irr
burning_namespace_end