On Thu, 2009-11-26 at 19:09 +0100, Christoph Bumiller wrote: 
> tom fogal schrieb:
> > Christoph Bumiller <[email protected]> writes:
> >   
> >> Hi. Now that there's util_bitcount in u_math, I'd like to have a
> >> bswap helper as well,
> >> I need to swap the stipple pattern on nv50. Any objections ?
> >>     
> > [snip]
> >   
> >>  src/gallium/auxiliary/util/u_math.h |   17 +++++++++++++++++
> >>  1 files changed, 17 insertions(+), 0 deletions(-)
> >>     
> > [snip]
> >   
> >> + * Reverse byte order of a 32 bit word.
> >> + */
> >> +static INLINE uint32_t
> >> +util_bswap32(uint32_t n)
> >> +{
> >> +#if defined(PIPE_CC_GCC)
> >> +   return __builtin_bswap32(n);
> >> +#else
> >> +   return (n >> 24) |
> >> +          ((n >> 8) & 0x0000ff00) |
> >> +          ((n << 8) & 0x00ff0000) |
> >> +          (n << 24);
> >>     
> >
> > Is there a reason you can't just use CPU_TO_LE32 from
> > src/mesa/main/compiler.h?
> >
> > Of course, 1) that's only if you need your data in little endian
> > format, and 2) it's based on a compile-time test, w/ a big warning
> > about that at the definition.  So you might prefer to avoid using it
> >   
> My application for the bswap32 doesn't really have to do with endianness,
> the polygon stipple pattern just happens to have a width of 32 bits, and for
> reasons unknown to me that *bitmap* is unconditionally shuffled "to handle
> endian differences" in mesa/main/image.c, and I need to undo that for the
> hardware.
> 
> So I admit this util function might not see much use, and I could just
> inline it
> in this case (as is done in _mesa_unpack_polygon_stipple) if you prefer, but
> it (looks) nicer with util_bswap32 in my opinion.

It (or something like it) should come in handy for drivers running on
big endian platforms. Thumbs up from me.


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to