Ensure PRIM_BEGIN marker isn't lost when incomplete primitives are wrapped.

This commit is contained in:
Keith Whitwell
2003-12-03 10:15:17 +00:00
parent 9b0dcfd408
commit 6ff60049a4
3 changed files with 27 additions and 14 deletions

View File

@@ -306,6 +306,7 @@ static void _save_wrap_buffers( GLcontext *ctx )
TNLcontext *tnl = TNL_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx);
GLint i = tnl->save.prim_count - 1; GLint i = tnl->save.prim_count - 1;
GLenum mode; GLenum mode;
GLuint count;
assert(i < (GLint) tnl->save.prim_max); assert(i < (GLint) tnl->save.prim_max);
assert(i >= 0); 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].count = ((tnl->save.initial_counter - tnl->save.counter) -
tnl->save.prim[i].start); 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. /* store the copied vertices, and allocate a new list.
*/ */
@@ -322,10 +325,19 @@ static void _save_wrap_buffers( GLcontext *ctx )
/* Restart interrupted primitive /* Restart interrupted primitive
*/ */
tnl->save.prim[0].mode = mode; if (!(mode & PRIM_END)) {
tnl->save.prim[0].start = 0;
tnl->save.prim[0].count = 0; if (count == tnl->save.copied.nr)
tnl->save.prim_count = 1; 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;
} }

View File

@@ -187,8 +187,6 @@ void _tnl_playback_vertex_list( GLcontext *ctx, void *data )
/* Degenerate case: list references current data and would /* Degenerate case: list references current data and would
* require fixup. Take the easier option & loop it back. * 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 ); _tnl_loopback_vertex_list( ctx, (struct tnl_vertex_list *) data );
return; return;
} }

View File

@@ -51,6 +51,8 @@ static void init_attrfv( TNLcontext *tnl );
static void _tnl_wrap_buffers( GLcontext *ctx ) static void _tnl_wrap_buffers( GLcontext *ctx )
{ {
TNLcontext *tnl = TNL_CONTEXT(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) { if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
GLint i = tnl->vtx.prim_count - 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].start = 0;
tnl->vtx.prim[0].count = 0; tnl->vtx.prim[0].count = 0;
tnl->vtx.prim_count++; 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; 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 0
if (tnl->vtx.counter * 2 > tnl->vtx.initial_counter) if (tnl->vtx.prim_count == TNL_MAX_PRIM)
_tnl_FlushVertices( ctx, ~0 );
#endif
if (tnl->vtx.prim_count == TNL_MAX_PRIM) {
#if 0
_tnl_FlushVertices( ctx, ~0 ); _tnl_FlushVertices( ctx, ~0 );
#else #else
if (tnl->vtx.prim_count == TNL_MAX_PRIM)
_tnl_flush_vtx( ctx ); _tnl_flush_vtx( ctx );
#endif #endif
}
} }
else else