Category: 

What Is a Swap Chain?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 20 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
In late 19th-century London, mail was delivered to residential addresses up to twelve times each day.   more...

September 28 ,  1924 :  Two US military planes complete the first flights around the world.  more...

A swap chain is a series of framebuffers, or locations in computer memory, that are used to render an image before it is displayed on an actual monitor or other device. There are always at least two framebuffers in a swap chain because the first, or active, buffer is usually identified as the one currently being shown on the display. While one framebuffer is being displayed, the next buffer can be rendered and prepared for display and then swapped to the device as necessary. Using a swap chain can eliminate some of the problems that occur because of conflicts between hardware and software timing, as well as graphical artifacts that can appear because of rendering directly to the display device.

The way an image is shown on a monitor is really just a matter of placing the correct sequence of numbers into a specified area of memory. Whatever is in this area of memory is drawn on the screen several times every second. A screen is drawn in horizontal lines from the top left corner to the bottom right corner. The moment when the screen is starting the next frame, when it moves from the bottom right corner of the screen to the upper left corner, is known as the vertical retrace.

Ad

Implementations of a swap buffer only draw to the screen during the vertical retrace. If this timing is off, or if a program attempts to draw to a screen during periods when a frame is being rendered, then a graphical anomaly known as a tear can appear. This occurs when the image in the display device’s memory is suddenly changed in the middle of rendering, causing one side of the display to show the last frame, and the rest of the screen to show the new one.

By rendering a scene ahead of time into a framebuffer, the next frame to be displayed is already prepared and can be quickly pushed into the display memory so it is shown. While one image is displayed, the next is being drawn in the inactive framebuffer, also called a back buffer. This creates smooth animations and visual effects that can be exactly timed to prevent tearing.

The term "swap chain" is more commonly known as double buffering or triple buffering, depending on the number of frames being drawn in advance of the active framebuffer. Using nanosecond or millisecond timing algorithms is an essential part of using a swap chain to ensure that the maximum frame rate of the monitor not exceeded and that programs can pace their own processing and resources on a system. Employing a swap chain, if properly implemented, can result in smooth animations regardless of the properties of a display device or the amount of time it takes to render a single frame of animation.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

exception 'Exception' with message 'error writing captcha: Duplicate entry '2147483647' for key 'PRIMARY'' in /ssd/www/wisegeek/public_html/_core/classes/public/Captcha.php:44
Stack trace:
#0 /ssd/www/wisegeek/public_html/_core/controls/public/ControlDiscussionPostBox.php(324): Captcha->createCaptcha()
#1 /ssd/www/wisegeek/public_html/framework/classes/Control.php(104): ControlDiscussionPostBox->preRender(false)
#2 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): Control->render()
#3 /ssd/www/wisegeek/public_html/tpl/default-nocustom-lu/pages/public/article/article.htm(526): Control->__toString()
#4 /ssd/www/wisegeek/public_html/framework/classes/Control.php(300): require('/ssd/www/wisege...')
#5 /ssd/www/wisegeek/public_html/framework/classes/Control.php(309): Control->requireTpl('pages/public/ar...', Object(PageArticleCom), true)
#6 /ssd/www/wisegeek/public_html/framework/classes/Control.php(131): Control->renderTpl('pages/public/ar...', Object(PageArticleCom))
#7 /ssd/www/wisegeek/public_html/framework/classes/FormDataControl.php(87): Control->renderTemplate()
#8 /ssd/www/wisegeek/public_html/framework/classes/Control.php(109): FormDataControl->renderTemplate()
#9 /ssd/www/wisegeek/public_html/framework/classes/ScriptPage.php(50): Control->render(false)
#10 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): ScriptPage->render()
#11 /ssd/www/wisegeek/public_html/framework/classes/Page.php(97): Control->__toString()
#12 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(443): Page->processRequest()
#13 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(7): PublicFrontController->renderPage()
#14 /ssd/www/wisegeek/public_html/index.php(11): PublicFrontController::run()
#15 {main}