IDXGIFactoryMedia::CreateSwapChainForCompositionSurfaceHandle method (dxgi1_3.h)

Creates a YUV swap chain for an existing DirectComposition surface handle.


HRESULT CreateSwapChainForCompositionSurfaceHandle(
  [in]           IUnknown                    *pDevice,
  [in, optional] HANDLE                      hSurface,
  [in]           const DXGI_SWAP_CHAIN_DESC1 *pDesc,
  [in, optional] IDXGIOutput                 *pRestrictToOutput,
  [out]          IDXGISwapChain1             **ppSwapChain


[in] pDevice

A pointer to the Direct3D device for the swap chain. This parameter cannot be NULL. Software drivers, like D3D_DRIVER_TYPE_REFERENCE, are not supported for composition swap chains.

[in, optional] hSurface

A handle to an existing DirectComposition surface. This parameter cannot be NULL.

[in] pDesc

A pointer to a DXGI_SWAP_CHAIN_DESC1 structure for the swap-chain description. This parameter cannot be NULL.

[in, optional] pRestrictToOutput

A pointer to the IDXGIOutput interface for the swap chain to restrict content to. If the swap chain is moved to a different output, the content is black. You can optionally set this parameter to an output target that uses DXGI_PRESENT_RESTRICT_TO_OUTPUT to restrict the content on this output. If the swap chain is moved to a different output, the content is black.

You must also pass the DXGI_PRESENT_RESTRICT_TO_OUTPUT flag in a present call to force the content to appear blacked out on any other output. If you want to restrict the content to a different output, you must create a new swap chain. However, you can conditionally restrict content based on the DXGI_PRESENT_RESTRICT_TO_OUTPUT flag.

Set this parameter to NULL if you don't want to restrict content to an output target.

[out] ppSwapChain

A pointer to a variable that receives a pointer to the IDXGISwapChain1 interface for the swap chain that this method creates.

Return value

CreateSwapChainForCompositionSurfaceHandle returns:

  • S_OK if it successfully created a swap chain.
  • E_OUTOFMEMORY if memory is unavailable to complete the operation.
  • DXGI_ERROR_INVALID_CALL if the calling application provided invalid data, for example, if pDesc, pYuvDecodeBuffers, or ppSwapChain is NULL.
  • Possibly other error codes that are described in the DXGI_ERROR topic that are defined by the type of device that you pass to pDevice.


Minimum supported client Windows 8.1 [desktop apps only]
Minimum supported server Windows Server 2012 R2 [desktop apps only]
Target Platform Windows
Header dxgi1_3.h
Library Dxgi.lib

See also

For best performance, use DXGI flip model