Querying for Depth Buffer Support

As with any feature, don't assume that the driver your application uses supports depth buffering; you should always check the driver's capabilities. Although most driver support z-based depth buffering, not all will be able to provide support to w-based depth buffering. (For general information about depth buffering, see What Are Depth Buffers?) Drivers do not fail if you attempt to enable an unsupported scheme, falling-back on another depth buffering method instead, or sometimes disabling depth buffering altogether, which can result in rendered scenes that show major depth sorting artifacts.

You can check for general support for depth buffers by querying the DirectDraw for the display device your application uses before you create a Direct3D device. If the DirectDraw object reports that it supports depth buffering, any hardware devices you create from this DirectDraw object will support z-buffering (but you don't yet know if the driver supports w-buffering).

To query for general depth buffering support

  1. Call the IDirectDraw4::GetCaps method of the DirectDraw object for the display device your application uses, passing initialized DDCAPS structures as parameters. After the call, the DDCAPS structures contain information about DirectDraw's hardware and emulation capabilities.
  2. Examine the ddsCaps member of the structure you passed as the first parameter. If this member–a DDSCAPS2 structure–includes the DDSCAPS_ZBUFFER flag, the driver supports depth buffering through z-buffers.

Once you know that the driver supports z-buffers, you can verify w-buffer support. Although z-buffers are supported for all software rasterizers, w-buffers are only supported by the reference rasterizer, which is hardly suited for use by real-world applications. No matter what type of device your application uses, you should verify support for w-buffers before you attempt to enable w-based depth buffering.

To determine support for w-buffers

  1. After creating your device (HAL or emulated), call the IDirect3DDevice3::GetCaps method, passing initialized D3DDEVICEDESC structures in both parameters.
  2. After the call, the dpcTriCaps and dpcLineCaps members (D3DPRIMCAPS structures) contain information about the driver's support for rendering primitives.
  3. If the dwRasterCaps member of these structures contains the D3DPRASTERCAPS_WBUFFER flag, then the driver supports w-based depth buffering for that primitive type.