17ec681f3SmrgFormats in gallium 27ec681f3Smrg================== 37ec681f3Smrg 47ec681f3SmrgGallium format names mostly follow D3D10 conventions, with some extensions. 57ec681f3Smrg 67ec681f3SmrgFormat names like XnYnZnWn have the X component in the lowest-address n bits 77ec681f3Smrgand the W component in the highest-address n bits; for B8G8R8A8, byte 0 is 87ec681f3Smrgblue and byte 3 is alpha. Note that platform endianness is not considered 97ec681f3Smrgin this definition. In C:: 107ec681f3Smrg 117ec681f3Smrg struct x8y8z8w8 { uint8_t x, y, z, w; }; 127ec681f3Smrg 137ec681f3SmrgFormat aliases like XYZWstrq are (s+t+r+q)-bit integers in host endianness, 147ec681f3Smrgwith the X component in the s least-significant bits of the integer. In C:: 157ec681f3Smrg 167ec681f3Smrg uint32_t xyzw8888 = (x << 0) | (y << 8) | (z << 16) | (w << 24); 177ec681f3Smrg 187ec681f3SmrgFormat suffixes affect the interpretation of the channel: 197ec681f3Smrg 207ec681f3Smrg- ``SINT``: N bit signed integer [-2^(N-1) ... 2^(N-1) - 1] 217ec681f3Smrg- ``SNORM``: N bit signed integer normalized to [-1 ... 1] 227ec681f3Smrg- ``SSCALED``: N bit signed integer [-2^(N-1) ... 2^(N-1) - 1] 237ec681f3Smrg- ``FIXED``: Signed fixed point integer, (N/2 - 1) bits of mantissa 247ec681f3Smrg- ``FLOAT``: N bit IEEE754 float 257ec681f3Smrg- ``NORM``: Normalized integers, signed or unsigned per channel 267ec681f3Smrg- ``UINT``: N bit unsigned integer [0 ... 2^N - 1] 277ec681f3Smrg- ``UNORM``: N bit unsigned integer normalized to [0 ... 1] 287ec681f3Smrg- ``USCALED``: N bit unsigned integer [0 ... 2^N - 1] 297ec681f3Smrg 307ec681f3SmrgThe difference between ``SINT`` and ``SSCALED`` is that the former are pure 317ec681f3Smrgintegers in shaders, while the latter are floats; likewise for ``UINT`` versus 327ec681f3Smrg``USCALED``. 337ec681f3Smrg 347ec681f3SmrgThere are two exceptions for ``FLOAT``. ``R9G9B9E5_FLOAT`` is nine bits 357ec681f3Smrgeach of red green and blue mantissa, with a shared five bit exponent. 367ec681f3Smrg``R11G11B10_FLOAT`` is five bits of exponent and five or six bits of mantissa 377ec681f3Smrgfor each color channel. 387ec681f3Smrg 397ec681f3SmrgFor the ``NORM`` suffix, the signedness of each channel is indicated with an 407ec681f3SmrgS or U after the number of channel bits, as in ``R5SG5SB6U_NORM``. 417ec681f3Smrg 427ec681f3SmrgThe ``SRGB`` suffix is like ``UNORM`` in range, but in the sRGB colorspace. 437ec681f3Smrg 447ec681f3SmrgCompressed formats are named first by the compression format string (``DXT1``, 457ec681f3Smrg``ETC1``, etc), followed by a format-specific subtype. Refer to the 467ec681f3Smrgappropriate compression spec for details. 477ec681f3Smrg 487ec681f3SmrgFormats used in video playback are named by their FOURCC code. 497ec681f3Smrg 507ec681f3SmrgFormat names with an embedded underscore are subsampled. ``R8G8_B8G8`` is a 517ec681f3Smrgsingle 32-bit block of two pixels, where the R and B values are repeated in 527ec681f3Smrgboth pixels. 537ec681f3Smrg 547ec681f3SmrgIndex buffers do not have a natural format in Gallium structures. For purposes 557ec681f3Smrgof ``is_format_supported`` queries, the formats ``R8_UINT``, ``R16_UINT``, and 567ec681f3Smrg``R32_UINT`` are used with ``PIPE_BIND_INDEX_BUFFER`` for 8-bit, 16-bit, and 577ec681f3Smrg32-bit index buffers respectively. 587ec681f3Smrg 597ec681f3SmrgReferences 607ec681f3Smrg---------- 617ec681f3Smrg 627ec681f3SmrgDirectX Graphics Infrastructure documentation on DXGI_FORMAT enum: 637ec681f3Smrghttp://msdn.microsoft.com/en-us/library/windows/desktop/bb173059%28v=vs.85%29.aspx 647ec681f3Smrg 657ec681f3SmrgFOURCC codes for YUV formats: 667ec681f3Smrghttp://www.fourcc.org/yuv.php 67