From 306d3fcdbad523428501833405e47e9897896def Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Apr 2002 16:56:50 +0000 Subject: [PATCH] bring in changes from dri tcl branch --- src/mesa/main/api_arrayelt.c | 6 +- src/mesa/main/api_noop.c | 52 +++++++++--- src/mesa/main/api_noop.h | 30 ++++--- src/mesa/main/context.c | 62 +++++++++++---- src/mesa/main/dlist.c | 15 ++-- src/mesa/main/mtypes.h | 35 +++++--- src/mesa/main/state.c | 4 +- src/mesa/main/vtxfmt.c | 11 +-- src/mesa/tnl/t_array_api.c | 55 ++++++------- src/mesa/tnl/t_context.c | 24 +++--- src/mesa/tnl/t_context.h | 13 ++- src/mesa/tnl/t_eval_api.c | 24 ++++-- src/mesa/tnl/t_imm_api.c | 149 +++++++++++++++++++++-------------- src/mesa/tnl/t_imm_api.h | 3 +- src/mesa/tnl/t_imm_dlist.c | 5 +- src/mesa/tnl/t_imm_eval.c | 14 +--- src/mesa/tnl/t_imm_exec.c | 11 ++- src/mesa/tnl/t_imm_fixup.c | 4 +- src/mesa/tnl/t_vb_render.c | 9 ++- src/mesa/tnl/t_vb_vertex.c | 9 ++- 20 files changed, 336 insertions(+), 199 deletions(-) diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index 98be1699eaf..a0b7f155996 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -1,4 +1,4 @@ -/* $Id: api_arrayelt.c,v 1.6 2002/01/14 16:06:35 brianp Exp $ */ +/* $Id: api_arrayelt.c,v 1.7 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -63,7 +63,7 @@ typedef struct { static void (*colorfuncs[2][8])( const void * ) = { { (array_func)glColor3bv, - (array_func)glColor3ub, + (array_func)glColor3ubv, (array_func)glColor3sv, (array_func)glColor3usv, (array_func)glColor3iv, @@ -72,7 +72,7 @@ static void (*colorfuncs[2][8])( const void * ) = { (array_func)glColor3dv }, { (array_func)glColor4bv, - (array_func)glColor4ub, + (array_func)glColor4ubv, (array_func)glColor4sv, (array_func)glColor4usv, (array_func)glColor4iv, diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index b603b74f5e2..a44322749e2 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -1,4 +1,4 @@ -/* $Id: api_noop.c,v 1.9 2001/12/14 02:50:01 brianp Exp $ */ +/* $Id: api_noop.c,v 1.10 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -249,7 +249,7 @@ void _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a ) } } -void _mesa_noop_MultiTexCoord1fvARB( GLenum target, GLfloat *v ) +void _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLuint unit = target - GL_TEXTURE0_ARB; @@ -283,7 +283,7 @@ void _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b ) } } -void _mesa_noop_MultiTexCoord2fvARB( GLenum target, GLfloat *v ) +void _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLuint unit = target - GL_TEXTURE0_ARB; @@ -317,7 +317,7 @@ void _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat } } -void _mesa_noop_MultiTexCoord3fvARB( GLenum target, GLfloat *v ) +void _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLuint unit = target - GL_TEXTURE0_ARB; @@ -352,7 +352,7 @@ void _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b, } } -void _mesa_noop_MultiTexCoord4fvARB( GLenum target, GLfloat *v ) +void _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLuint unit = target - GL_TEXTURE0_ARB; @@ -419,7 +419,7 @@ void _mesa_noop_TexCoord1f( GLfloat a ) dest[3] = 1; } -void _mesa_noop_TexCoord1fv( GLfloat *v ) +void _mesa_noop_TexCoord1fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; @@ -439,7 +439,7 @@ void _mesa_noop_TexCoord2f( GLfloat a, GLfloat b ) dest[3] = 1; } -void _mesa_noop_TexCoord2fv( GLfloat *v ) +void _mesa_noop_TexCoord2fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; @@ -459,7 +459,7 @@ void _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c ) dest[3] = 1; } -void _mesa_noop_TexCoord3fv( GLfloat *v ) +void _mesa_noop_TexCoord3fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; @@ -479,7 +479,7 @@ void _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) COPY_FLOAT(dest[3], d); } -void _mesa_noop_TexCoord4fv( GLfloat *v ) +void _mesa_noop_TexCoord4fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; @@ -489,6 +489,40 @@ void _mesa_noop_TexCoord4fv( GLfloat *v ) COPY_FLOAT(dest[3], v[3]); } +/* Useful outside begin/end? + */ +void _mesa_noop_Vertex2fv( const GLfloat *v ) +{ + (void) v; +} + +void _mesa_noop_Vertex3fv( const GLfloat *v ) +{ + (void) v; +} + +void _mesa_noop_Vertex4fv( const GLfloat *v ) +{ + (void) v; +} + +void _mesa_noop_Vertex2f( GLfloat a, GLfloat b ) +{ + (void) a; (void) b; +} + +void _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c ) +{ + (void) a; (void) b; (void) c; +} + +void _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) +{ + (void) a; (void) b; (void) c; (void) d; +} + + + void _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { diff --git a/src/mesa/main/api_noop.h b/src/mesa/main/api_noop.h index 14fb9fcc2b7..de099bbe0aa 100644 --- a/src/mesa/main/api_noop.h +++ b/src/mesa/main/api_noop.h @@ -1,4 +1,4 @@ -/* $Id: api_noop.h,v 1.4 2001/12/14 02:50:01 brianp Exp $ */ +/* $Id: api_noop.h,v 1.5 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -75,22 +75,22 @@ extern void _mesa_noop_Color3fv( const GLfloat *v ); extern void _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a ); -extern void _mesa_noop_MultiTexCoord1fvARB( GLenum target, GLfloat *v ); +extern void _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ); extern void _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b ); -extern void _mesa_noop_MultiTexCoord2fvARB( GLenum target, GLfloat *v ); +extern void _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ); extern void _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c); -extern void _mesa_noop_MultiTexCoord3fvARB( GLenum target, GLfloat *v ); +extern void _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v ); extern void _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c, GLfloat d ); -extern void _mesa_noop_MultiTexCoord4fvARB( GLenum target, GLfloat *v ); +extern void _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v ); extern void _mesa_noop_SecondaryColor3ubEXT( GLubyte a, GLubyte b, GLubyte c ); @@ -102,19 +102,31 @@ extern void _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v ); extern void _mesa_noop_TexCoord1f( GLfloat a ); -extern void _mesa_noop_TexCoord1fv( GLfloat *v ); +extern void _mesa_noop_TexCoord1fv( const GLfloat *v ); extern void _mesa_noop_TexCoord2f( GLfloat a, GLfloat b ); -extern void _mesa_noop_TexCoord2fv( GLfloat *v ); +extern void _mesa_noop_TexCoord2fv( const GLfloat *v ); extern void _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c ); -extern void _mesa_noop_TexCoord3fv( GLfloat *v ); +extern void _mesa_noop_TexCoord3fv( const GLfloat *v ); extern void _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ); -extern void _mesa_noop_TexCoord4fv( GLfloat *v ); +extern void _mesa_noop_TexCoord4fv( const GLfloat *v ); + +extern void _mesa_noop_Vertex2fv( const GLfloat *v ); + +extern void _mesa_noop_Vertex3fv( const GLfloat *v ); + +extern void _mesa_noop_Vertex4fv( const GLfloat *v ); + +extern void _mesa_noop_Vertex2f( GLfloat a, GLfloat b ); + +extern void _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c ); + +extern void _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ); extern void _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 969b320a440..154164d1651 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.159 2002/04/09 14:58:03 keithw Exp $ */ +/* $Id: context.c,v 1.160 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -70,22 +70,11 @@ #endif #ifndef MESA_VERBOSE -int MESA_VERBOSE = 0 -/* | VERBOSE_PIPELINE */ -/* | VERBOSE_IMMEDIATE */ -/* | VERBOSE_VARRAY */ -/* | VERBOSE_TEXTURE */ -/* | VERBOSE_API */ -/* | VERBOSE_DRIVER */ -/* | VERBOSE_STATE */ -/* | VERBOSE_DISPLAY_LIST */ -; +int MESA_VERBOSE = 0; #endif #ifndef MESA_DEBUG_FLAGS -int MESA_DEBUG_FLAGS = 0 -/* | DEBUG_ALWAYS_FLUSH */ -; +int MESA_DEBUG_FLAGS = 0; #endif @@ -1434,6 +1423,44 @@ alloc_proxy_textures( GLcontext *ctx ) } +static void add_debug_flags( const char *debug ) +{ +#ifdef MESA_DEBUG + if (strstr(debug, "varray")) + MESA_VERBOSE |= VERBOSE_VARRAY; + + if (strstr(debug, "tex")) + MESA_VERBOSE |= VERBOSE_TEXTURE; + + if (strstr(debug, "imm")) + MESA_VERBOSE |= VERBOSE_IMMEDIATE; + + if (strstr(debug, "pipe")) + MESA_VERBOSE |= VERBOSE_PIPELINE; + + if (strstr(debug, "driver")) + MESA_VERBOSE |= VERBOSE_DRIVER; + + if (strstr(debug, "state")) + MESA_VERBOSE |= VERBOSE_STATE; + + if (strstr(debug, "api")) + MESA_VERBOSE |= VERBOSE_API; + + if (strstr(debug, "list")) + MESA_VERBOSE |= VERBOSE_DISPLAY_LIST; + + if (strstr(debug, "lighting")) + MESA_VERBOSE |= VERBOSE_LIGHTING; + + /* Debug flag: + */ + if (strstr(debug, "flush")) + MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH; +#endif +} + + /* * Initialize a GLcontext struct. This includes allocating all the * other structs and arrays which hang off of the context by pointers. @@ -1597,6 +1624,13 @@ _mesa_initialize_context( GLcontext *ctx, trInitDispatch(ctx->TraceDispatch); #endif + + if (getenv("MESA_DEBUG")) + add_debug_flags(getenv("MESA_DEBUG")); + + if (getenv("MESA_VERBOSE")) + add_debug_flags(getenv("MESA_VERBOSE")); + return GL_TRUE; } diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index e2224a1046b..99d477e7a4c 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,4 +1,4 @@ -/* $Id: dlist.c,v 1.85 2002/04/02 16:15:17 brianp Exp $ */ +/* $Id: dlist.c,v 1.86 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -5065,12 +5065,11 @@ _mesa_EndList( void ) { GET_CURRENT_CONTEXT(ctx); FLUSH_CURRENT(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + if (MESA_VERBOSE&VERBOSE_API) fprintf(stderr, "glEndList\n"); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); /* ??? */ - /* Check that a list is under construction */ if (!ctx->CurrentListPtr) { _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" ); @@ -5097,7 +5096,6 @@ _mesa_EndList( void ) ctx->CurrentDispatch = ctx->Exec; _glapi_set_dispatch( ctx->CurrentDispatch ); - } @@ -5111,6 +5109,10 @@ _mesa_CallList( GLuint list ) /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ /* execute the display list, and restore the CompileFlag. */ + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_mesa_CallList %d\n", list); + /* mesa_print_display_list( list ); */ save_compile_flag = ctx->CompileFlag; @@ -5141,6 +5143,9 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) GLint i; GLboolean save_compile_flag; + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_mesa_CallLists %d\n", n); + /* Save the CompileFlag status, turn it off, execute display list, * and restore the CompileFlag. */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a8154738309..4eec17874e2 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.69 2002/03/29 17:27:59 brianp Exp $ */ +/* $Id: mtypes.h,v 1.70 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -1810,6 +1810,9 @@ struct __GLcontextRec { /* The string names for GL_POINT, GL_LINE_LOOP, etc */ extern const char *_mesa_prim_name[GL_POLYGON+4]; +#ifndef MESA_DEBUG +#define MESA_DEBUG +#endif #ifdef MESA_DEBUG extern int MESA_VERBOSE; @@ -1831,8 +1834,10 @@ enum _verbose { VERBOSE_DRIVER = 0x0010, VERBOSE_STATE = 0x0020, VERBOSE_API = 0x0040, - VERBOSE_DISPLAY_LIST = 0x0200, - VERBOSE_LIGHTING = 0x0400 + VERBOSE_DISPLAY_LIST = 0x0100, + VERBOSE_LIGHTING = 0x0200, + VERBOSE_PRIMS = 0x0400, + VERBOSE_VERTS = 0x0800 }; @@ -1848,18 +1853,22 @@ enum _debug { /* Eventually let the driver specify what statechanges require a flush: */ -#define FLUSH_VERTICES(ctx, newstate) \ -do { \ - if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ - ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ - ctx->NewState |= newstate; \ +#define FLUSH_VERTICES(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + fprintf(stderr, "FLUSH_VERTICES in %s\n", __FUNCTION__); \ + if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ + ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ + ctx->NewState |= newstate; \ } while (0) -#define FLUSH_CURRENT(ctx, newstate) \ -do { \ - if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ - ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ - ctx->NewState |= newstate; \ +#define FLUSH_CURRENT(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + fprintf(stderr, "FLUSH_CURRENT in %s\n", __FUNCTION__); \ + if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ + ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ + ctx->NewState |= newstate; \ } while (0) #define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index e705f14d4d1..c1657125f8a 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $Id: state.c,v 1.80 2002/04/02 16:15:17 brianp Exp $ */ +/* $Id: state.c,v 1.81 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -910,7 +910,7 @@ void _mesa_update_state( GLcontext *ctx ) const GLuint oldneedeyecoords = ctx->_NeedEyeCoords; if (MESA_VERBOSE & VERBOSE_STATE) - _mesa_print_state("", new_state); + _mesa_print_state("_mesa_update_state", new_state); if (new_state & _NEW_MODELVIEW) _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index 599dce1bf2a..14b8e8381aa 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -1,4 +1,4 @@ -/* $Id: vtxfmt.c,v 1.10 2001/12/15 02:14:43 brianp Exp $ */ +/* $Id: vtxfmt.c,v 1.11 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -50,14 +50,6 @@ { \ GET_CURRENT_CONTEXT(ctx); \ struct gl_tnl_module *tnl = &(ctx->TnlModule); \ - const GLuint new_state = ctx->NewState; \ - \ - if ( new_state ) \ - _mesa_update_state( ctx ); \ - \ - /* Validate the current tnl module. */ \ - if ( new_state & ctx->Driver.NeedValidate ) \ - ctx->Driver.ValidateTnlModule( ctx, new_state ); \ \ ASSERT( tnl->Current ); \ ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \ @@ -149,6 +141,7 @@ static void install_vtxfmt( struct _glapi_table *tab, GLvertexformat *vfmt ) void _mesa_init_exec_vtxfmt( GLcontext *ctx ) { install_vtxfmt( ctx->Exec, &neutral_vtxfmt ); + ctx->TnlModule.SwapCount = 0; } diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 1187538c736..0ad9ca419b3 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.24 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_array_api.c,v 1.25 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -53,10 +53,9 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, { if (_tnl_hard_begin( ctx, mode )) { GLint i; - for (i = start; i < count; i++) { - _tnl_array_element( ctx, i ); - } - _tnl_end( ctx ); + for (i = start; i < count; i++) + glArrayElement( i ); + glEnd(); } } @@ -64,13 +63,11 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count, const GLuint *indices) { - /* Simple version of the above code. - */ if (_tnl_hard_begin(ctx, mode)) { GLint i; for (i = 0 ; i < count ; i++) - _tnl_array_element( ctx, indices[i] ); - _tnl_end( ctx ); + glArrayElement( indices[i] ); + glEnd(); } } @@ -82,6 +79,10 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, { TNLcontext *tnl = TNL_CONTEXT(ctx); FLUSH_CURRENT( ctx, 0 ); + + /* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (tnl->pipeline.build_state_changes) + _tnl_validate_pipeline( ctx ); _tnl_vb_bind_arrays( ctx, start, end ); @@ -112,8 +113,10 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) GET_CURRENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - -/* fprintf(stderr, "%s %d %d\n", __FUNCTION__, start, count); */ + GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10; + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_DrawArrays %d %d\n", start, count); /* Check arguments, etc. */ @@ -126,10 +129,16 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) if (ctx->CompileFlag) { fallback_drawarrays( ctx, mode, start, start + count ); } + else if (!ctx->Array.LockCount && count < thresh) { + /* Small primitives: attempt to share a vb (at the expense of + * using the immediate interface). + */ + fallback_drawarrays( ctx, mode, start, start + count ); + } else if (ctx->Array.LockCount && count < (GLint) ctx->Const.MaxArrayLockSize) { - /* Small primitives which can fit in a single vertex buffer: + /* Locked primitives which can fit in a single vertex buffer: */ FLUSH_CURRENT( ctx, 0 ); @@ -210,10 +219,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) FLUSH_CURRENT( ctx, 0 ); -/* fprintf(stderr, "start %d count %d min %d modulo %d skip %d\n", */ -/* start, count, minimum, modulo, skip); */ - - bufsz -= bufsz % modulo; bufsz -= minimum; count += start; @@ -222,8 +227,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) nr = MIN2( bufsz, count - j ); -/* fprintf(stderr, "%d..%d\n", j - minimum, j+nr); */ - _tnl_vb_bind_arrays( ctx, j - minimum, j + nr ); VB->FirstPrimitive = 0; @@ -246,10 +249,10 @@ _tnl_DrawRangeElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { GET_CURRENT_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint *ui_indices; - -/* fprintf(stderr, "%s\n", __FUNCTION__); */ + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_DrawRangeElements %d %d %d\n", start, end, count); /* Check arguments, etc. */ @@ -257,9 +260,6 @@ _tnl_DrawRangeElements(GLenum mode, type, indices )) return; - if (tnl->pipeline.build_state_changes) - _tnl_validate_pipeline( ctx ); - ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); @@ -316,19 +316,16 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { GET_CURRENT_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint *ui_indices; -/* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_DrawElements %d\n", count); /* Check arguments, etc. */ if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) return; - if (tnl->pipeline.build_state_changes) - _tnl_validate_pipeline( ctx ); - ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 2cea4b1dcdf..7be74c61c6c 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.24 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_context.c,v 1.25 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -110,12 +110,15 @@ _tnl_CreateContext( GLcontext *ctx ) /* Hook our functions into exec and compile dispatch tables. */ _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); - _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt ); - ctx->Save->CallList = _mesa_save_CallList; - ctx->Save->CallLists = _mesa_save_CallLists; - ctx->Save->EvalMesh1 = _mesa_save_EvalMesh1; - ctx->Save->EvalMesh2 = _mesa_save_EvalMesh2; - ctx->Save->Begin = _tnl_save_Begin; + + tnl->save_vtxfmt = tnl->vtxfmt; + tnl->save_vtxfmt.CallList = _mesa_save_CallList; + tnl->save_vtxfmt.EvalMesh1 = _mesa_save_EvalMesh1; + tnl->save_vtxfmt.EvalMesh2 = _mesa_save_EvalMesh2; + tnl->save_vtxfmt.Begin = _tnl_save_Begin; + + _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); + /* Set a few default values in the driver struct. */ @@ -200,12 +203,7 @@ _tnl_wakeup_save_exec( GLcontext *ctx ) TNLcontext *tnl = TNL_CONTEXT(ctx); _tnl_wakeup_exec( ctx ); - _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt ); - ctx->Save->CallList = _mesa_save_CallList; /* fixme */ - ctx->Save->CallLists = _mesa_save_CallLists; - ctx->Save->EvalMesh1 = _mesa_save_EvalMesh1; /* fixme */ - ctx->Save->EvalMesh2 = _mesa_save_EvalMesh2; - ctx->Save->Begin = _tnl_save_Begin; + _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 92483e69994..31d917f3d58 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.39 2002/04/04 18:25:40 kschultz Exp $ */ +/* $Id: t_context.h,v 1.40 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -387,9 +387,13 @@ struct tnl_device_driver { */ void (*NotifyMaterialChange)(GLcontext *ctx); - /* Alert tnl-aware drivers of changes to material, especially in - * exec_empty_cassette, which doesn't otherwise reach the driver. - * --> Need to be able to disable exec_empty_cassette??? + /* Alert tnl-aware drivers of changes to material. + */ + + GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p); + /* Allow drivers to hook in optimized begin/end engines. + * Return value: GL_TRUE - driver handled the begin + * GL_FALSE - driver didn't handle the begin */ /*** @@ -539,6 +543,7 @@ typedef struct { /* Functions to be plugged into dispatch when tnl is active. */ GLvertexformat vtxfmt; + GLvertexformat save_vtxfmt; } TNLcontext; diff --git a/src/mesa/tnl/t_eval_api.c b/src/mesa/tnl/t_eval_api.c index 37d8f69118b..fc6e671bfe2 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.8 2001/12/03 17:39:12 keithw Exp $ */ +/* $Id: t_eval_api.c,v 1.9 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -100,7 +100,12 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) */ { GLboolean compiling = ctx->CompileFlag; + TNLcontext *tnl = TNL_CONTEXT(ctx); struct immediate *im = TNL_CURRENT_IM(ctx); + GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p); + + NotifyBegin = tnl->Driver.NotifyBegin; + tnl->Driver.NotifyBegin = 0; if (compiling) { struct immediate *tmp = _tnl_alloc_immediate( ctx ); @@ -110,7 +115,7 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) ctx->CompileFlag = GL_FALSE; } - _tnl_hard_begin( ctx, prim ); + _tnl_Begin( prim ); for (i=i1;i<=i2;i++,u+=du) { _tnl_eval_coord1f( ctx, u ); } @@ -119,6 +124,7 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) /* Need this for replay *and* compile: */ FLUSH_VERTICES( ctx, 0 ); + tnl->Driver.NotifyBegin = NotifyBegin; if (compiling) { TNL_CURRENT_IM(ctx)->ref_count--; @@ -160,6 +166,11 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) { GLboolean compiling = ctx->CompileFlag; struct immediate *im = TNL_CURRENT_IM(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); + GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p); + + NotifyBegin = tnl->Driver.NotifyBegin; + tnl->Driver.NotifyBegin = 0; if (compiling) { struct immediate *tmp = _tnl_alloc_immediate( ctx ); @@ -171,7 +182,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) switch (mode) { case GL_POINT: - _tnl_hard_begin( ctx, GL_POINTS ); + _tnl_Begin( GL_POINTS ); for (v=v1,j=j1;j<=j2;j++,v+=dv) { for (u=u1,i=i1;i<=i2;i++,u+=du) { _tnl_eval_coord2f( ctx, u, v ); @@ -181,14 +192,14 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) break; case GL_LINE: for (v=v1,j=j1;j<=j2;j++,v+=dv) { - _tnl_hard_begin( ctx, GL_LINE_STRIP ); + _tnl_Begin( GL_LINE_STRIP ); for (u=u1,i=i1;i<=i2;i++,u+=du) { _tnl_eval_coord2f( ctx, u, v ); } _tnl_end(ctx); } for (u=u1,i=i1;i<=i2;i++,u+=du) { - _tnl_hard_begin( ctx, GL_LINE_STRIP ); + _tnl_Begin( GL_LINE_STRIP ); for (v=v1,j=j1;j<=j2;j++,v+=dv) { _tnl_eval_coord2f( ctx, u, v ); } @@ -197,7 +208,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) break; case GL_FILL: for (v=v1,j=j1;jDriver.NotifyBegin = NotifyBegin; if (compiling) { TNL_CURRENT_IM(ctx)->ref_count--; diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index d19f6a6e007..a67851df139 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.25 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_imm_api.c,v 1.26 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -53,6 +53,10 @@ void _tnl_flush_immediate( struct immediate *IM ) { GLcontext *ctx = IM->backref; + if (MESA_VERBOSE & VERBOSE_IMMEDIATE) + fprintf(stderr, "_tnl_flush_immediate IM: %d compiling: %d\n", + IM->id, ctx->CompileFlag); + if (IM->FlushElt == FLUSH_ELT_EAGER) { _tnl_translate_array_elts( ctx, IM, IM->LastPrimitive, IM->Count ); } @@ -69,10 +73,18 @@ void _tnl_flush_immediate( struct immediate *IM ) } +/* Hook for ctx->Driver.FlushVertices: + */ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) { struct immediate *IM = TNL_CURRENT_IM(ctx); + if (MESA_VERBOSE & VERBOSE_IMMEDIATE) + fprintf( stderr, + "_tnl_flush_vertices flags %x IM(%d) %d..%d Flag[%d]: %x\n", + flags, IM->id, IM->Start, IM->Count, IM->Start, + IM->Flag[IM->Start]); + if (IM->Flag[IM->Start]) if ((flags & FLUSH_UPDATE_CURRENT) || IM->Count > IM->Start) _tnl_flush_immediate( IM ); @@ -81,29 +93,23 @@ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) -/* Note the ctx argument. This function called only by _tnl_Begin, - * _tnl_save_Begin and _tnl_hard_begin() in this file. - */ -static void -_tnl_begin( GLcontext *ctx, GLenum p ) +void +_tnl_save_Begin( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); struct immediate *IM = TNL_CURRENT_IM(ctx); GLuint inflags, state; - if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glBegin(IM %d) %s\n", IM->id, - _mesa_lookup_enum_by_nr(p)); +/* fprintf(stderr, "%s: before: %x\n", __FUNCTION__, IM->BeginState); */ + + if (mode > GL_POLYGON) { + _mesa_compile_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" ); + return; + } 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( IM ); - IM = TNL_CURRENT_IM(ctx); - } - /* Check for and flush buffered vertices from internal operations. */ if (IM->SavedBeginState) { @@ -124,7 +130,7 @@ _tnl_begin( GLcontext *ctx, GLenum p ) state |= (VERT_BEGIN_0|VERT_BEGIN_1); IM->Flag[count] |= VERT_BIT_BEGIN; - IM->Primitive[count] = p | PRIM_BEGIN; + IM->Primitive[count] = mode | PRIM_BEGIN; IM->PrimitiveLength[IM->LastPrimitive] = count - IM->LastPrimitive; IM->LastPrimitive = count; @@ -139,20 +145,15 @@ _tnl_begin( GLcontext *ctx, GLenum p ) ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; IM->BeginState = state; -} - -void -_tnl_save_Begin( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (mode > GL_POLYGON) { - _mesa_compile_error( ctx, GL_INVALID_ENUM, "glBegin" ); - return; + if (ctx->ExecuteFlag) { + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" ); + } + else + ctx->Driver.CurrentExecPrimitive = mode; } - _tnl_begin( ctx, mode ); /* Update save_primitive now. */ @@ -167,18 +168,52 @@ void _tnl_Begin( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); + ASSERT (!ctx->CompileFlag); if (mode > GL_POLYGON) { - _mesa_compile_error( ctx, GL_INVALID_ENUM, "glBegin" ); + _mesa_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" ); return; } - _tnl_begin(ctx, mode); + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" ); + return; + } - /* Update exec_primitive now. - */ - ASSERT (!ctx->CompileFlag); - if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) { + if (ctx->NewState) + _mesa_update_state(ctx); + + { + struct immediate *IM = TNL_CURRENT_IM(ctx); + GLuint count = IM->Count; + GLuint last = IM->LastPrimitive; + + if (IM->Start == IM->Count && + tnl->Driver.NotifyBegin && + tnl->Driver.NotifyBegin( ctx, mode )) + return; + + assert( IM->SavedBeginState == 0 ); + assert( IM->BeginState == 0 ); + + /* Not quite right. Need to use the fallback '_aa_ArrayElement' + * when not known to be inside begin/end and arrays are + * unlocked. + */ + if (IM->FlushElt == FLUSH_ELT_EAGER) { + _tnl_translate_array_elts( ctx, IM, last, count ); + } + + IM->Flag[count] |= VERT_BIT_BEGIN; + IM->Primitive[count] = mode | PRIM_BEGIN; + IM->PrimitiveLength[last] = count - last; + IM->LastPrimitive = count; + IM->BeginState = (VERT_BEGIN_0|VERT_BEGIN_1); + +/* fprintf(stderr, "%s: %x\n", __FUNCTION__, IM->BeginState); */ + + ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; ctx->Driver.CurrentExecPrimitive = mode; } } @@ -191,12 +226,13 @@ _tnl_Begin( GLenum mode ) GLboolean _tnl_hard_begin( GLcontext *ctx, GLenum p ) { +/* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (!ctx->CompileFlag) { /* If not compiling, treat as a normal begin(). */ - _tnl_begin( ctx, p ); - ASSERT(ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END); - ctx->Driver.CurrentExecPrimitive = p; +/* fprintf(stderr, "%s: treating as glBegin\n", __FUNCTION__); */ + glBegin( p ); return GL_TRUE; } else { @@ -262,7 +298,7 @@ _tnl_hard_begin( GLcontext *ctx, GLenum p ) return GL_TRUE; default: - ASSERT (0); + assert (0); return GL_TRUE; } } @@ -285,6 +321,8 @@ _tnl_end( GLcontext *ctx ) GLuint state = IM->BeginState; GLuint inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1); + assert( ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES ); + state |= inflags << 2; /* errors */ if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1)) @@ -308,8 +346,11 @@ _tnl_end( GLcontext *ctx ) IM->BeginState = state; - if (!ctx->CompileFlag) { - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; + if (ctx->ExecuteFlag) { + if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) + _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_End" ); + else + ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; } /* You can set this flag to get the old 'flush_vb on glEnd()' @@ -1076,19 +1117,6 @@ _tnl_eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v ) EVALCOORD2( i, u, v ); } -void -_tnl_array_element( GLcontext *CC, GLint i ) -{ - struct immediate *im = TNL_CURRENT_IM(CC); - ARRAY_ELT( im, i ); -} - -void -_tnl_vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) -{ - struct immediate *im = TNL_CURRENT_IM(ctx); - VERTEX2( im, x, y ); -} @@ -1141,14 +1169,12 @@ _tnl_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) { GET_CURRENT_CONTEXT(ctx); -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - if (_tnl_hard_begin( ctx, GL_QUADS )) { - _tnl_vertex2f( ctx, x1, y1 ); - _tnl_vertex2f( ctx, x2, y1 ); - _tnl_vertex2f( ctx, x2, y2 ); - _tnl_vertex2f( ctx, x1, y2 ); - _tnl_end( ctx ); + glVertex2f( x1, y1 ); + glVertex2f( x2, y1 ); + glVertex2f( x2, y2 ); + glVertex2f( x1, y2 ); + glEnd(); } } @@ -1164,6 +1190,9 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (bitmask == 0) return; + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_Materialfv\n"); if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ diff --git a/src/mesa/tnl/t_imm_api.h b/src/mesa/tnl/t_imm_api.h index c13dde77aa1..6615a9ce93a 100644 --- a/src/mesa/tnl/t_imm_api.h +++ b/src/mesa/tnl/t_imm_api.h @@ -1,4 +1,4 @@ -/* $Id: t_imm_api.h,v 1.4 2001/12/14 02:51:44 brianp Exp $ */ +/* $Id: t_imm_api.h,v 1.5 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -33,6 +33,7 @@ extern void _tnl_save_Begin( GLenum mode ); +extern void _tnl_Begin( GLenum mode ); extern void _tnl_Begin( GLenum mode ); diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index dfc4e7795d1..8805c23b12f 100644 --- a/src/mesa/tnl/t_imm_dlist.c +++ b/src/mesa/tnl/t_imm_dlist.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_dlist.c,v 1.38 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_imm_dlist.c,v 1.39 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -128,6 +128,9 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) TNLvertexcassette *node; GLuint new_beginstate; + if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) + fprintf(stderr, "_tnl_compiled_cassette IM: %d\n", IM->id); + if (IM->FlushElt) { ASSERT (IM->FlushElt == FLUSH_ELT_LAZY); _tnl_translate_array_elts( ctx, IM, IM->Start, IM->Count ); diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index 01c886bec04..1b95f15f10d 100644 --- a/src/mesa/tnl/t_imm_eval.c +++ b/src/mesa/tnl/t_imm_eval.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_eval.c,v 1.21 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_imm_eval.c,v 1.22 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -242,7 +242,6 @@ static void eval2_4f( GLvector4f *dest, if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) { GLfloat u = (coord[i][0] - u1) * du; GLfloat v = (coord[i][1] - v1) * dv; -/* fprintf(stderr, "coord %d: %f %f\n", i, coord[i][0], coord[i][1]); */ _math_horner_bezier_surf(map->Points, to[i], u, v, dimension, map->Uorder, map->Vorder); @@ -344,8 +343,6 @@ static void copy_4f_stride( GLfloat to[][4], GLfloat *from, MEMCPY( to, from, count * sizeof(to[0])); else { GLuint i; -/* fprintf(stderr, "%s stride %d count %d\n", __FUNCTION__, */ -/* stride, count); */ for (i = 0 ; i < count ; i++, STRIDE_F(from, stride)) COPY_4FV( to[i], from ); } @@ -354,11 +351,7 @@ static void copy_4f_stride( GLfloat to[][4], GLfloat *from, static void copy_3f( GLfloat to[][4], GLfloat from[][4], GLuint count ) { GLuint i; -/* MEMCPY( to, from, (count) * sizeof(to[0])); */ for (i = 0 ; i < count ; i++) { -/* fprintf(stderr, "copy norm %d from %p: %f %f %f\n", i, */ -/* from[i], */ -/* from[i][0], from[i][1], from[i][2]); */ COPY_3FV(to[i], from[i]); } } @@ -459,9 +452,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) else copycount = IM->Count - IM->CopyStart; /* copy all vertices */ -/* fprintf(stderr, "%s copystart %d start %d count %d copycount %d\n", */ -/* __FUNCTION__, IM->CopyStart, IM->Start, IM->Count, copycount); */ - if (!store) store = tnl->eval.im = _tnl_alloc_immediate( ctx ); @@ -711,8 +701,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) struct vertex_buffer *VB = &tnl->vb; GLuint i,j,count = VB->Count; -/* fprintf(stderr, "PURGING\n"); */ - for (i = 0, j = 0 ; i < count ; i++) { if (flags[i] & vertex) { store->Elt[j++] = i; diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 007d688e147..c2b31ee8691 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.37 2002/02/13 23:53:19 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.38 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -71,6 +71,10 @@ static void reset_input( GLcontext *ctx, if (start < IM->Count+2) MEMSET(IM->Flag + start, 0, sizeof(GLuint) * (IM->Count+2-start)); + if (MESA_VERBOSE & VERBOSE_IMMEDIATE) + fprintf(stderr, "reset_input: IM(%d) new %x\n", + IM->id, beginstate); + IM->Start = start; IM->Count = start; IM->LastMaterial = start; @@ -432,7 +436,7 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM ) TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; -/* fprintf(stderr, "%s\n", __FUNCTION__); */ +/* fprintf(stderr, "%s\n", __FUNCTION__); */ _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount ); @@ -514,6 +518,9 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES; + +/* fprintf(stderr, "%s: NeedFlush: %x\n", __FUNCTION__, */ +/* ctx->Driver.NeedFlush); */ } diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index 8e3f52e6210..c589980588f 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.34 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_imm_fixup.c,v 1.35 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -386,6 +386,7 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) vulnerable ); + ++i; } while (vulnerable); } } @@ -680,6 +681,7 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) vulnerable ); + ++i; } while (vulnerable); } } diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 1721b883235..496c22cc42d 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_render.c,v 1.28 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.29 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -42,6 +42,7 @@ #include "glheader.h" #include "context.h" +#include "enums.h" #include "macros.h" #include "mem.h" #include "mtypes.h" @@ -324,6 +325,12 @@ static GLboolean run_render( GLcontext *ctx, length= VB->PrimitiveLength[i]; ASSERT(length || (flags & PRIM_LAST)); ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1); + + if (MESA_VERBOSE & VERBOSE_PRIMS) + fprintf(stderr, "MESA prim %s %d..%d\n", + _mesa_lookup_enum_by_nr(flags & PRIM_MODE_MASK), + i, i+length); + if (length) tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags ); } diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index 4369df16f6c..e13b8bc0a1e 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_vertex.c,v 1.13 2002/03/29 17:27:59 brianp Exp $ */ +/* $Id: t_vb_vertex.c,v 1.14 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -140,7 +140,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx, if (stage->changed_inputs) { if (ctx->_NeedEyeCoords) { - /* Separate modelview and project transformations: + /* Separate modelview transformation: + * Use combined ModelProject to avoid some depth artifacts */ if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY) VB->EyePtr = VB->ObjPtr; @@ -153,8 +154,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx, VB->ClipPtr = VB->EyePtr; else VB->ClipPtr = TransformRaw( &store->clip, - ctx->ProjectionMatrixStack.Top, - VB->EyePtr ); + &ctx->_ModelProjectMatrix, + VB->ObjPtr ); } else { /* Combined modelviewproject transform: -- 2.30.2