HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, multiple buffering is the use of more than one
buffer Buffer may refer to: Science * Buffer gas, an inert or nonflammable gas * Buffer solution, a solution used to prevent changes in pH * Lysis buffer, in cell biology * Metal ion buffer * Mineral redox buffer, in geology Technology and engineeri ...
to hold a block of
data Data ( , ) are a collection of discrete or continuous values that convey information, describing the quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted for ...
, so that a " reader" will see a complete (though perhaps old) version of the data instead of a partially updated version of the data being created by a "
writer A writer is a person who uses written words in different writing styles, genres and techniques to communicate ideas, to inspire feelings and emotions, or to entertain. Writers may develop different forms of writing such as novels, short sto ...
". It is very commonly used for computer display images. It is also used to avoid the need to use
dual-ported RAM Dual-ported RAM (DPRAM), also called dual-port RAM, is a type of random-access memory (RAM) that can be accessed via two different buses. A simple dual-port RAM may allow only read access through one of the ports and write access through the o ...
(DPRAM) when the readers and writers are different devices.


Description


Double buffering Petri net

The
Petri net A Petri net, also known as a place/transition net (PT net), is one of several mathematical modeling languages for the description of distributed systems. It is a class of discrete event dynamic system. A Petri net is a directed bipartite graph t ...
in the illustration shows double buffering. Transitions W1 and W2 represent writing to buffer 1 and 2 respectively while R1 and R2 represent reading from buffer 1 and 2 respectively. At the beginning, only the transition W1 is enabled. After W1 fires, R1 and W2 are both enabled and can proceed in parallel. When they finish, R2 and W1 proceed in parallel and so on. After the initial transient where W1 fires alone, this system is periodic and the transitions are enabled – always in pairs (R1 with W2 and R2 with W1 respectively).


Double buffering in computer graphics

In
computer graphics Computer graphics deals with generating images and art with the aid of computers. Computer graphics is a core technology in digital photography, film, video games, digital art, cell phone and computer displays, and many specialized applications. ...
, double buffering is a technique for drawing graphics that shows less stutter,
tearing Tearing is the act of breaking apart a material by force, without the aid of a cutting tool. A tear in a piece of paper, fabric, or some other similar object may be the result of the intentional effort with one's bare hands, or be accidental. ...
, and other artifacts. It is difficult for a program to draw a display so that pixels do not change more than once. For instance, when updating a page of text, it is much easier to clear the entire page and then draw the letters than to somehow erase only the pixels that are used in old letters but not in new ones. However, this intermediate image is seen by the user as flickering. In addition,
computer monitor A computer monitor is an output device that displays information in pictorial or textual form. A discrete monitor comprises a electronic visual display, visual display, support electronics, power supply, Housing (engineering), housing, electri ...
s constantly redraw the visible video page (traditionally at around 60 times a second), so even a perfect update may be visible momentarily as a horizontal divider between the "new" image and the un-redrawn "old" image, known as
tearing Tearing is the act of breaking apart a material by force, without the aid of a cutting tool. A tear in a piece of paper, fabric, or some other similar object may be the result of the intentional effort with one's bare hands, or be accidental. ...
.


Software double buffering

