Mesa (gallium-index-bias): draw: Fix cache elt_bias implementation.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Apr 20 08:37:33 UTC 2010


Module: Mesa
Branch: gallium-index-bias
Commit: 4e8154e8666ec9375936bbe3fa2ca925ff9be5df
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e8154e8666ec9375936bbe3fa2ca925ff9be5df

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Apr 20 10:32:06 2010 +0200

draw: Fix cache elt_bias implementation.

---

 src/gallium/auxiliary/draw/draw_pt_vcache.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index a513188..28dc514 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -347,7 +347,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
                        vcache->fetch_max,
                        draw_count);
       
-   if (max_index >= DRAW_PIPE_MAX_VERTICES ||
+   if (elt_bias + max_index >= DRAW_PIPE_MAX_VERTICES ||
        fetch_count >= UNDEFINED_VERTEX_ID ||
        fetch_count > draw_count) {
       if (0) debug_printf("fail\n");
@@ -363,6 +363,9 @@ vcache_check_run( struct draw_pt_front_end *frontend,
    }
 
 
+   assert((elt_bias >= 0 && min_index + elt_bias >= min_index) ||
+          (elt_bias <  0 && min_index + elt_bias <  min_index));
+
    if (elt_bias <= 0 &&
        min_index == (unsigned)-elt_bias &&
        index_size == 2)
@@ -407,21 +410,21 @@ vcache_check_run( struct draw_pt_front_end *frontend,
          case 1:
             rebase_ubyte_elts( (const ubyte *)elts,
                                   draw_count,
-                                  elt_bias - (int)min_index,
+                                  -elt_bias - (int)min_index,
                                   storage );
             break;
 
          case 2:
             rebase_ushort_elts( (const ushort *)elts,
                                    draw_count,
-                                   elt_bias - (int)min_index,
+                                   -elt_bias - (int)min_index,
                                    storage );
             break;
 
          case 4:
             rebase_uint_elts( (const uint *)elts,
                                  draw_count,
-                                 elt_bias - (int)min_index,
+                                 -elt_bias - (int)min_index,
                                  storage );
             break;
 
@@ -436,7 +439,7 @@ vcache_check_run( struct draw_pt_front_end *frontend,
 
    if (fetch_count < UNDEFINED_VERTEX_ID)
       ok = vcache->middle->run_linear_elts( vcache->middle,
-                                            min_index, /* start */
+                                            min_index + elt_bias, /* start */
                                             fetch_count,
                                             transformed_elts,
                                             draw_count );




More information about the mesa-commit mailing list