?/TD>
Microsoft DirectX 9.0

D3DFORMAT


Defines the various types of surface formats.

Syntax

typedef enum _D3DFORMAT {

... (values)

} D3DFORMAT;

There are several types of formats.

All formats are listed from left to right, most significant bit (MSB) to least significant bit (LSB). For example, D3DFORMAT_ARGB is ordered from the MSB channel A (alpha), to the LSB channel B (blue). When traversing surface data, the data is stored in memory from LSB to MSB, which means that the channel order in memory is from LSB (blue) to MSB (alpha).

The default value for formats that contain undefined channels (G16R16, A8 etc.) is 1. The only exception is the A8 format, which is initialized to 000 for the three color channels.

Unsigned Formats

These constants refer to opcodes for texture address instructions for pixel shaders.

Data in an unsigned format must be positive. Unsigned formats use combinations of (R)ed, (G)reen, (B)lue, (A)lpha, (L)uminance, and (P)alette data. Palette data is also referred to as color indexed data because the data is used to index a color palette.

Unsigned format flagsValueFormat
D3DFMT_R8G8B82024-bit RGB pixel format with 8 bits per channel.
D3DFMT_A8R8G8B82132-bit ARGB pixel format with alpha, using 8 bits per channel.
D3DFMT_X8R8G8B82232-bit RGB pixel format, where 8 bits are reserved for each color.
D3DFMT_R5G6B52316-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
D3DFMT_X1R5G5B52416-bit pixel format where 5 bits are reserved for each color.
D3DFMT_A1R5G5B52516-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
D3DFMT_A4R4G4B42616-bit ARGB pixel format with 4 bits for each channel.
D3DFMT_R3G3B2278-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
D3DFMT_A8288-bit alpha only.
D3DFMT_A8R3G3B22916-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
D3DFMT_X4R4G4B43016-bit RGB pixel format using 4 bits for each color.
D3DFMT_A2B10G10R103132-bit pixel format using 10 bits for each color and 2 bits for alpha.
D3DFMT_A8B8G8R83232-bit ARGB pixel format with alpha, using 8 bits per channel.
D3DFMT_X8B8G8R83332-bit RGB pixel format, where 8 bits are reserved for each color.
D3DFMT_G16R163432-bit pixel format using 16 bits each for green and red.
D3DFMT_A2R10G10B103532-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
D3DFMT_A16B16G16R163664-bit pixel format using 16 bits for each component.
D3DFMT_A8P8408-bit color indexed with 8 bits of alpha.
D3DFMT_P8418-bit color indexed.
D3DFMT_L8508-bit luminance only.
D3DFMT_L168116-bit luminance only.
D3DFMT_A8L85116-bit using 8 bits each for alpha and luminance.
D3DFMT_A4L4528-bit using 4 bits each for alpha and luminance.

Signed Formats

Data in a signed format can be both positive and negative. Signed formats use combinations of (U), (V), (W), and (Q) data.

Signed format flagsValueFormat
D3DFMT_V8U86016-bit bump-map format using 8 bits each for u and v data.
D3DFMT_Q8W8V8U86332-bit bump-map format using 8 bits for each channel.
D3DFMT_V16U166432-bit bump-map format using 16 bits for each channel.
D3DFMT_Q16W16V16U1611064-bit bump-map format using 16 bits for each component.
D3DFMT_CxV8U811716-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 - U2 - V2).

Mixed Formats

Data in mixed formats can contain a combination of unsigned data and signed data.

Mixed format flagsValueFormat
D3DFMT_L6V5U56116-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
D3DFMT_X8L8V8U86232-bit bump-map format with luminance using 8 bits for each channel.
D3DFMT_A2W10V10U106732-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.

FOURCC Formats

Data in a four-character code (FOURCC) format is compressed data.

MAKEFOURCC

A macro for generating four-character codes follows:

#define MAKEFOURCC(ch0, ch1, ch2, ch3)                              \
                ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) |   \
                ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))

Here are the defined FOURCC formats.

