From 6ff60049a4ab1abac46e5c8e317b0dd842e088c2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 3 Dec 2003 10:15:17 +0000 Subject: Ensure PRIM_BEGIN marker isn't lost when incomplete primitives are wrapped. --- src/mesa/tnl/t_save_api.c | 22 +++++++++++++++++----- src/mesa/tnl/t_save_playback.c | 2 -- src/mesa/tnl/t_vtx_api.c | 17 ++++++++++------- 3 files changed, 27 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c index 1fe2ff6d44..92fd336953 100644 --- a/src/mesa/tnl/t_save_api.c +++ b/src/mesa/tnl/t_save_api.c @@ -306,6 +306,7 @@ static void _save_wrap_buffers( GLcontext *ctx ) TNLcontext *tnl = TNL_CONTEXT(ctx); GLint i = tnl->save.prim_count - 1; GLenum mode; + GLuint count; assert(i < (GLint) tnl->save.prim_max); assert(i >= 0); @@ -314,7 +315,9 @@ static void _save_wrap_buffers( GLcontext *ctx ) */ tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) - tnl->save.prim[i].start); - mode = tnl->save.prim[i].mode & ~(PRIM_BEGIN|PRIM_END); + count = tnl->save.prim[i].count; + mode = tnl->save.prim[i].mode; + /* store the copied vertices, and allocate a new list. */ @@ -322,10 +325,19 @@ static void _save_wrap_buffers( GLcontext *ctx ) /* Restart interrupted primitive */ - tnl->save.prim[0].mode = mode; - tnl->save.prim[0].start = 0; - tnl->save.prim[0].count = 0; - tnl->save.prim_count = 1; + if (!(mode & PRIM_END)) { + + if (count == tnl->save.copied.nr) + tnl->save.prim[0].mode = mode; + else + tnl->save.prim[0].mode = mode & ~PRIM_BEGIN; + + tnl->save.prim[0].start = 0; + tnl->save.prim[0].count = 0; + tnl->save.prim_count = 1; + } + else + tnl->save.prim_count = 0; } diff --git a/src/mesa/tnl/t_save_playback.c b/src/mesa/tnl/t_save_playback.c index 27fe2fe162..5a44401444 100644 --- a/src/mesa/tnl/t_save_playback.c +++ b/src/mesa/tnl/t_save_playback.c @@ -187,8 +187,6 @@ void _tnl_playback_vertex_list( GLcontext *ctx, void *data ) /* Degenerate case: list references current data and would * require fixup. Take the easier option & loop it back. */ - _mesa_debug(ctx, - "tnl_playback_vertex_list: loopback dangling attr ref\n"); _tnl_loopback_vertex_list( ctx, (struct tnl_vertex_list *) data ); return; } diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index 73849a4dc5..34a77ec40a 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -51,6 +51,8 @@ static void init_attrfv( TNLcontext *tnl ); static void _tnl_wrap_buffers( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); + GLuint last_prim = tnl->vtx.prim[tnl->vtx.prim_count-1].mode; + GLuint last_count = tnl->vtx.prim[tnl->vtx.prim_count-1].count; if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { GLint i = tnl->vtx.prim_count - 1; @@ -72,6 +74,9 @@ static void _tnl_wrap_buffers( GLcontext *ctx ) tnl->vtx.prim[0].start = 0; tnl->vtx.prim[0].count = 0; tnl->vtx.prim_count++; + + if (tnl->vtx.copied.nr == last_count) + tnl->vtx.prim[0].mode |= last_prim & PRIM_BEGIN; } } @@ -1008,18 +1013,16 @@ static void _tnl_End( void ) ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1; + /* Two choices which effect the way vertex attributes are + * carried over (or not) between adjacent primitives. + */ #if 0 - if (tnl->vtx.counter * 2 > tnl->vtx.initial_counter) - _tnl_FlushVertices( ctx, ~0 ); -#endif - - if (tnl->vtx.prim_count == TNL_MAX_PRIM) { -#if 0 + if (tnl->vtx.prim_count == TNL_MAX_PRIM) _tnl_FlushVertices( ctx, ~0 ); #else + if (tnl->vtx.prim_count == TNL_MAX_PRIM) _tnl_flush_vtx( ctx ); #endif - } } else -- cgit v1.2.3