In get_vertex(), slot was computed using & 31. Replace with % VCACHE_SIZE.
authorBrian <brian.paul@tungstengraphics.com>
Tue, 23 Oct 2007 18:32:02 +0000 (12:32 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 23 Oct 2007 18:32:02 +0000 (12:32 -0600)
Also, assert that index is not too large before indexing array.

src/mesa/pipe/draw/draw_vertex_cache.c

index 1f4adededeed3a11535071f40fd45845a78ddba0..dc939d6d14ff630f5138d64b4a527a1e0e0dd528 100644 (file)
@@ -57,7 +57,7 @@ void draw_vertex_cache_invalidate( struct draw_context *draw )
 static struct vertex_header *get_vertex( struct draw_context *draw,
                                         unsigned i )
 {
-   unsigned slot = (i + (i>>5)) & 31;
+   unsigned slot = (i + (i>>5)) % VCACHE_SIZE;
    
    /* Cache miss?
     */
@@ -74,6 +74,8 @@ static struct vertex_header *get_vertex( struct draw_context *draw,
          draw->vcache.referenced |= (1 << slot);  /* slot now in use */
       }
 
+      assert(slot < Elements(draw->vcache.idx));
+
       draw->vcache.idx[slot] = i;
 
       /* Add to vertex shader queue: