Mesa (master): u_vbuf_mgr: fix max_index computation for large src_offset

Marek Olšák mareko at kemper.freedesktop.org
Mon Sep 26 13:25:25 UTC 2011


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sun Sep 25 18:58:54 2011 +0200

u_vbuf_mgr: fix max_index computation for large src_offset

NOTE: This is a candidate for the 7.11 branch.

---

 src/gallium/auxiliary/util/u_vbuf_mgr.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.c b/src/gallium/auxiliary/util/u_vbuf_mgr.c
index b2070ab..66c90a5 100644
--- a/src/gallium/auxiliary/util/u_vbuf_mgr.c
+++ b/src/gallium/auxiliary/util/u_vbuf_mgr.c
@@ -570,8 +570,7 @@ static void u_vbuf_mgr_compute_max_index(struct u_vbuf_mgr_priv *mgr)
    for (i = 0; i < nr; i++) {
       struct pipe_vertex_buffer *vb =
             &mgr->b.vertex_buffer[mgr->ve->ve[i].vertex_buffer_index];
-      int unused;
-      unsigned max_index;
+      unsigned max_index, src_size, unused;
 
       if (!vb->buffer ||
           !vb->stride ||
@@ -580,16 +579,17 @@ static void u_vbuf_mgr_compute_max_index(struct u_vbuf_mgr_priv *mgr)
          continue;
       }
 
-      /* How many bytes is unused after the last vertex.
-       * width0 may be "count*stride - unused" and we have to compensate
-       * for that when dividing by stride. */
-      unused = vb->stride -
-               (mgr->ve->ve[i].src_offset + mgr->ve->src_format_size[i]);
+      src_size = mgr->ve->ve[i].src_offset + mgr->ve->src_format_size[i];
 
       /* If src_offset is greater than stride (which means it's a buffer
        * offset rather than a vertex offset)... */
-      if (unused < 0) {
+      if (src_size >= vb->stride) {
          unused = 0;
+      } else {
+         /* How many bytes is unused after the last vertex.
+          * width0 may be "count*stride - unused" and we have to compensate
+          * for that when dividing by stride. */
+         unused = vb->stride - src_size;
       }
 
       /* Compute the maximum index for this vertex element. */




More information about the mesa-commit mailing list