u_vbuf_mgr: avoid one call to pipe_resource_reference in most cases
authorMarek Olšák <maraeo@gmail.com>
Fri, 4 Nov 2011 17:06:04 +0000 (18:06 +0100)
committerMarek Olšák <maraeo@gmail.com>
Fri, 4 Nov 2011 17:11:01 +0000 (18:11 +0100)
src/gallium/auxiliary/util/u_vbuf_mgr.c

index 6c2d1ed64002b93014de08b891c112c279a0140a..ca4f795f0342ce0163dd9dee7b56f64773de6f34 100644 (file)
@@ -471,7 +471,6 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
       const struct pipe_vertex_buffer *vb = &bufs[i];
 
       pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
-      pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
 
       mgr->b.real_vertex_buffer[i].buffer_offset =
       mgr->b.vertex_buffer[i].buffer_offset = vb->buffer_offset;
@@ -480,10 +479,12 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
       mgr->b.vertex_buffer[i].stride = vb->stride;
 
       if (!vb->buffer) {
+         pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
          continue;
       }
 
       if (u_vbuf_resource(vb->buffer)->user_ptr) {
+         pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
          mgr->any_user_vbs = TRUE;
          continue;
       }