Performing Gamma Correction on Swap Chains

Applications can maintain back buffers of their swap chains in linear color space in order to perform blending operations correctly. Because the desktop is typically not in linear color space, gamma correction to the contents of back buffers is required before the contents can be presented on the desktop.

An application calls the IDirect3DSwapChain9::Present method to present the contents of the next back buffer in the swap chain. In this call, to indicate that the back-buffer contents are in linear color space, the application sets the D3DPRESENT_LINEAR_CONTENT flag. The DirectX 9.0 runtime, in turn, calls the display driver's DdBlt function with the DDBLT_EXTENDED_FLAGS and DDBLT_EXTENDED_LINEAR_CONTENT flags set. When the driver receives this DdBlt call, the driver determines that the source surface contains content in a linear color space. The driver can then perform gamma 2.2 correction (sRGB) on the linear color space as part of the blt. For more information about extended blit flags, see Extended Blt Flags.

The driver sets the D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION capability bit in the Caps3 member of the D3DCAPS9 structure to indicate that its device supports gamma 2.2 correction. The driver returns a D3DCAPS9 structure in response to a GetDriverInfo2 query similarly to how it returns a D3DCAPS8 structure as described in Reporting DirectX 8.0 Style Direct3D Capabilities. Support of this query is described in Supporting GetDriverInfo2.

For more information about IDirect3DSwapChainXxx::Present, see the latest DirectX SDK documentation.