Mesa (master): r300g: upload only vertex buffers referenced by vertex elements

Marek Olšák mareko at kemper.freedesktop.org
Sun Jun 13 08:44:21 PDT 2010


Module: Mesa
Branch: master
Commit: 1384a7bccab3d5b36729d59944a76538375f5494
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1384a7bccab3d5b36729d59944a76538375f5494

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sat Jun 12 20:34:50 2010 +0200

r300g: upload only vertex buffers referenced by vertex elements

---

 src/gallium/drivers/r300/r300_screen_buffer.c |   37 +++++++++++++-----------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 44179f1..fe53f30 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -93,25 +93,28 @@ int r300_upload_user_buffers(struct r300_context *r300)
     enum pipe_error ret = PIPE_OK;
     int i, nr;
 
-    nr = r300->vertex_buffer_count;
+    nr = r300->velems->count;
 
     for (i = 0; i < nr; i++) {
-	if (r300_buffer_is_user_buffer(r300->vertex_buffer[i].buffer)) {
-	    struct pipe_resource *upload_buffer = NULL;
-	    unsigned offset = 0; /*r300->vertex_buffer[i].buffer_offset * 4;*/
-	    unsigned size = r300->vertex_buffer[i].buffer->width0;
-	    unsigned upload_offset;
-	    ret = u_upload_buffer(r300->upload_vb,
-				  offset, size,
-				  r300->vertex_buffer[i].buffer,
-				  &upload_offset, &upload_buffer);
-	    if (ret)
-		return ret;
-
-	    pipe_resource_reference(&r300->vertex_buffer[i].buffer, NULL);
-	    r300->vertex_buffer[i].buffer = upload_buffer;
-	    r300->vertex_buffer[i].buffer_offset = upload_offset;
-	}
+        struct pipe_vertex_buffer *vb =
+            &r300->vertex_buffer[r300->velems->velem[i].vertex_buffer_index];
+
+        if (r300_buffer_is_user_buffer(vb->buffer)) {
+            struct pipe_resource *upload_buffer = NULL;
+            unsigned offset = 0; /*vb->buffer_offset * 4;*/
+            unsigned size = vb->buffer->width0;
+            unsigned upload_offset;
+            ret = u_upload_buffer(r300->upload_vb,
+                                  offset, size,
+                                  vb->buffer,
+                                  &upload_offset, &upload_buffer);
+            if (ret)
+                return ret;
+
+            pipe_resource_reference(&vb->buffer, NULL);
+            vb->buffer = upload_buffer;
+            vb->buffer_offset = upload_offset;
+        }
     }
     return ret;
 }



More information about the mesa-commit mailing list