diff options
Diffstat (limited to 'src/mesa/vbo/vbo_exec_api.c')
-rw-r--r-- | src/mesa/vbo/vbo_exec_api.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 88cce984f8d..600398c5891 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -719,6 +719,34 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) /** + * Try to merge / concatenate the two most recent VBO primitives. + */ +static void +try_vbo_merge(struct vbo_exec_context *exec) +{ + struct _mesa_prim *cur = &exec->vtx.prim[exec->vtx.prim_count - 1]; + + assert(exec->vtx.prim_count >= 1); + + vbo_try_prim_conversion(cur); + + if (exec->vtx.prim_count >= 2) { + struct _mesa_prim *prev = &exec->vtx.prim[exec->vtx.prim_count - 2]; + assert(prev == cur - 1); + + if (vbo_can_merge_prims(prev, cur)) { + assert(cur->begin); + assert(cur->end); + assert(prev->begin); + assert(prev->end); + vbo_merge_prims(prev, cur); + exec->vtx.prim_count--; /* drop the last primitive */ + } + } +} + + +/** * Called via glEnd. */ static void GLAPIENTRY vbo_exec_End( void ) @@ -744,6 +772,8 @@ static void GLAPIENTRY vbo_exec_End( void ) exec->vtx.prim[i].end = 1; exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start; + + try_vbo_merge(exec); } ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; |