From: Michel D. <mi...@da...> - 2010-03-01 17:03:13
|
On Fri, 2010-02-26 at 08:47 -0800, Jose Fonseca wrote: > Module: Mesa > Branch: master > Commit: 9beb302212a2afac408016cbd7b93c8b859e4910 > URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9beb302212a2afac408016cbd7b93c8b859e4910 > > Author: José Fonseca <jfo...@vm...> > Date: Fri Feb 26 16:45:22 2010 +0000 > > util: Code generate functions to pack and unpack a single pixel. > > Should work correctly for all pixel formats except SRGB formats. > > Generated code made much simpler by defining the pixel format as > a C structure. For example this is the generated structure for > PIPE_FORMAT_B6UG5SR5S_NORM: > > union util_format_b6ug5sr5s_norm { > uint16_t value; > struct { > int r:5; > int g:5; > unsigned b:6; > } chan; > }; José, are you aware that the memory layout of bitfields is mostly implementation dependent? IME this makes them mostly unusable for modelling hardware in a portable manner. > Not used everywhere yet because it seems compiled code is slower than > bitshift arithmetic by some misterious reason. So we should generate > bitshift arithmetic at least for the simple UNORM pixel formats. Due to above I'd recommend always using bitshift arithmetic rather than bitfields anyway. :) -- Earthling Michel Dänzer | http://www.vmware.com Libre software enthusiast | Debian, X and DRI developer |