#endif
};
-struct vbo_save_copied_vtx {
- fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS];
- GLuint nr;
-};
struct vbo_save_context {
GLvertexformat vtxfmt;
GLuint vert_count;
GLboolean dangling_attr_ref;
- struct vbo_save_copied_vtx copied;
+ struct {
+ fi_type *buffer;
+ GLuint nr;
+ } copied;
fi_type *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */
GLubyte *currentsz[VBO_ATTRIB_MAX];
struct vbo_save_context *save = &vbo_context(ctx)->save;
struct _mesa_prim *prim = &node->cold->prims[node->cold->prim_count - 1];
GLuint sz = save->vertex_size;
- const fi_type *src = src_buffer + prim->start * sz;
- fi_type *dst = save->copied.buffer;
- if (prim->end)
+ if (prim->end || !prim->count || !sz)
return 0;
+ const fi_type *src = src_buffer + prim->start * sz;
+ assert(save->copied.buffer == NULL);
+ save->copied.buffer = malloc(sizeof(fi_type) * sz * prim->count);
+
return vbo_copy_vertices(ctx, prim->mode, prim->start, &prim->count,
- prim->begin, sz, true, dst, src);
+ prim->begin, sz, true, save->copied.buffer, src);
}
numComponents = save->copied.nr * save->vertex_size;
fi_type *buffer_ptr = save->vertex_store->buffer_in_ram;
- memcpy(buffer_ptr,
- save->copied.buffer,
- numComponents * sizeof(fi_type));
+ if (numComponents) {
+ assert(save->copied.buffer);
+ memcpy(buffer_ptr,
+ save->copied.buffer,
+ numComponents * sizeof(fi_type));
+ free(save->copied.buffer);
+ save->copied.buffer = NULL;
+ }
assert(save->vertex_store->used == 0 && save->vert_count == 0);
save->vert_count = save->copied.nr;
save->vertex_store->used = numComponents;
* and will need fixup at runtime.
*/
if (save->copied.nr) {
+ assert(save->copied.buffer);
const fi_type *data = save->copied.buffer;
fi_type *dest = save->vertex_store->buffer_in_ram;
save->vert_count += save->copied.nr;
save->vertex_store->used += save->vertex_size * save->copied.nr;
+ free(save->copied.buffer);
+ save->copied.buffer = NULL;
}
}