Mesa (master): nvc0: upload user buffers only from draw info min to max index

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Sat Jan 8 01:15:24 UTC 2011


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

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Sat Jan  8 00:49:17 2011 +0100

nvc0: upload user buffers only from draw info min to max index

There are actually applications that profit immensely from this.

---

 src/gallium/drivers/nvc0/nvc0_context.h |    2 ++
 src/gallium/drivers/nvc0/nvc0_vbo.c     |   10 +++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_context.h b/src/gallium/drivers/nvc0/nvc0_context.h
index 83aff0a..c181f15 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nvc0/nvc0_context.h
@@ -101,6 +101,8 @@ struct nvc0_context {
    unsigned num_vtxbufs;
    struct pipe_index_buffer idxbuf;
    uint32_t vbo_fifo;
+   unsigned vbo_min_index; /* from pipe_draw_info, for vertex upload */
+   unsigned vbo_max_index;
 
    struct pipe_sampler_view *textures[5][PIPE_MAX_SAMPLERS];
    unsigned num_textures[5];
diff --git a/src/gallium/drivers/nvc0/nvc0_vbo.c b/src/gallium/drivers/nvc0/nvc0_vbo.c
index c6a88a7..881f065 100644
--- a/src/gallium/drivers/nvc0/nvc0_vbo.c
+++ b/src/gallium/drivers/nvc0/nvc0_vbo.c
@@ -161,9 +161,10 @@ nvc0_vertex_arrays_validate(struct nvc0_context *nvc0)
             continue;
          push = nvc0->vbo_push_hint;
          if (!push) {
-            nvc0_migrate_vertices(nvc0_resource(vb->buffer),
-                                  vb->buffer_offset,
-                                  vb->buffer->width0 - vb->buffer_offset);
+            unsigned base, size;
+            base = vb->buffer_offset + nvc0->vbo_min_index * vb->stride;
+            size = (nvc0->vbo_max_index - nvc0->vbo_min_index + 1) * vb->stride;
+            nvc0_migrate_vertices(nvc0_resource(vb->buffer), base, size);
             nvc0->vbo_dirty = TRUE;
          } else
             continue;
@@ -536,6 +537,9 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       !(info->indexed &&
         ((info->max_index - info->min_index + 64) < info->count));
 
+   nvc0->vbo_min_index = info->min_index;
+   nvc0->vbo_max_index = info->max_index;
+
    nvc0_state_validate(nvc0);
 
    if (nvc0->state.instance_base != info->start_instance) {




More information about the mesa-commit mailing list