summaryrefslogtreecommitdiff
path: root/src/mesa/vbo/vbo_save_api.c
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2009-04-16 12:19:19 +0100
committerKeith Whitwell <keithw@vmware.com>2009-04-16 12:19:19 +0100
commit8b2ebd15310cbd5d905b08761b5e950f8e2580e5 (patch)
tree9b0775ff18df77fa3730d45156bef73c90c39d7a /src/mesa/vbo/vbo_save_api.c
parente80d1e367a25af406c7f2327646c0aa699962fe8 (diff)
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.
Diffstat (limited to 'src/mesa/vbo/vbo_save_api.c')
-rw-r--r--src/mesa/vbo/vbo_save_api.c25
1 files changed, 25 insertions, 0 deletions
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);