From: Keith Whitwell Date: Sun, 23 Mar 2008 18:21:00 +0000 (+0000) Subject: draw: fix some unsigned vs ushort confusion X-Git-Tag: 062012170305~17580^2~390^2~2134 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=301b187ca9a811b608894d20bab934af0a10b8ab;p=profile%2Fivi%2Fmesa.git draw: fix some unsigned vs ushort confusion Middle-end elements are ushort, but prior to that have to treat all elements as unsigned to avoid wrapping and/or overruns. --- diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index 1b81d19..f56fa8d 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -35,7 +35,7 @@ #include "pipe/p_compiler.h" -typedef ushort (*pt_elt_func)( const void *elts, ushort idx ); +typedef unsigned (*pt_elt_func)( const void *elts, unsigned idx ); /* The "front end" - prepare sets of fetch, draw elements for the diff --git a/src/gallium/auxiliary/draw/draw_pt_elts.c b/src/gallium/auxiliary/draw/draw_pt_elts.c index 585b83f..f337f71 100644 --- a/src/gallium/auxiliary/draw/draw_pt_elts.c +++ b/src/gallium/auxiliary/draw/draw_pt_elts.c @@ -37,22 +37,22 @@ * the start value into a pointer. */ -static ushort elt_uint( const void *elts, ushort idx ) +static unsigned elt_uint( const void *elts, unsigned idx ) { return *(((const uint *)elts) + idx); } -static ushort elt_ushort( const void *elts, ushort idx ) +static unsigned elt_ushort( const void *elts, unsigned idx ) { return *(((const ushort *)elts) + idx); } -static ushort elt_ubyte( const void *elts, ushort idx ) +static unsigned elt_ubyte( const void *elts, unsigned idx ) { return *(((const ubyte *)elts) + idx); } -static ushort elt_vert( const void *elts, ushort idx ) +static unsigned elt_vert( const void *elts, unsigned idx ) { return (const ubyte *)elts - (const ubyte *)NULL + idx; } diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 07e9f0a..98c22eb 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -45,7 +45,7 @@ struct vcache_frontend { struct draw_pt_front_end base; - ushort in[CACHE_MAX]; + unsigned in[CACHE_MAX]; ushort out[CACHE_MAX]; ushort draw_elts[DRAW_MAX]; @@ -74,13 +74,14 @@ static void vcache_flush( struct vcache_frontend *vcache ) } #endif - if (vcache->draw_count) + if (vcache->draw_count) { vcache->middle->run( vcache->middle, vcache->output_prim, vcache->fetch_elts, vcache->fetch_count, vcache->draw_elts, vcache->draw_count ); + } memset(vcache->in, ~0, sizeof(vcache->in)); vcache->fetch_count = 0; @@ -100,9 +101,7 @@ static void vcache_check_flush( struct vcache_frontend *vcache ) static void vcache_elt( struct vcache_frontend *vcache, unsigned felt ) { - // ushort felt = elt(draw, i); - - ushort idx = felt % CACHE_MAX; + unsigned idx = felt % CACHE_MAX; if (vcache->in[idx] != felt) { assert(vcache->fetch_count < FETCH_MAX);