Mesa (master): draw: added array element debug / bounds checking code ( disabled)

Brian Paul brianp at kemper.freedesktop.org
Fri Jul 16 17:57:17 UTC 2010


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

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Jul 16 11:09:17 2010 -0600

draw: added array element debug / bounds checking code (disabled)

---

 src/gallium/auxiliary/draw/draw_pt_vcache.c |   28 +++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index b7e0da7..d856bd8 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -344,10 +344,10 @@ vcache_check_run( struct draw_pt_front_end *frontend,
 {
    struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; 
    struct draw_context *draw = vcache->draw;
-   unsigned min_index = draw->pt.user.min_index;
-   unsigned max_index = draw->pt.user.max_index;
-   unsigned index_size = draw->pt.user.eltSize;
-   unsigned fetch_count = max_index + 1 - min_index;
+   const unsigned min_index = draw->pt.user.min_index;
+   const unsigned max_index = draw->pt.user.max_index;
+   const unsigned index_size = draw->pt.user.eltSize;
+   const unsigned fetch_count = max_index + 1 - min_index;
    const ushort *transformed_elts;
    ushort *storage = NULL;
    boolean ok = FALSE;
@@ -357,6 +357,26 @@ vcache_check_run( struct draw_pt_front_end *frontend,
                        vcache->fetch_max,
                        draw_count);
 
+   /* debug: verify indexes are in range [min_index, max_index] */
+   if (0) {
+      unsigned i;
+      for (i = 0; i < draw_count; i++) {
+         if (index_size == 1) {
+            assert( ((const ubyte *) elts)[i] >= min_index);
+            assert( ((const ubyte *) elts)[i] <= max_index);
+         }
+         else if (index_size == 2) {
+            assert( ((const ushort *) elts)[i] >= min_index);
+            assert( ((const ushort *) elts)[i] <= max_index);
+         }
+         else {
+            assert(index_size == 4);
+            assert( ((const uint *) elts)[i] >= min_index);
+            assert( ((const uint *) elts)[i] <= max_index);
+         }
+      }
+   }
+
    if (elt_bias + max_index >= DRAW_PIPE_MAX_VERTICES ||
        fetch_count >= UNDEFINED_VERTEX_ID ||
        fetch_count > draw_count) {




More information about the mesa-commit mailing list