A software implementation of double buffering has all drawing operations store their results in some region of system
RAM Ram, ram, or RAM most commonly refers to: * A male sheep * Random-access memory, computer memory * Ram Trucks, US, since 2009 ** List of vehicles named Dodge Ram, trucks and vans ** Ram Pickup, produced by Ram Trucks Ram, ram, or RAM may also ref ...
; any such region is often called a "back buffer". When all drawing operations are considered complete, the whole region (or only the changed portion) is copied into the
video RAM Video random-access memory (VRAM) is dedicated computer memory used to store the pixels and other graphics data as a framebuffer to be rendered on a computer monitor. It often uses a different technology than other computer memory, in order to b ...
(the "front buffer"); this copying is usually synchronized with the monitor's
raster file:Rgb-raster-image.svg, upright=1, The Smiley, smiley face in the top left corner is a raster image. When enlarged, individual pixels appear as squares. Enlarging further, each pixel can be analyzed, with their colors constructed through comb ...
beam in order to avoid tearing. Software implementations of double buffering necessarily require more memory and CPU time than single buffering because of the system memory allocated for the back buffer, the time for the copy operation, and the time waiting for synchronization.
Compositing window manager A compositing manager, or compositor, is software that provides applications with an off-screen data buffer, buffer for each window, then Compositing, composites these window buffers into an image representing the screen and writes the result into ...
s often combine the "copying" operation with "
compositing Compositing is the process or technique of combining visual elements from separate sources into single images, often to create the illusion that all those elements are parts of the same scene. Live action, Live-action shooting for compositing ...
" used to position windows, transform them with scale or warping effects, and make portions transparent. Thus, the "front buffer" may contain only the composite image seen on the screen, while there is a different "back buffer" for every window containing the non-composited image of the entire window contents.


Page flipping

In the page-flip method, instead of copying the data, both buffers are capable of being displayed. At any one time, one buffer is actively being displayed by the monitor, while the other, background buffer is being drawn. When the background buffer is complete, the roles of the two are switched. The page-flip is typically accomplished by modifying a
hardware register In digital electronics, especially computing, hardware registers are circuits typically composed of flip-flops, often with many characteristics similar to memory, such as: * Using an memory or port address to select a particular register in a ma ...
in the
video display controller A video display controller (VDC), also called a display engine or display interface, is an integrated circuit which is the main component in a video-signal generator, a device responsible for the production of a TV video signal in a computing ...
—the value of a pointer to the beginning of the display data in the video memory. The page-flip is much faster than copying the data and can guarantee that tearing will not be seen as long as the pages are switched over during the monitor's
vertical blanking interval In a raster scan display, the vertical blanking interval (VBI), also known as the vertical interval or VBLANK, is the time between the end of the final visible line of a frame or field and the beginning of the first visible line of the next fra ...
—the blank period when no video data is being drawn. The currently active and visible buffer is called the front buffer, while the background page is called the back buffer.


Triple buffering

In
computer graphics Computer graphics deals with generating images and art with the aid of computers. Computer graphics is a core technology in digital photography, film, video games, digital art, cell phone and computer displays, and many specialized applications. ...
, triple buffering is similar to double buffering but can provide improved performance. In double buffering, the program must wait until the finished drawing is copied or swapped before starting the next drawing. This waiting period could be several
milliseconds A millisecond (from '' milli-'' and second; symbol: ms) is a unit of time in the International System of Units equal to one thousandth (0.001 or 10−3 or 1/1000) of a second or 1000 microseconds. A millisecond is to one second, as one second i ...
during which neither buffer can be touched. In triple buffering, the program has two back buffers and can immediately start drawing in the one that is not involved in such copying. The third buffer, the front buffer, is read by the graphics card to display the image on the monitor. Once the image has been sent to the monitor, the front buffer is flipped with (or copied from) the back buffer holding the most recent complete image. Since one of the back buffers is always complete, the graphics card never has to wait for the software to complete. Consequently, the software and the graphics card are completely independent and can run at their own pace. Finally, the displayed image was started without waiting for synchronization and thus with minimum lag. Due to the software
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
not
polling Poll, polled, or polling may refer to: Forms of voting and counting * Poll, a formal election ** Election verification exit poll, a survey taken to verify election counts ** Polling, voting to make decisions or determine opinions ** Polling pla ...
the graphics hardware for monitor refresh events, the algorithm may continuously draw additional frames as fast as the hardware can render them. For frames that are completed much faster than interval between refreshes, it is possible to replace a back buffers' frames with newer iterations multiple times before copying. This means frames may be written to the back buffer that are never used at all before being overwritten by successive frames. Nvidia has implemented this method under the name "Fast Sync". An alternative method sometimes referred to as triple buffering is a
swap chain In computer graphics, a swap chain (also swapchain) is a series of virtual framebuffers used by the graphics card and graphics API for frame rate stabilization, stutter reduction, and several other purposes. Because of these benefits, many graphic ...
three buffers long. After the program has drawn both back buffers, it waits until the first one is placed on the screen, before drawing another back buffer (i.e. it is a 3-long first in, first out queue). Most Windows games seem to refer to this method when enabling triple buffering.


