diff options
author | Brian Paul <[email protected]> | 2002-04-19 12:32:14 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-04-19 12:32:14 +0000 |
commit | 05be7ae1253ad68d80816395c3d09665e5619ebc (patch) | |
tree | aaa634bb60d5cbce9f5da87873ffc36f9b942da3 /src | |
parent | 0c527ab0546eb1de9ee10cc31bc386a40e6b3f98 (diff) |
pass context pointer to _tnl_free_immediate(), removed backref pointer
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/tnl/t_context.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 36 | ||||
-rw-r--r-- | src/mesa/tnl/t_eval_api.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.c | 7 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.h | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 58 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.h | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 6 |
9 files changed, 88 insertions, 43 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 7be74c61c6c..9d000d05280 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -1,4 +1,4 @@ -/* $Id: t_context.c,v 1.25 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_context.c,v 1.26 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -145,7 +145,7 @@ _tnl_DestroyContext( GLcontext *ctx ) _tnl_array_destroy( ctx ); _tnl_imm_destroy( ctx ); _tnl_destroy_pipeline( ctx ); - _tnl_free_immediate( tnl->freed_immediate ); + _tnl_free_immediate( ctx, tnl->freed_immediate ); FREE(tnl); ctx->swtnl_context = 0; diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 31d917f3d58..dc4cb3730cc 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.40 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_context.h,v 1.41 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -93,6 +93,39 @@ #define VERT_BIT_CLIP VERT_BIT_END /* vb only, reuse imm bit*/ +/* + * XXXX these are temporary - for backward compatibility w/ DRI drivers + */ +#define VERT_OBJ VERT_BIT_POS +#define VERT_RGBA VERT_BIT_COLOR0 +#define VERT_NORM VERT_BIT_NORMAL +#define VERT_INDEX VERT_BIT_INDEX +#define VERT_EDGE VERT_BIT_SEVEN +#define VERT_SPEC_RGB VERT_BIT_COLOR1 +#define VERT_FOG_COORD VERT_BIT_FOG +#define VERT_TEX0 VERT_BIT_TEX0 +#define VERT_TEX1 VERT_BIT_TEX1 +#define VERT_TEX2 VERT_BIT_TEX2 +#define VERT_TEX3 VERT_BIT_TEX3 +#define VERT_TEX4 VERT_BIT_TEX4 +#define VERT_TEX5 VERT_BIT_TEX5 +#define VERT_TEX6 VERT_BIT_TEX6 +#define VERT_TEX7 VERT_BIT_TEX7 +#define VERT_EVAL_C1 VERT_BIT_EVAL_C1 +#define VERT_EVAL_C2 VERT_BIT_EVAL_C2 +#define VERT_EVAL_P1 VERT_BIT_EVAL_P1 +#define VERT_EVAL_P2 VERT_BIT_EVAL_P2 +#define VERT_OBJ_3 VERT_BIT_OBJ_3 +#define VERT_OBJ_4 VERT_BIT_OBJ_4 +#define VERT_MATERIAL VERT_BIT_MATERIAL +#define VERT_ELT VERT_BIT_ELT +#define VERT_BEGIN VERT_BIT_BEGIN +#define VERT_END VERT_BIT_END +#define VERT_END_VB VERT_BIT_END_VB +#define VERT_POINT_SIZE VERT_BIT_POINT_SIZE +#define VERT_EYE VERT_BIT_EYE +#define VERT_CLIP VERT_BIT_CLIP + /* Flags for IM->TexCoordSize. Enough flags for 16 units. */ @@ -150,7 +183,6 @@ */ struct immediate { - struct __GLcontextRec *backref; GLuint id, ref_count; /* This must be saved when immediates are shared in display lists. diff --git a/src/mesa/tnl/t_eval_api.c b/src/mesa/tnl/t_eval_api.c index fc6e671bfe2..aa068032e16 100644 --- a/src/mesa/tnl/t_eval_api.c +++ b/src/mesa/tnl/t_eval_api.c @@ -1,4 +1,4 @@ -/* $Id: t_eval_api.c,v 1.9 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_eval_api.c,v 1.10 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -129,7 +129,7 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) if (compiling) { TNL_CURRENT_IM(ctx)->ref_count--; ASSERT( TNL_CURRENT_IM(ctx)->ref_count == 0 ); - _tnl_free_immediate( TNL_CURRENT_IM(ctx) ); + _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) ); SET_IMMEDIATE( ctx, im ); ctx->CompileFlag = GL_TRUE; } @@ -228,7 +228,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) if (compiling) { TNL_CURRENT_IM(ctx)->ref_count--; - _tnl_free_immediate( TNL_CURRENT_IM( ctx ) ); + _tnl_free_immediate( ctx, TNL_CURRENT_IM( ctx ) ); SET_IMMEDIATE( ctx, im ); ctx->CompileFlag = GL_TRUE; } diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c index 1518331c4a1..76bfd165128 100644 --- a/src/mesa/tnl/t_imm_alloc.c +++ b/src/mesa/tnl/t_imm_alloc.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_alloc.c,v 1.14 2002/01/10 15:50:12 brianp Exp $ */ +/* $Id: t_imm_alloc.c,v 1.15 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -47,7 +47,6 @@ static struct immediate *real_alloc_immediate( GLcontext *ctx ) IM->id = id++; IM->ref_count = 0; - IM->backref = ctx; IM->FlushElt = 0; IM->LastPrimitive = IMM_MAX_COPIED_VERTS; IM->Count = IMM_MAX_COPIED_VERTS; @@ -102,9 +101,9 @@ struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) /* May be called after tnl is destroyed. */ -void _tnl_free_immediate( struct immediate *IM ) +void _tnl_free_immediate( GLcontext *ctx, struct immediate *IM ) { - TNLcontext *tnl = TNL_CONTEXT(IM->backref); + TNLcontext *tnl = TNL_CONTEXT(ctx); ASSERT(IM->ref_count == 0); diff --git a/src/mesa/tnl/t_imm_alloc.h b/src/mesa/tnl/t_imm_alloc.h index 37512cc2191..862daf224db 100644 --- a/src/mesa/tnl/t_imm_alloc.h +++ b/src/mesa/tnl/t_imm_alloc.h @@ -1,4 +1,4 @@ -/* $Id: t_imm_alloc.h,v 1.2 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_imm_alloc.h,v 1.3 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -34,7 +34,7 @@ extern struct immediate *_tnl_alloc_immediate( GLcontext *ctx ); -extern void _tnl_free_immediate( struct immediate *im ); +extern void _tnl_free_immediate( GLcontext *ctx, struct immediate *im ); #endif diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index a67851df139..f477a351b22 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 ); } } diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index c2b31ee8691..24802060954 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_exec.c,v 1.38 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.39 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,7 +25,7 @@ */ /** - * \file vpexec.c + * \file tnl/t_imm_exec.c * \brief Setup to execute immediate-mode vertex data. * \author Keith Whitwell */ @@ -592,7 +592,7 @@ void _tnl_imm_destroy( GLcontext *ctx ) if (TNL_CURRENT_IM(ctx)) { TNL_CURRENT_IM(ctx)->ref_count--; if (TNL_CURRENT_IM(ctx)->ref_count == 0) - _tnl_free_immediate( TNL_CURRENT_IM(ctx) ); + _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) ); /* * Don't use SET_IMMEDIATE here, or else we'll whack the * _tnl_CurrentInput pointer - not good when another diff --git a/src/mesa/tnl/t_imm_exec.h b/src/mesa/tnl/t_imm_exec.h index 5e586449e8a..99b816d82ec 100644 --- a/src/mesa/tnl/t_imm_exec.h +++ b/src/mesa/tnl/t_imm_exec.h @@ -1,4 +1,4 @@ -/* $Id: t_imm_exec.h,v 1.7 2001/08/02 22:39:51 keithw Exp $ */ +/* $Id: t_imm_exec.h,v 1.8 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -38,7 +38,7 @@ extern void _tnl_flush_vertices( GLcontext *ctx, GLuint flush_flags ); /* Called from imm_api.c and _tnl_flush_vertices: */ -extern void _tnl_flush_immediate( struct immediate *IM ); +extern void _tnl_flush_immediate( GLcontext *ctx, struct immediate *IM ); /* Called from imm_dlist.c and _tnl_flush_immediate: */ diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index c589980588f..d46f0a5baf7 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.c,v 1.35 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_imm_fixup.c,v 1.36 2002/04/19 12:32:14 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -560,7 +560,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) } if (--tnl->ExecCopySource->ref_count == 0) - _tnl_free_immediate( tnl->ExecCopySource ); + _tnl_free_immediate( ctx, tnl->ExecCopySource ); tnl->ExecCopySource = next; next->ref_count++; } @@ -773,7 +773,7 @@ _tnl_get_exec_copy_verts( GLcontext *ctx, struct immediate *IM ) if (tnl->ExecCopySource) if (--tnl->ExecCopySource->ref_count == 0) - _tnl_free_immediate( tnl->ExecCopySource ); + _tnl_free_immediate( ctx, tnl->ExecCopySource ); if (prim == GL_POLYGON+1) { tnl->ExecCopySource = 0; |