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. |
GetBuffer
Retrieves a back buffer.
HRESULT GetBuffer(
[in] UINT Buffer,
[in] REFIID riid,
[out] void **ppSurface
);
Buffer
riid
ppSurface
ID3D11Texture2D
or IDXGISurface
). For a back buffer, this is typically an ID3D11Texture2D
interface.GetDesc
Gets a description of the swap chain.
HRESULT GetDesc(
[out] DXGI_SWAP_CHAIN_DESC *pDesc
);
pDesc
DXGI_SWAP_CHAIN_DESC
structure that describes the swap chain.GetFrameStatistics
Gets frame statistics.
HRESULT GetFrameStatistics(
[out] DXGI_FRAME_STATISTICS *pStats
);
pStats
DXGI_FRAME_STATISTICS
structure that receives frame statistics.GetLastPresentCount
Gets the count of present operations.
HRESULT GetLastPresentCount(
[out] UINT *pLastPresentCount
);
pLastPresentCount
UINT
variable that receives the count of present operations.Present
Presents the next frame of the swap chain to the user.
HRESULT Present(
[in] UINT SyncInterval,
[in] UINT Flags
);
SyncInterval
Flags
DXGI_PRESENT_DO_NOT_SEQUENCE
.ResizeBuffers
Resizes the back buffers.
HRESULT ResizeBuffers(
[in] UINT BufferCount,
[in] UINT Width,
[in] UINT Height,
[in] DXGI_FORMAT NewFormat,
[in] UINT SwapChainFlags
);
BufferCount
Width
Height
NewFormat
SwapChainFlags
ScrollPresent
Updates a portion of the client area and presents it.
HRESULT ScrollPresent(
[in] UINT ScrollX,
[in] UINT ScrollY,
[in] const RECT *pDirtyRect,
[in] UINT Flags
);
ScrollX
ScrollY
pDirtyRect
RECT
structure that specifies the updated region.Flags
The 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.