summaryrefslogtreecommitdiff
path: root/src/mesa/vbo/vbo_exec_draw.c
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2010-10-31 23:51:30 +0100
committerFrancisco Jerez <currojerez@riseup.net>2010-11-06 01:59:59 +0100
commit2e64c2209e7f9d5acbcc9d70bf315732f3c403b3 (patch)
treedb64ff8d903ccee8c3cf0c8b894d5b313cc96fce /src/mesa/vbo/vbo_exec_draw.c
parentf1600d3a9725803f0526fb3fd673787307539d27 (diff)
vbo: Avoid unnecessary copy to/from current in vertex format upgrade.
Rebuilding the vertex format from scratch every time we see a new vertex attribute is rather costly, new attributes can be appended at the end avoiding a copy to current and then back again, and the full attr pointer recalculation. In the not so likely case of an already existing attribute having its size increased the old behavior is preserved, this could be optimized more, not sure if it's worth it. It's a modest improvement in FlightGear (that game punishes the VBO module pretty hard in general, framerate goes from some 46 FPS to 50 FPS with the nouveau classic driver). Signed-off-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa/vbo/vbo_exec_draw.c')
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 71ac0066ca..94aa021ac9 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -160,7 +160,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
struct vbo_exec_context *exec = &vbo->exec;
struct gl_client_array *arrays = exec->vtx.arrays;
const GLuint count = exec->vtx.vert_count;
- const GLubyte *data = (GLubyte *) exec->vtx.buffer_map;
const GLuint *map;
GLuint attr;
GLbitfield varying_inputs = 0x0;
@@ -215,6 +214,9 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
const GLuint src = map[attr];
if (exec->vtx.attrsz[src]) {
+ GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[src] -
+ (GLbyte *)exec->vtx.vertex;
+
/* override the default array set above */
ASSERT(attr < Elements(exec->vtx.inputs));
ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */
@@ -222,17 +224,13 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
if (_mesa_is_bufferobj(exec->vtx.bufferobj)) {
/* a real buffer obj: Ptr is an offset, not a pointer*/
- GLsizeiptr offset;
assert(exec->vtx.bufferobj->Pointer); /* buf should be mapped */
- offset = (GLbyte *) data -
- (GLbyte *) exec->vtx.bufferobj->Pointer +
- exec->vtx.bufferobj->Offset;
assert(offset >= 0);
- arrays[attr].Ptr = (void *) offset;
+ arrays[attr].Ptr = (GLubyte *)exec->vtx.bufferobj->Offset + offset;
}
else {
/* Ptr into ordinary app memory */
- arrays[attr].Ptr = (void *) data;
+ arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset;
}
arrays[attr].Size = exec->vtx.attrsz[src];
arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
@@ -245,7 +243,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
exec->vtx.bufferobj);
arrays[attr]._MaxElement = count; /* ??? */
- data += exec->vtx.attrsz[src] * sizeof(GLfloat);
varying_inputs |= 1 << attr;
}
}