1848b8605SmrgFormats in gallium
2848b8605Smrg==================
3848b8605Smrg
4848b8605SmrgGallium format names mostly follow D3D10 conventions, with some extensions.
5848b8605Smrg
6848b8605SmrgFormat names like XnYnZnWn have the X component in the lowest-address n bits
7848b8605Smrgand the W component in the highest-address n bits; for B8G8R8A8, byte 0 is
8848b8605Smrgblue and byte 3 is alpha.  Note that platform endianness is not considered
9848b8605Smrgin this definition.  In C::
10848b8605Smrg
11848b8605Smrg    struct x8y8z8w8 { uint8_t x, y, z, w; };
12848b8605Smrg
13848b8605SmrgFormat aliases like XYZWstrq are (s+t+r+q)-bit integers in host endianness,
14848b8605Smrgwith the X component in the s least-significant bits of the integer.  In C::
15848b8605Smrg
16848b8605Smrg    uint32_t xyzw8888 = (x << 0) | (y << 8) | (z << 16) | (w << 24);
17848b8605Smrg
18848b8605SmrgFormat suffixes affect the interpretation of the channel:
19848b8605Smrg
20848b8605Smrg- ``SINT``:     N bit signed integer [-2^(N-1) ... 2^(N-1) - 1]
21848b8605Smrg- ``SNORM``:    N bit signed integer normalized to [-1 ... 1]
22848b8605Smrg- ``SSCALED``:  N bit signed integer [-2^(N-1) ... 2^(N-1) - 1]
23848b8605Smrg- ``FIXED``:    Signed fixed point integer, (N/2 - 1) bits of mantissa
24848b8605Smrg- ``FLOAT``:    N bit IEEE754 float
25848b8605Smrg- ``NORM``:     Normalized integers, signed or unsigned per channel
26848b8605Smrg- ``UINT``:     N bit unsigned integer [0 ... 2^N - 1]
27848b8605Smrg- ``UNORM``:    N bit unsigned integer normalized to [0 ... 1]
28848b8605Smrg- ``USCALED``:  N bit unsigned integer [0 ... 2^N - 1]
29848b8605Smrg
30848b8605SmrgThe difference between ``SINT`` and ``SSCALED`` is that the former are pure
31848b8605Smrgintegers in shaders, while the latter are floats; likewise for ``UINT`` versus
32848b8605Smrg``USCALED``.
33848b8605Smrg
34848b8605SmrgThere are two exceptions for ``FLOAT``.  ``R9G9B9E5_FLOAT`` is nine bits
35848b8605Smrgeach of red green and blue mantissa, with a shared five bit exponent.
36848b8605Smrg``R11G11B10_FLOAT`` is five bits of exponent and five or six bits of mantissa
37848b8605Smrgfor each color channel.
38848b8605Smrg
39848b8605SmrgFor the ``NORM`` suffix, the signedness of each channel is indicated with an
40848b8605SmrgS or U after the number of channel bits, as in ``R5SG5SB6U_NORM``.
41848b8605Smrg
42848b8605SmrgThe ``SRGB`` suffix is like ``UNORM`` in range, but in the sRGB colorspace.
43848b8605Smrg
44848b8605SmrgCompressed formats are named first by the compression format string (``DXT1``,
45848b8605Smrg``ETC1``, etc), followed by a format-specific subtype.  Refer to the
46848b8605Smrgappropriate compression spec for details.
47848b8605Smrg
48848b8605SmrgFormats used in video playback are named by their FOURCC code.
49848b8605Smrg
50848b8605SmrgFormat names with an embedded underscore are subsampled.  ``R8G8_B8G8`` is a
51848b8605Smrgsingle 32-bit block of two pixels, where the R and B values are repeated in
52848b8605Smrgboth pixels.
53848b8605Smrg
54848b8605SmrgReferences
55848b8605Smrg----------
56848b8605Smrg
57848b8605SmrgDirectX Graphics Infrastructure documentation on DXGI_FORMAT enum:
58848b8605Smrghttp://msdn.microsoft.com/en-us/library/windows/desktop/bb173059%28v=vs.85%29.aspx
59848b8605Smrg
60848b8605SmrgFOURCC codes for YUV formats:
61848b8605Smrghttp://www.fourcc.org/yuv.php
62