Marking Formats for Gamma and Linear Conversion

A DirectX 9.0 version driver marks texture formats for linear or gamma conversion so that it can determine whether to convert textures of those formats in order to accurately process or render them.

Texture content is typically stored in sRGB format, which is gamma corrected. However, for the pixel pipeline to perform accurate blending operations on sRGB-formatted textures, the driver must convert those textures to a linear format before reading from them. When the pixel pipeline is ready to write those textures out to the render target, the driver must convert those textures back to sRGB format. In this way, the pixel pipeline performs all operations in linear space.

The driver specifies the following flags in the dwOperations member of the DDPIXELFORMAT structure for a texture surface's format to mark the format for conversion:

  • D3DFORMAT_OP_SRGBREAD to indicate whether a texture is gamma 2.2 corrected or not (sRGB or not), and if it must be converted to a linear format by the driver either for blending operations or for the sampler at lookup time.

  • D3DFORMAT_OP_SRGBWRITE to indicate whether the pixel pipeline should gamma correct back to sRGB space when writing out to the render target.