[Mesa-dev] Gallium pixel formats on big-endian

Michel Dänzer michel at daenzer.net
Mon Feb 4 22:45:12 PST 2013


On Mon, 2013-02-04 at 20:17 +0100, Michel Dänzer wrote: 
> 
> [...] how about something like this:
> 
> Define the packing to be in the host byte order. However, do not define
> array formats as packed values (which makes little sense e.g. for
> *32*32*32*32 anyway) but really just as arrays. 16- or 32-bit components
> of arrays are again packed in host byte order. Array components of 4, 2
> or 1 bits occupy bits [0,n-1] of byte 0, then bits [n,2n-1] of byte
> 0, ..., bits [0,n-1] of byte 1, and so on.
> 
> To make the distinction between packed and array formats clear, they
> should probably use different naming schemes. The current scheme makes
> more sense for packed formats I think, so I'd propose separating array
> components e.g. by an additional underscore, and ordering components
> from lower memory address left to higher address right. As an example,
> PIPE_FORMAT_R8G8_UNORM would become PIPE_FORMAT_R8_G8_UNORM. It would
> probably make sense to define packed naming aliases for array formats
> where possible, e.g. PIPE_FORMAT_R8_R8_UNORM would alias to
> PIPE_FORMAT_R8G8_UNORM (which would be identical to MESA_FORMAT_GR88) on
> little endian and PIPE_FORMAT_G8R8_UNORM (== MESA_FORMAT_RG88) on big
> endian hosts. (That's using the current component ordering for packed
> formats; IMHO the reverse order would actually make more sense for
> those, but that might require more invasive changes...)

Actually, on second thought this means it's probably better to keep the
current naming scheme for array formats. Maybe the component names and
sizes could be packed together to indicate packed formats, e.g.
PIPE_FORMAT_B5G6R5_UNORM would become PIPE_FORMAT_RGB565_UNORM and would
be defined identically to MESA_FORMAT_RGB565.

For my example above, PIPE_FORMAT_R8G8_UNORM would alias to
PIPE_FORMAT_GR88_UNORM (== MESA_FORMAT_GR88) on little endian and to
PIPE_FORMAT_RG88_UNORM (== MESA_FORMAT_RG88) on big endian.

In addition to the pros I mentioned in my previous post, this should
bring the Gallium and Mesa format naming closer, with even fewer changes
required. :)


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


More information about the mesa-dev mailing list