Platform SDK: DirectX |
Applications can increase performance when using z-buffering and texturing by ensuring that scenes are rendered from front to back. Textured z-buffered primitives are pretested against the z-buffer on a scan line basis. If a scan line is hidden by a previously rendered polygon, the system rejects it quickly and efficiently. Z-buffering can improve performance, but the technique is most useful when a scene includes a great deal of overdraw. Overdraw is the average number of times a screen pixel is written to. Overdraw is difficult to calculate exactly, but you can often make a close approximation. If the overdraw averages less than 2, you can achieve the best performance by turning z-buffering off, and rendering the scene from back-to-front.
You can also improve the performance of your application by performing visibility testing before rendering. Direct3D Immediate Mode offers the IDirect3DDevice7::ComputeSphereVisibility method for this purpose. The ComputeSphereVisibility method provides information about the visibility of a given set of polygons. If the method reports that the geometry isn't visible, you can avoid even rendering the object.
You can also improve the performance of your application by performing visibility testing before rendering. Direct3D Immediate Mode offers the Direct3DDevice7.ComputeSphereVisibility method for this purpose. The ComputeSphereVisibility method provides information about the visibility of a given set of polygons. If the method reports that the geometry isn't visible, you can avoid even rendering the object.
On faster personal computers, software rendering to system memory is often faster than rendering to video memory, although it has the disadvantage of not being able to use double buffering or hardware-accelerated clear operations. If your application can render to either system or video memory, and if you include a routine that tests which is faster, you can take advantage of the best approach on the current system. The Direct3D sample code in this SDK demonstrates this strategy. It is necessary to implement both methods because there is no other way to test the speed. Speeds can vary enormously from computer to computer, depending on the main-memory architecture and the type of graphics adapter being used.