Triple buffering
From Wikipedia, the free encyclopedia
In computer graphics, triple buffering is a variant on double buffering, a technique for drawing graphics that shows no (or less) flicker, shearing, and tearing artifacts.
Triple buffering attempts to provide a speed improvement over double buffering. In real life applications, this often involves trying to abstract the graphics drawing operations from being synchronized with the monitor's refresh rate. Typically this involves frames being drawn at a rate lower than or higher than the monitor's frame rate (a variable frame rate) without the usual effects this would cause (namely flickering, shearing and tearing).
Due to the software algorithm not having to poll the graphics hardware for monitor refresh events, the algorithm is free to run as fast as possible. This is not the only method of triple buffering available, but is the most prevalent on the PC architecture where the speed of the target machine is highly variable.
Another method of triple buffering involves synchronizing with the monitor frame rate, and simply using the third buffer as a method of providing breathing room for changing demands in the amount of graphics drawn. This is the use of a buffer in the true sense whereby the buffer acts as a reservoir. Such a method requires a higher minimum specification of the target hardware but provides a consistent (vs. variable) frame rate.
Triple buffering implies three buffers, but the method can be extended to as many buffers as is practical for the application. Usually, there is no advantage to using more than three buffers.
Contents |
[edit] Limitations of double buffering
If the system has two color buffers A and B, it can display buffer B while drawing a new picture (rendering) into buffer A. When it is done rendering into buffer A, the system needs to wait until buffer B is in the monitor's vertical blank period before swapping buffers. This waiting period could be several milliseconds during which neither buffer can be touched. At 60 frames per second, there are only 16.67 milliseconds in which to draw the frame, so this delay could waste valuable frame time. When the monitor is in vertical blank it can either swap buffers A and B and then start rendering into buffer B (page flipping) or copy buffer A into buffer B and render into buffer A.
[edit] Advantage of triple buffering
If the system has three color buffers A, B and C, it does not have to wait to swap buffers. It can display buffer B while rendering into buffer A. When done rendering into buffer A, it can start rendering into buffer C immediately. When the monitor is in vertical blank, it can display buffer A and make buffer B available for reuse.
Also, on systems like Amigas, you could paint using the CPU in parallel with the blitter doing a cleanup of a previous buffer, meaning that you could show buffer A, while cleaning buffer B and paint graphics on buffer C. If you only used two buffers, you would have to make sure the cleaning was completely done before starting the drawing on the unused buffer, which would waste some time.
[edit] Limitations of triple buffering
If the system always renders buffers in less time than it takes to display a buffer once on the monitor, the computer will wait for the monitor regardless of how many buffers there are. In this particular case triple buffering has no advantage over double buffering. The third buffer also uses additional memory, which could be used for other data (like textures). Thirdly, if the system is interactive (for example, a simulator or a video game), triple buffering increases the average delay between the input controls being read and visual feedback being presented to the user.
[edit] See also
[edit] External links
- Triple buffering: improve your PC gaming performance for free by Mike Doolittle (2007-05-24)