+ /* Calculate new IM->Elts, IM->Primitive, IM->PrimitiveLength for
+ * the case where vertex maps are not enabled for some received eval
+ * coordinates.
+ */
+ if (purge_flags) {
+ GLuint vertex = VERT_OBJ|(VERT_EVAL_ANY & ~purge_flags);
+ GLuint last_new_prim = 0;
+ GLuint new_prim_length = 0;
+ GLuint next_old_prim = 0;
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i,j,count = VB->Count;
+
+/* fprintf(stderr, "PURGING\n"); */
+
+ for (i = 0, j = 0 ; i < count ; i++) {
+ if (flags[i] & vertex) {
+ store->Elt[j++] = i;
+ new_prim_length++;
+ }
+ if (i == next_old_prim) {
+ next_old_prim += VB->PrimitiveLength[i];
+ VB->PrimitiveLength[last_new_prim] = new_prim_length;
+ VB->Primitive[j] = VB->Primitive[i];
+ last_new_prim = j;
+ }
+ }
+
+ VB->Elts = store->Elt;
+ _tnl_get_purged_copy_verts( ctx, store );
+ }
+
+ /* Produce new flags array:
+ */