Double buffering

From Wikipedia, the free encyclopedia

In computer graphics, double buffering (sometimes called ping-pong buffering) is a technique used to reduce or remove visible artifacts from the drawing process. It may be implemented in either software or hardware.

Computer monitors constantly redraw the visible video page (at around 60 times a second), and so it is difficult to make changes to the video page (such as creation or movement of complex objects onscreen) without the monitor showing the results before the graphics operation is complete. This results in ugly artifacts such as flickering, tearing and shearing.

A software implementation of double buffering uses a video page stored in system RAM that all drawing operations are written to. When a drawing operation is considered complete, the whole page, or a portion of it, is copied into the video RAM (VRAM) in one operation. This is generally synchronised so that copy operation is ahead of the monitor's raster beam so that ideally (if the copy is faster than the video beam) artifacts are avoided. This software method is not always flawless, and has a higher overhead than the hardware method.

The hardware method is also known as page flipping. In this method, two graphics pages in VRAM are used. At any one time, one page is actively being displayed by the monitor, while the other, background page is being drawn. When drawing is complete, the roles of the two pages are switched, so that the previously shown page is now being modified, and the previously drawn page is now being shown. The page-flip is typically accomplished by modifying the value of a pointer to the beginning of the display data in the video memory.

The hardware method guarantees artifacts will not be seen as long as the pages are switched over during the monitor's vertical blank period when no video data is being drawn. This method requires twice the amount of VRAM that is required for a single video page. The currently active and visible buffer is called the front buffer, while the background page is called the back buffer.

A variation of double buffering exists called triple buffering.

[edit] Database management system

In database management systems, double buffering is a technique used to exploit CPU resources during I/O operation (e.g. external sorting) by overlapping CPU and I/O processing. See Prefetching.

[edit] See also

In other languages