From 8b2ebd15310cbd5d905b08761b5e950f8e2580e5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 16 Apr 2009 12:19:19 +0100 Subject: vbo: cache last dlist vertex in malloced memory Avoids repeated mapping of the VBO buffer on display list replay. We need access to the final vertex in order to update the GL current attrib values. --- src/mesa/vbo/vbo_save_api.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/mesa/vbo/vbo_save_api.c') diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 52b6f1884e..868226075a 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -289,6 +289,31 @@ static void _save_compile_vertex_list( GLcontext *ctx ) node->vertex_store->refcount++; node->prim_store->refcount++; + + node->current_size = node->vertex_size - node->attrsz[0]; + node->current_data = NULL; + + if (node->current_size) { + /* If the malloc fails, we just pull the data out of the VBO + * later instead. + */ + node->current_data = MALLOC( node->current_size * sizeof(GLfloat) ); + if (node->current_data) { + const char *buffer = (const char *)save->vertex_store->buffer; + unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat); + unsigned vertex_offset = 0; + + if (node->count) + vertex_offset = (node->count-1) * node->vertex_size * sizeof(GLfloat); + + memcpy( node->current_data, + buffer + node->buffer_offset + vertex_offset + attr_offset, + node->current_size * sizeof(GLfloat) ); + } + } + + + assert(node->attrsz[VBO_ATTRIB_POS] != 0 || node->count == 0); -- cgit v1.2.3