/** * For a list of prims, try merging prims that can just be extensions of the * previous prim. */ static void merge_prims(struct gl_context *ctx, struct _mesa_prim *prim_list, GLuint *prim_count) { GLuint i; struct _mesa_prim *prev_prim = prim_list; for (i = 1; i < *prim_count; i++) { struct _mesa_prim *this_prim = prim_list + i; vbo_try_prim_conversion(this_prim); if (vbo_can_merge_prims(prev_prim, this_prim)) { /* We've found a prim that just extend the previous one. Tack it * onto the previous one, and let this primitive struct get dropped. */ vbo_merge_prims(prev_prim, this_prim); continue; } /* If any previous primitives have been dropped, then we need to copy * this later one into the next available slot. */ prev_prim++; if (prev_prim != this_prim) *prev_prim = *this_prim; } *prim_count = prev_prim - prim_list + 1; }
/** * 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 */ } } }