mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 13:48:06 +02:00
Catch and shortcircuit no-primitive and no-vertex cases in _tnl_wrap_buffers()
This commit is contained in:
parent
da2be88f18
commit
dd9e6e7e37
1 changed files with 38 additions and 21 deletions
|
|
@ -52,32 +52,47 @@ 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;
|
||||
assert(i >= 0);
|
||||
tnl->vtx.prim[i].count = ((tnl->vtx.initial_counter - tnl->vtx.counter) -
|
||||
tnl->vtx.prim[i].start);
|
||||
if (tnl->vtx.prim_count == 0) {
|
||||
tnl->vtx.copied.nr = 0;
|
||||
tnl->vtx.counter = tnl->vtx.initial_counter;
|
||||
tnl->vtx.vbptr = tnl->vtx.buffer;
|
||||
}
|
||||
else {
|
||||
GLuint last_prim = tnl->vtx.prim[tnl->vtx.prim_count-1].mode;
|
||||
GLuint last_count = tnl->vtx.prim[tnl->vtx.prim_count-1].count;
|
||||
|
||||
/* Execute the buffer and save copied vertices.
|
||||
*/
|
||||
_tnl_flush_vtx( ctx );
|
||||
if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
|
||||
GLint i = tnl->vtx.prim_count - 1;
|
||||
assert(i >= 0);
|
||||
tnl->vtx.prim[i].count = ((tnl->vtx.initial_counter -
|
||||
tnl->vtx.counter) -
|
||||
tnl->vtx.prim[i].start);
|
||||
}
|
||||
|
||||
/* Emit a glBegin to start the new list.
|
||||
*/
|
||||
assert(tnl->vtx.prim_count == 0);
|
||||
/* Execute the buffer and save copied vertices.
|
||||
*/
|
||||
if (tnl->vtx.counter != tnl->vtx.initial_counter)
|
||||
_tnl_flush_vtx( ctx );
|
||||
else {
|
||||
tnl->vtx.prim_count = 0;
|
||||
tnl->vtx.copied.nr = 0;
|
||||
}
|
||||
|
||||
if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
|
||||
tnl->vtx.prim[0].mode = ctx->Driver.CurrentExecPrimitive;
|
||||
tnl->vtx.prim[0].start = 0;
|
||||
tnl->vtx.prim[0].count = 0;
|
||||
tnl->vtx.prim_count++;
|
||||
/* Emit a glBegin to start the new list.
|
||||
*/
|
||||
assert(tnl->vtx.prim_count == 0);
|
||||
|
||||
if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
|
||||
tnl->vtx.prim[0].mode = ctx->Driver.CurrentExecPrimitive;
|
||||
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;
|
||||
if (tnl->vtx.copied.nr == last_count)
|
||||
tnl->vtx.prim[0].mode |= last_prim & PRIM_BEGIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +113,8 @@ static void _tnl_wrap_filled_vertex( GLcontext *ctx )
|
|||
assert(tnl->vtx.counter > tnl->vtx.copied.nr);
|
||||
|
||||
for (i = 0 ; i < tnl->vtx.copied.nr ; i++) {
|
||||
_mesa_memcpy( tnl->vtx.vbptr, data, tnl->vtx.vertex_size * sizeof(GLfloat));
|
||||
_mesa_memcpy( tnl->vtx.vbptr, data,
|
||||
tnl->vtx.vertex_size * sizeof(GLfloat));
|
||||
tnl->vtx.vbptr += tnl->vtx.vertex_size;
|
||||
data += tnl->vtx.vertex_size;
|
||||
tnl->vtx.counter--;
|
||||
|
|
@ -191,6 +207,7 @@ static void _tnl_wrap_upgrade_vertex( GLcontext *ctx,
|
|||
*/
|
||||
_tnl_wrap_buffers( ctx );
|
||||
|
||||
|
||||
/* Do a COPY_TO_CURRENT to ensure back-copying works for the case
|
||||
* when the attribute already exists in the vertex and is having
|
||||
* its size increased.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue