Ensure PRIM_BEGIN marker isn't lost when incomplete primitives are wrapped.
authorKeith Whitwell <keith@tungstengraphics.com>
Wed, 3 Dec 2003 10:15:17 +0000 (10:15 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Wed, 3 Dec 2003 10:15:17 +0000 (10:15 +0000)
src/mesa/tnl/t_save_api.c
src/mesa/tnl/t_save_playback.c
src/mesa/tnl/t_vtx_api.c

index 1fe2ff6d442b1a4f139dd2816cfebdbef2fbf37f..92fd3369531e45feea494c61c3de269e41ca7c32 100644 (file)
@@ -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;
 }
 
 
index 27fe2fe1626d22cefcdc8171c528850bb2ff920a..5a444014449d7aeb142642fdf53460e0c79a7a18 100644 (file)
@@ -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;
       }
index 73849a4dc5013860d5ed951b9e93b93fc7683a17..34a77ec40a0a8590f6f859212ed64cd2bd41fd12 100644 (file)
@@ -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