The IDXGISwapChain interface represents a swap chain, which is a collection of buffers that are used to display rendered frames on the screen. The swap chain manages the presentation of rendered images by allowing applications to specify how and when to present them.
The IDXGISwapChain interface inherits from IDXGISurface1.
The IDXGISwapChain interface includes the following methods:
| Method | Description |
|---|---|
GetBuffer |
Retrieves a back buffer. |
GetDesc |
Gets a description of the swap chain. |
GetFrameStatistics |
Gets frame statistics. |
GetLastPresentCount |
Gets the count of present operations. |
Present |
Presents the next frame of the swap chain to the user. |
ResizeBuffers |
Resizes the back buffers. |
ScrollPresent |
Updates a portion of the client area and presents it. |
GetBufferRetrieves a back buffer.
HRESULT GetBuffer(
[in] UINT Buffer,
[in] REFIID riid,
[out] void **ppSurface
);
BufferriidppSurfaceID3D11Texture2D or IDXGISurface). For a back buffer, this is typically an ID3D11Texture2D interface.GetDescGets a description of the swap chain.
HRESULT GetDesc(
[out] DXGI_SWAP_CHAIN_DESC *pDesc
);
pDescDXGI_SWAP_CHAIN_DESC structure that describes the swap chain.GetFrameStatisticsGets frame statistics.
HRESULT GetFrameStatistics(
[out] DXGI_FRAME_STATISTICS *pStats
);
pStatsDXGI_FRAME_STATISTICS structure that receives frame statistics.GetLastPresentCountGets the count of present operations.
HRESULT GetLastPresentCount(
[out] UINT *pLastPresentCount
);
pLastPresentCountUINT variable that receives the count of present operations.PresentPresents the next frame of the swap chain to the user.
HRESULT Present(
[in] UINT SyncInterval,
[in] UINT Flags
);
SyncIntervalFlagsDXGI_PRESENT_DO_NOT_SEQUENCE.ResizeBuffersResizes the back buffers.
HRESULT ResizeBuffers(
[in] UINT BufferCount,
[in] UINT Width,
[in] UINT Height,
[in] DXGI_FORMAT NewFormat,
[in] UINT SwapChainFlags
);
BufferCountWidthHeightNewFormatSwapChainFlagsScrollPresentUpdates a portion of the client area and presents it.
HRESULT ScrollPresent(
[in] UINT ScrollX,
[in] UINT ScrollY,
[in] const RECT *pDirtyRect,
[in] UINT Flags
);
ScrollXScrollYpDirtyRectRECT structure that specifies the updated region.FlagsThe IDXGISwapChain interface is central to how graphics are displayed in Windows applications. It provides control over buffer presentation, resolution changes, and frame synchronization, making it a fundamental component for any application that renders graphics using DirectX.
When an application renders a frame, it typically draws to a back buffer. The Present method then makes this back buffer visible to the user, often synchronizing with the monitor's refresh rate to avoid tearing.
The ResizeBuffers method is crucial for handling window resizing or changes in display resolution. Applications must be able to adapt their rendering targets and swap chain configuration to these changes.