Quad buffering

The term quad buffering is the use of double buffering for each of the left and right eye images in
stereoscopic Stereoscopy, also called stereoscopics or stereo imaging, is a technique for creating or enhancing the illusion of depth in an image by means of stereopsis for binocular vision. The word ''stereoscopy'' derives . Any stereoscopic image is ...
implementations, thus four buffers total (if triple buffering was used then there would be ''six'' buffers). The command to swap or copy the buffer typically applies to both pairs at once, so at no time does one eye see an older image than the other eye. Quad buffering requires special support in the graphics card drivers which is disabled for most consumer cards. AMD's Radeon HD 6000 Series and newer support it. 3D standards like
OpenGL OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
and
Direct3D Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
support quad buffering.


Double buffering for DMA

The term double buffering is used for copying data between two buffers for
direct memory access Direct memory access (DMA) is a feature of computer systems that allows certain hardware subsystems to access main system computer memory, memory independently of the central processing unit (CPU). Without DMA, when the CPU is using programmed i ...
(DMA) transfers, not for enhancing performance, but to meet specific addressing requirements of a device (esp. 32-bit devices on systems with wider addressing provided via
Physical Address Extension In computing, Physical Address Extension (PAE), sometimes referred to as Page Address Extension, is a memory management feature for the x86 architecture. PAE was first introduced by Intel in the Pentium Pro, and later by AMD in the Athlon process ...
).
DOS DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
and
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
device drivers In the context of an operating system, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabli ...
are a place where the term "double buffering" is likely to be used. Linux and BSD source code calls these "bounce buffers". Some programmers try to avoid this kind of double buffering with
zero-copy In computer science, zero-copy refers to techniques that enable data transfer between memory spaces without requiring the CPU to copy the data. By avoiding redundant copying, zero-copy methods minimize CPU usage and memory bandwidth, leading ...
techniques.


Other uses

Double buffering is also used as a technique to facilitate interlacing or
deinterlacing Deinterlacing is the process of converting interlaced video into a non-interlaced or Progressive scan, progressive form. Interlaced video signals are commonly found in analog television, VHS, Laserdisc, digital television (HDTV) when in the 1080 ...
of video signals.


See also

* Adaptive tile refresh *
Vertical synchronization Vertical synchronization or Vsync can refer to: * Analog television#Vertical synchronization, a process in which a pulse signal separates analog video fields * Screen tearing#Vertical synchronization, a process in which digital graphics rendering ...
*
Stereoscopy Stereoscopy, also called stereoscopics or stereo imaging, is a technique for creating or enhancing the depth perception, illusion of depth in an image by means of stereopsis for binocular vision. The word ''stereoscopy'' derives . Any ster ...
*
LC shutter glasses An active shutter 3D system (a.k.a. alternate frame sequencing, alternate image, AI, alternating field, field sequential or eclipse method) is a technique for displaying stereoscopic 3D images. It works by only presenting the image intended for ...
*
Nvidia 3D Vision Nvidia 3D Vision (previously ''GeForce 3D Vision'') is a discontinued stereoscopy, stereoscopic gaming kit from Nvidia which consists of LC shutter glasses and Device driver, driver software which enables stereoscopic vision for any Direct3D game, ...
* HD3D * Virtual DMA Services (VDS)


References


External links

*
Triple buffering: improve your PC gaming performance for free
' by Mike Doolittle (2007-05-24)

{{Webarchive, url=https://web.archive.org/web/20160818200909/http://www.tweakguides.com/Graphics_10.html , date=2016-08-18 Computer graphics algorithms Image processing Petri nets