Swap chain
![]() | This article may be too technical for most readers to understand. |
In computer graphics, a swap chain is a series of framebuffers utilized by the graphics card or graphics API in both immediate mode and retained mode graphics processing environments for frame rate stabilization and several other functions. The swap chain usually exists in graphics memory, but it can exist in system memory as well. The non-utilization of a swap chain will result in 'choppy' rendering, but its existence and utilization are required by many graphics APIs.
Function

In every swap chain there are at least two buffers. The first framebuffer, the screenbuffer, is the buffer that is rendered to the output of the video card. Each time a new frame is displayed, the first back buffer in the swap chain takes the place of the screenbuffer, this is called 'presentation' or 'swapping'. A variety of other actions may be taken on the previous screenbuffer and other backbuffers (if they exist). The screenbuffer may be simply overwritten or returned to the back of the swap chain for further processing. The action taken is decided by the client application and is API dependent.
Direct3D
Microsoft Direct3D implements a 'SwapChain' class. Each host device has at least one swap chain assigned to it, and others may be created by the client application.[1] The API provides three methods of swapping: 'copy', 'discard', and 'flip'. When the SwapChain is set to 'flip', the screenbuffer is copied onto the last backbuffer, then all the existing backbuffers are copied forward in the chain. When 'copy' is set, each backbuffer is copied forward, but the screenbuffer is not wrapped to the last buffer, leaving it unchanged. 'Flip' does not work when there is only one backbuffer, as the screenbuffer is copied over the only backbuffer before it can be presented. In 'discard' mode, the driver selects the best method.[2]
Notes
- ^ "SwapChain Class". Microsoft. Retrieved 30 October 2009.
- ^ "Swap Chains". neXe. Retrieved 30 October 2009.