diff options
Diffstat (limited to 'src/mesa/tnl/t_imm_api.c')
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index a67851df13..f477a351b2 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_api.c,v 1.26 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_imm_api.c,v 1.27 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -49,9 +49,15 @@ /* A cassette is full or flushed on a statechange. */ -void _tnl_flush_immediate( struct immediate *IM ) +void _tnl_flush_immediate( GLcontext *ctx, struct immediate *IM ) { - GLcontext *ctx = IM->backref; + if (!ctx) { + /* We were called by glVertex, glEvalCoord, glArrayElement, etc. + * The current context is corresponds to the IM structure. + */ + GET_CURRENT_CONTEXT(context); + ctx = context; + } if (MESA_VERBOSE & VERBOSE_IMMEDIATE) fprintf(stderr, "_tnl_flush_immediate IM: %d compiling: %d\n", @@ -87,7 +93,7 @@ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) if (IM->Flag[IM->Start]) if ((flags & FLUSH_UPDATE_CURRENT) || IM->Count > IM->Start) - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( ctx, IM ); } @@ -110,10 +116,17 @@ _tnl_save_Begin( GLenum mode ) if (ctx->NewState) _mesa_update_state(ctx); + /* if only a very few slots left, might as well flush now + */ + if (IM->Count > IMM_MAXDATA-8) { + _tnl_flush_immediate( ctx, IM ); + IM = TNL_CURRENT_IM(ctx); + } + /* Check for and flush buffered vertices from internal operations. */ if (IM->SavedBeginState) { - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( ctx, IM ); IM = TNL_CURRENT_IM(ctx); IM->BeginState = IM->SavedBeginState; IM->SavedBeginState = 0; @@ -246,7 +259,7 @@ _tnl_hard_begin( GLcontext *ctx, GLenum p ) _mesa_update_state(ctx); if (IM->Count > IMM_MAXDATA-8) { - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( ctx, IM ); IM = TNL_CURRENT_IM(ctx); } @@ -356,8 +369,9 @@ _tnl_end( GLcontext *ctx ) /* You can set this flag to get the old 'flush_vb on glEnd()' * behaviour. */ + /* XXXX tempory change here */ if (1 /*(MESA_DEBUG_FLAGS&DEBUG_ALWAYS_FLUSH)*/ ) - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( ctx, IM ); } void @@ -727,7 +741,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) ASSIGN_4V(dest, x, y, 0, 1); \ /* ASSERT(IM->Flag[IM->Count]==0); */ \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #define VERTEX3(IM,x,y,z) \ @@ -738,7 +752,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) ASSIGN_4V(dest, x, y, z, 1); \ /* ASSERT(IM->Flag[IM->Count]==0); */ \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #define VERTEX4(IM, x,y,z,w) \ @@ -748,7 +762,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) IM->Flag[count] |= VERT_BITS_OBJ_234; \ ASSIGN_4V(dest, x, y, z, w); \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #if defined(USE_IEEE) @@ -763,7 +777,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) dest[3].i = IEEE_ONE; \ /* ASSERT(IM->Flag[IM->Count]==0); */ \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #else #define VERTEX2F VERTEX2 @@ -781,7 +795,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) dest[3].i = IEEE_ONE; \ /* ASSERT(IM->Flag[IM->Count]==0); */ \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #else #define VERTEX3F VERTEX3 @@ -798,7 +812,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) dest[2].i = ((fi_type *)&(z))->i; \ dest[3].i = ((fi_type *)&(w))->i; \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #else #define VERTEX4F VERTEX4 @@ -992,7 +1006,7 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) IM->Flag[count] |= VERT_BIT_EVAL_C1; \ ASSIGN_4V(dest, x, 0, 0, 1); \ if (count == IMM_MAXDATA-1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #define EVALCOORD2(IM, x, y) \ @@ -1002,7 +1016,7 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) IM->Flag[count] |= VERT_BIT_EVAL_C2; \ ASSIGN_4V(dest, x, y, 0, 1); \ if (count == IMM_MAXDATA-1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #define EVALPOINT1(IM, x) \ @@ -1012,7 +1026,7 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) IM->Flag[count] |= VERT_BIT_EVAL_P1; \ ASSIGN_4V(dest, x, 0, 0, 1); \ if (count == IMM_MAXDATA-1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } #define EVALPOINT2(IM, x, y) \ @@ -1022,7 +1036,7 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) IM->Flag[count] |= VERT_BIT_EVAL_P2; \ ASSIGN_4V(dest, x, y, 0, 1); \ if (count == IMM_MAXDATA-1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } static void @@ -1082,7 +1096,7 @@ _tnl_EvalPoint2( GLint i, GLint j ) IM->FlushElt = IM->ArrayEltFlush; \ IM->Count += IM->ArrayEltIncr; \ if (IM->Count == IMM_MAXDATA) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( NULL, IM ); \ } @@ -1136,7 +1150,7 @@ _tnl_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w if (index == 0) { IM->Count++; if (count == IMM_MAXDATA - 1) - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( NULL, IM ); } } } @@ -1153,7 +1167,7 @@ _tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) if (index == 0) { IM->Count++; if (count == IMM_MAXDATA - 1) - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( NULL, IM ); } } } @@ -1197,7 +1211,7 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ { - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( ctx, IM ); IM = TNL_CURRENT_IM(ctx); count = IM->Count; } @@ -1271,7 +1285,7 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ { - _tnl_flush_immediate( IM ); + _tnl_flush_immediate( ctx, IM ); } } |