FOURCC flagsValueFormat
D3DFMT_MULTI2_ARGB8MAKEFOURCC('M','E','T','1')MultiElement texture (not compressed)
D3DFMT_G8R8_G8B8MAKEFOURCC('G', 'R', 'G', 'B')A 16-bit packed RGB format analogous to YUY2 (Y0U0, Y1V0, Y2U2, etc.). It requires a pixel pair in order to properly represent the color value. The first pixel in the pair contains 8 bits of green (in the high 8 bits) and 8 bits of red (in the low 8 bits). The second pixel contains 8 bits of green (in the high 8 bits) and 8 bits of blue (in the low 8 bits). Together, the two pixels share the red and blue components, while each has a unique green component (G0R0, G1B0, G2R2, etc.). The texture sampler does not normalize the colors when looking up into a pixel shader; they remain in the range of 0.0f to 255.0f. This is true for all programmable pixel shader models. For the fixed function pixel shader, the hardware should normalize to the 0.f to 1.f range and essentially treat it as the YUY2 texture. Hardware that exposes this format must have the PixelShader1xMaxValue member of D3DCAPS9 set to a value capable of handling that range.
D3DFMT_R8G8_B8G8MAKEFOURCC('R', 'G', 'B', 'G')A 16-bit packed RGB format analogous to UYVY (U0Y0, V0Y1, U2Y2, etc.). It requires a pixel pair in order to properly represent the color value. The first pixel in the pair contains 8 bits of green (in the low 8 bits) and 8 bits of red (in the high 8 bits). The second pixel contains 8 bits of green (in the low 8 bits) and 8 bits of blue (in the high 8 bits). Together, the two pixels share the red and blue components, while each has a unique green component (R0G0, B0G1, R2G2, etc.). The texture sampler does not normalize the colors when looking up into a pixel shader; they remain in the range of 0.0f to 255.0f. This is true for all programmable pixel shader models. For the fixed function pixel shader, the hardware should normalize to the 0.f to 1.f range and essentially treat it as the YUY2 texture. Hardware that exposes this format must have PixelShader1xMaxValue member of D3DCAPS9 set to a value capable of handling that range.
D3DFMT_DXT1MAKEFOURCC('D', 'X', 'T', '1')DXT1 compression texture format
D3DFMT_DXT2MAKEFOURCC('D', 'X', 'T', '2')DXT2 compression texture format
D3DFMT_DXT3MAKEFOURCC('D', 'X', 'T', '3')DXT3 compression texture format
D3DFMT_DXT4MAKEFOURCC('D', 'X', 'T', '4')DXT4 compression texture format
D3DFMT_DXT5MAKEFOURCC('D', 'X', 'T', '5')DXT5 compression texture format
D3DFMT_UYVYMAKEFOURCC('U', 'Y', 'V', 'Y')UYVY format (PC98 compliance)
D3DFMT_YUY2MAKEFOURCC('Y', 'U', 'Y', '2')YUY2 format (PC98 compliance)

Buffer Formats

Depth, stencil, vertex, and index buffers each have unique formats.

Buffer flagsValueFormat
D3DFMT_D16_LOCKABLE7016-bit z-buffer bit depth.
D3DFMT_D327132-bit z-buffer bit depth.
D3DFMT_D15S17316-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
D3DFMT_D24S87532-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
D3DFMT_D24X87732-bit z-buffer bit depth using 24 bits for the depth channel.
D3DFMT_D24X4S47932-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
D3DFMT_D32F_LOCKABLE82A lockable format where the depth value is represented as a standard IEEE floating-point number.
D3DFMT_D24FS883A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
D3DFMT_D168016-bit z-buffer bit depth.
D3DFMT_VERTEXDATA100Describes a vertex buffer surface.
D3DFMT_INDEX1610116-bit index buffer bit depth.
D3DFMT_INDEX3210232-bit index buffer bit depth.

All depth-stencil formats except D3DFMT_D16_LOCKABLE indicate no particular bit ordering per pixel, and the driver is allowed to consume more than the indicated number of bits-per-depth channel (but not stencil channel).

Floating-Point Formats

These flags are used for floating-point surface formats. These 16-bits-per-channel formats are also known as s10e5 formats.

Floating-point flagsValueFormat
D3DFMT_R16F11116-bit float format using 16 bits for the red channel.
D3DFMT_G16R16F11232-bit float format using 16 bits for the red channel and 16 bits for the green channel.
D3DFMT_A16B16G16R16F11364-bit float format using 16 bits for the each channel (alpha, blue, green, red).

IEEE Formats

These flags are used for floating-point surface formats. These 32-bits-per-channel formats are also known as s23e8 formats.

Floating-point flagsValueFormat
D3DFMT_R32F11432-bit float format using 32 bits for the red channel.
D3DFMT_G32R32F11564-bit float format using 32 bits for the red channel and 32 bits for the green channel.
D3DFMT_A32B32G32R32F116128-bit float format using 32 bits for the each channel (alpha, blue, green, red).

Other

This only other flag used is for undefined formats.

Other flagsValueFormat
D3DFMT_UNKNOWN0Surface format is unknown

BackBuffer or Display Formats

These formats are the only valid formats for a back buffer or a display.

FormatBack bufferDisplay
A2R10G10B10xx (full-screen mode only)
A8R8G8B8x
X8R8G8B8xx
A1R5G5B5x
X1R5G5B5xx
R5G6B5xx

Remarks

The order of the bits are from the most significant byte first, so D3DFMT_A8L8 indicates that the high byte of this 2-byte format is alpha. D3DFMT_D16 indicates a 16-bit integer value and an application-lockable surface.

Pixel formats have been chosen to enable the expression of hardware-vendor-defined extension formats, as well as to include the well-established FOURCC method. The set of formats understood by the Microsoft?Direct3D?runtime is defined by D3DFORMAT.

Note that formats are supplied by independent hardware vendors (IHVs) and many FOURCC codes are not listed. The formats in this enumeration are unique in that they are sanctioned by the runtime, meaning that the reference rasterizer will operate on all these types. IHV-supplied formats will be supported by the individual IHVs on a card-by-card basis.

Related Topics



© 2002 Microsoft Corporation. All rights reserved.