summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-07-16 11:09:17 -0600
committerBrian Paul <[email protected]>2010-07-16 11:09:32 -0600
commit959a458ea01d5fa4274bdd439da114b42d3b86d3 (patch)
treec0083d87796c3de6e8921c801ac675653407ec48
parent2f6d47a7c8d6e69e5154de44115aab9ba35a41d2 (diff)
draw: added array element debug / bounds checking code (disabled)
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c28
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 b7e0da7d44e..d856bd8bd3d 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) {