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 drivers 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 don't 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 scenes rendered with extreme 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).
[C++]
To query for general depth buffering support from C++
Call the IDirectDraw7::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 hardware and emulation capabilities of DirectDraw.
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.
[Visual Basic]
To query for general depth buffering support in Visual Basic
Call the DirectDraw7.GetCaps method of the DirectDraw object for the display device your application uses, passing variables of type DDCAPS as parameters. After the call, the DDCAPS variables contain information about hardware and emulation capabilities of DirectDraw.
Examine the ddsCaps member of the variable you passed as the first parameter. If this member–a DDSCAPS2 type–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.
[C++]
To determine support for w-buffers in a C++ application
After the call, the dpcTriCaps and dpcLineCaps members (D3DPRIMCAPS structures) contain information about the driver's support for rendering primitives.
If the dwRasterCaps member of these structures contains the D3DPRASTERCAPS_WBUFFER flag, then the driver supports w-based depth buffering for that primitive type.
[Visual Basic]
To determine support for w-buffers in Visual Basic
After creating your device (HAL or emulated), call the Direct3DDevice7.GetCaps method, passing a variable of type D3DDEVICEDESC7 type as a parameter.
After the call, the dpcTriCaps and dpcLineCaps members (D3DPRIMCAPS types) each contain information about the driver's support for rendering primitives.
If the lRasterCaps members of dpcTriCaps and dpcLineCaps contain the D3DPRASTERCAPS_WBUFFER flag, the driver supports w-based depth buffering for that primitive type.