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.
This commit is contained in:
Keith Whitwell 2008-03-23 18:21:00 +00:00
parent f40357e25c
commit 301b187ca9
3 changed files with 9 additions and 10 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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);