[Mesa-dev] [PATCH 11/11] mesa: Optimize rebinding the same VBO

Fredrik Höglund fredrik at kde.org
Mon Oct 28 23:33:54 CET 2013


Check if the new buffer object has the same name as the current
buffer object before looking it up.
---
 src/mesa/main/varray.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 5b5b8b2..93581ea 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1367,6 +1367,7 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
                        GLsizei stride)
 {
    struct gl_buffer_object *vbo;
+   struct gl_vertex_buffer_binding *binding;
 
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -1413,7 +1414,11 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
       return;
    }
 
-   if (buffer != 0) {
+   binding = gl_vertex_buffer_binding(ctx, VERT_ATTRIB_GENERIC(bindingIndex));
+
+   if (buffer == binding->BufferObj->Name) {
+      vbo = binding->BufferObj;
+   } else if (buffer != 0) {
       vbo = _mesa_lookup_bufferobj(ctx, buffer);
 
       /* The ARB_vertex_attrib_binding spec doesn't specify that an error
-- 
1.7.10.4



More information about the mesa-dev mailing list