ID3D11Device::CreateRenderTargetView method (d3d11.h)

Creates a render-target view for accessing resource data.


HRESULT CreateRenderTargetView(
  [in]            ID3D11Resource                      *pResource,
  [in, optional]  const D3D11_RENDER_TARGET_VIEW_DESC *pDesc,
  [out, optional] ID3D11RenderTargetView              **ppRTView


[in] pResource

Type: ID3D11Resource*

Pointer to a ID3D11Resource that represents a render target. This resource must have been created with the D3D11_BIND_RENDER_TARGET flag.

[in, optional] pDesc


Pointer to a D3D11_RENDER_TARGET_VIEW_DESC that represents a render-target view description. Set this parameter to NULL to create a view that accesses all of the subresources in mipmap level 0.

[out, optional] ppRTView

Type: ID3D11RenderTargetView**

Address of a pointer to an ID3D11RenderTargetView. Set this parameter to NULL to validate the other input parameters (the method will return S_FALSE if the other input parameters pass validation).

Return value


This method returns one of the Direct3D 11 Return Codes.


A render-target view can be bound to the output-merger stage by calling ID3D11DeviceContext::OMSetRenderTargets.

The Direct3D 11.1 runtime, which is available starting with Windows 8, allows you to use CreateRenderTargetView for the following new purpose.

You can create render-target views of video resources so that Direct3D shaders can process those render-target views. These video resources are either Texture2D or Texture2DArray. The value in the ViewDimension member of the D3D11_RENDER_TARGET_VIEW_DESC structure for a created render-target view must match the type of video resource, D3D11_RTV_DIMENSION_TEXTURE2D for Texture2D and D3D11_RTV_DIMENSION_TEXTURE2DARRAY for Texture2DArray. Additionally, the format of the underlying video resource restricts the formats that the view can use. The video resource format values on the DXGI_FORMAT reference page specify the format values that views are restricted to.

The runtime read+write conflict prevention logic (which stops a resource from being bound as an SRV and RTV or UAV at the same time) treats views of different parts of the same video surface as conflicting for simplicity. Therefore, the runtime does not allow an application to read from luma while the application simultaneously renders to chroma in the same surface even though the hardware might allow these simultaneous operations.


Requirement Value
Target Platform Windows
Header d3d11.h
Library D3D11.lib

See also