IDXGIResource1::CreateSubresourceSurface method

Creates a subresource surface object.


HRESULT CreateSubresourceSurface(
  UINT          index,
  IDXGISurface2 **ppSurface



The index of the subresource surface object to enumerate.


The address of a pointer to a IDXGISurface2 interface that represents the created subresource surface object at the position specified by the index parameter.

Return Value

Returns S_OK if successful; otherwise, returns one of the following values:

  • DXGI_ERROR_INVALID_CALL if the index is out of range or if the subresource is not a valid surface.
  • E_OUTOFMEMORY if insufficient memory is available to create the subresource surface object.
A subresource is a valid surface if the original resource would have been a valid surface had its array size been equal to 1.


Subresource surface objects implement the IDXGISurface2 interface, which inherits from IDXGISurface1 and indirectly IDXGISurface. Therefore, the GDI-interoperable methods of IDXGISurface1 work if the original resource interface object was created with the GDI-interoperable flag (D3D11_RESOURCE_MISC_GDI_COMPATIBLE).

CreateSubresourceSurface creates a subresource surface that is based on the resource interface on which CreateSubresourceSurface is called. For example, if the original resource interface object is a 2D texture, the created subresource surface is also a 2D texture.

You can use CreateSubresourceSurface to create parts of a stereo resource so you can use Direct2D on either the left or right part of the stereo resource.


Minimum supported client Windows 8 and Platform Update for Windows 7 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header dxgi1_2.h
Library Dxgi.lib

See Also