RGBZ Support

DirectDraw supports the RGBZ pixel format. In RGBZ, bits that do not store colors store depth information; instead of being stored in a separate z-buffer, depth information is stored with each pixel.

The RGBZ format is particularly useful for applications that rely on emulating 3-D capabilities in software. Complicated 3-D scenes typically use many small triangles. When z-information is kept in a separate buffer, applications must access random memory locations repeatedly for each line of a triangle; once to check the z-buffer, again to write the new color value (if necessary), and again for the same area (in the common case of overlapping triangles). Applications using RGBZ pixels can perform one memory access for an entire line in a triangle, and there is no additional overhead if the hardware can drop the z-information automatically.

DirectDraw supports copying to an RGBZ surface and clearing it, but it does not contain any methods that directly exploit the depth information.

DirectDraw can copy from a source surface to a destination surface only when the surfaces have exactly the same pixel format. DirectDraw does not emulate copying from an RGBZ surface to an RGB surface.

Some hardware can copy from RGBZ surfaces to RGB surfaces. A useful feature in such copy operations is the ability to drop the z-information automatically. Drivers use the dwSVBCaps2 member of the DDCAPS structure to specify that they can perform RGBZ to RGB conversions. (The dwSVBCaps member specifies other capabilities of system- to video-memory blits.)

Most implementations of RGBZ pixel formats support dropping the z-information on blits from system-to video memory, not on blits from video-to-video memory. Blits from system- to video-memory can often be performed asynchronously, leaving more processor time for rendering or logic. In addition, access to z-buffers is read-write intensive and therefore usually occurs in system memory. Applications that sometimes run out of space in video memory (for example, applications that use many textures) will find system- to video-memory blits useful.

Applications can use the dwFillPixel member of the DDBLTFX structure to apply color fills to RGBZ surfaces. (You cannot fill only the color or only the z-portions of an RGBZ surface¾you must set both. The dwFillPixel member does this for you.)