optimised enabling/disabling the clipping state
This commit is contained in:
parent
a0c5ddcb75
commit
6f7f3b5a91
|
@ -599,8 +599,20 @@ void RenderDrawTriangles_impl( void )
|
|||
#endif
|
||||
|
||||
OGLRender.NumberOfTriangles = 0;
|
||||
// Render the front buffer after each triangle sequence
|
||||
// (However, rendering each triangle seperately would be more correct)
|
||||
if (Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER)
|
||||
{
|
||||
glFlush();
|
||||
}
|
||||
s_Framebuffer.SetRenderBufferChanged();
|
||||
|
||||
// Clipping is turned off here per default to save the state-change call
|
||||
// for unclipped triangles. Usally this never triggers, so it's called
|
||||
// once per triangle sequence.
|
||||
// This allows for one call per triangle sequence + one call per clipped
|
||||
// triangle instead of one call for any (even unclipped) triangle
|
||||
SetClipVerticesState(false);
|
||||
|
||||
VERIFY_ACTIVE_TEXTURE_UNIT(OpenGL.ColorAlphaUnit1);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ bool s_bUpdateColorInvertState = false;
|
|||
bool s_bUpdateAlphaInvertState = false;
|
||||
bool s_bUpdateConstantColorValueState = false;
|
||||
bool s_bUpdateConstantColorValue4State = false;
|
||||
//bool s_bUpdateClipVerticesState = false;
|
||||
|
||||
bool s_bForceChromaKeyAndAlphaStateUpdate = false;
|
||||
|
||||
|
@ -1584,7 +1585,12 @@ void SetClipVerticesState_Update(bool clip_vertices)
|
|||
OpenGL.ClipVerticesEnabledState = clip_vertices;
|
||||
if (InternalConfig.EXT_clip_volume_hint)
|
||||
{
|
||||
RenderDrawTriangles();
|
||||
// If clipping is about to be turned off we have to render
|
||||
// any triangles to be rendered with clipping turned on
|
||||
if (!OpenGL.ClipVerticesEnabledState)
|
||||
{
|
||||
RenderDrawTriangles();
|
||||
}
|
||||
glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, clip_vertices ? GL_DONT_CARE : GL_FASTEST);
|
||||
#ifdef OPENGL_DEBUG
|
||||
GlideMsg("OpenGL.ClipVerticesEnabledState = %s\n", clip_vertices ? "GL_DONT_CARE" : "GL_FASTEST");
|
||||
|
|
|
@ -22,6 +22,7 @@ extern bool s_bUpdateColorInvertState;
|
|||
extern bool s_bUpdateAlphaInvertState;
|
||||
extern bool s_bUpdateConstantColorValueState;
|
||||
extern bool s_bUpdateConstantColorValue4State;
|
||||
//extern bool s_bUpdateClipVerticesState;
|
||||
|
||||
extern bool s_bForceChromaKeyAndAlphaStateUpdate;
|
||||
|
||||
|
@ -178,16 +179,21 @@ inline void SetConstantColorValue4State()
|
|||
s_bUpdateConstantColorValue4State = true;
|
||||
}
|
||||
|
||||
//inline void SetClipVerticesState()
|
||||
//{
|
||||
// s_bUpdateClipVerticesState = true;
|
||||
//}
|
||||
|
||||
// Also called from FrameBuffer class
|
||||
extern void SetClipVerticesState_Update(bool clip_vertices);
|
||||
|
||||
// Needs to be called before adding a triangle, line or point
|
||||
inline void SetClipVerticesState(bool clip)
|
||||
{
|
||||
bool clip_vertices = clip || OpenGL.Clipping;
|
||||
const bool clip_vertices = clip || OpenGL.Clipping;
|
||||
// Triggers very seldomly (because grDrawXXXWithClip() is used very seldom)
|
||||
// As a result this method is designed for cause the least cost when not being triggered
|
||||
if (clip_vertices != OpenGL.ClipVerticesEnabledState)
|
||||
if (clip_vertices != OpenGL.ClipVerticesEnabledState)
|
||||
{
|
||||
SetClipVerticesState_Update(clip_vertices);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include "GLRender.h"
|
||||
#include "GLRenderUpdateState.h"
|
||||
|
||||
//#define RENDER_FRONTBUFFER_IMMMEDIATE if (Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER){RenderDrawTriangles();glFlush();}
|
||||
#define RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
|
||||
//*************************************************
|
||||
//* Draws a Triangle on the screen
|
||||
//*************************************************
|
||||
|
@ -23,15 +26,9 @@ grDrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c )
|
|||
GlideMsg( "grDrawTriangle( ---, ---, --- )\n" );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
RenderAddTriangle( a, b, c, true );
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
|
@ -44,17 +41,12 @@ grDrawPlanarPolygonVertexList( int nVertices, const GrVertex vlist[] )
|
|||
GlideMsg("grDrawPlanarPolygonVertexList( %d, --- )\n", nVertices );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
for ( int i = 2; i < nVertices; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ 0 ], &vlist[ i - 1 ], &vlist[ i ], true );
|
||||
}
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
|
@ -67,9 +59,9 @@ grDrawLine( const GrVertex *a, const GrVertex *b )
|
|||
GlideMsg("grDrawLine( ---, --- )\n");
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
RenderAddLine( a, b, true );
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
|
@ -82,9 +74,9 @@ grDrawPoint( const GrVertex *a )
|
|||
GlideMsg( "grDrawPoint( --- )\n" );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
RenderAddPoint( a, true );
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
|
@ -97,8 +89,7 @@ grDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
|||
GlideMsg( "grDrawPolygon( %d, ---, --- )\n" );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
for ( int i = 2; i < nverts; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||
|
@ -106,12 +97,7 @@ grDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
|||
&vlist[ ilist[ i ] ],
|
||||
true );
|
||||
}
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
|
@ -124,8 +110,7 @@ grDrawPlanarPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
|||
GlideMsg( "grDrawPlanarPolygon( %d, ---, --- )\n", nverts );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
for ( int i = 2; i < nverts; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||
|
@ -133,12 +118,7 @@ grDrawPlanarPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
|
|||
&vlist[ ilist[ i ] ],
|
||||
true );
|
||||
}
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
|
@ -151,8 +131,7 @@ grDrawPolygonVertexList( int nVertices, const GrVertex vlist[] )
|
|||
GlideMsg( "grDrawPolygonVertexList( %d, --- )\n", nVertices );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
// SetClipVerticesState(false);
|
||||
for ( int i = 2; i < nVertices; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ 0 ],
|
||||
|
@ -160,11 +139,7 @@ grDrawPolygonVertexList( int nVertices, const GrVertex vlist[] )
|
|||
&vlist[ i ],
|
||||
true );
|
||||
}
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
|
@ -176,14 +151,8 @@ guAADrawTriangleWithClip( const GrVertex *a, const GrVertex *b,
|
|||
#endif
|
||||
|
||||
SetClipVerticesState(true);
|
||||
|
||||
RenderAddTriangle( a, b, c, false );
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
|
@ -196,14 +165,8 @@ guDrawTriangleWithClip( const GrVertex *a,
|
|||
#endif
|
||||
|
||||
SetClipVerticesState(true);
|
||||
|
||||
RenderAddTriangle( a, b, c, false );
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
|
@ -214,7 +177,6 @@ guDrawPolygonVertexListWithClip( int nVertices, const GrVertex vlist[] )
|
|||
#endif
|
||||
|
||||
SetClipVerticesState(true);
|
||||
|
||||
for ( int i = 2; i < nVertices; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ 0 ],
|
||||
|
@ -222,11 +184,7 @@ guDrawPolygonVertexListWithClip( int nVertices, const GrVertex vlist[] )
|
|||
&vlist[ i ],
|
||||
false );
|
||||
}
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
|
@ -236,69 +194,57 @@ grAADrawLine( const GrVertex *a, const GrVertex *b )
|
|||
GlideMsg( "grAADrawLine( ---, --- )\n" );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
RenderAddLine( a, b, true );
|
||||
// SetClipVerticesState(false);
|
||||
RenderAddLine( a, b, true );
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
grAADrawPoint(const GrVertex *a )
|
||||
{
|
||||
#ifdef OGL_CRITICAL
|
||||
GlideMsg("grAADrawPoint( --- )\n");
|
||||
GlideMsg("grAADrawPoint( --- )\n");
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
RenderAddPoint( a, true );
|
||||
// SetClipVerticesState(false);
|
||||
RenderAddPoint( a, true );
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
grAADrawPolygon( const int nverts, const int ilist[], const GrVertex vlist[] )
|
||||
{
|
||||
#ifdef OGL_CRITICAL
|
||||
GlideMsg( "grAADrawPolygon( %d, ---, --- )\n", nverts );
|
||||
GlideMsg( "grAADrawPolygon( %d, ---, --- )\n", nverts );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
for ( int i = 2; i < nverts; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||
&vlist[ ilist[ i - 1 ] ],
|
||||
&vlist[ ilist[ i ] ],
|
||||
true );
|
||||
}
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
// SetClipVerticesState(false);
|
||||
for ( int i = 2; i < nverts; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
|
||||
&vlist[ ilist[ i - 1 ] ],
|
||||
&vlist[ ilist[ i ] ],
|
||||
true );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
grAADrawPolygonVertexList( const int nverts, const GrVertex vlist[] )
|
||||
{
|
||||
#ifdef OGL_CRITICAL
|
||||
GlideMsg( "grAADrawPolygonVertexList( %d, --- )\n", nverts );
|
||||
GlideMsg( "grAADrawPolygonVertexList( %d, --- )\n", nverts );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
for ( int i = 2; i < nverts; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ 0 ],
|
||||
&vlist[ i - 1 ],
|
||||
&vlist[ i ],
|
||||
true );
|
||||
}
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
// SetClipVerticesState(false);
|
||||
for ( int i = 2; i < nverts; i++ )
|
||||
{
|
||||
RenderAddTriangle( &vlist[ 0 ],
|
||||
&vlist[ i - 1 ],
|
||||
&vlist[ i ],
|
||||
true );
|
||||
}
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
|
@ -310,13 +256,7 @@ grAADrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c,
|
|||
ab_antialias, bc_antialias, ca_antialias );
|
||||
#endif
|
||||
|
||||
SetClipVerticesState(false);
|
||||
|
||||
RenderAddTriangle( a, b, c, true );
|
||||
|
||||
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
|
||||
{
|
||||
RenderDrawTriangles( );
|
||||
glFlush( );
|
||||
}
|
||||
// SetClipVerticesState(false);
|
||||
RenderAddTriangle( a, b, c, true );
|
||||
RENDER_FRONTBUFFER_IMMMEDIATE
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue