ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews method (d3d11.h)

Binds resources to the output-merger stage.

Syntax

void OMSetRenderTargetsAndUnorderedAccessViews(
  [in]           UINT                      NumRTVs,
  [in, optional] ID3D11RenderTargetView    * const *ppRenderTargetViews,
  [in, optional] ID3D11DepthStencilView    *pDepthStencilView,
  [in]           UINT                      UAVStartSlot,
  [in]           UINT                      NumUAVs,
  [in, optional] ID3D11UnorderedAccessView * const *ppUnorderedAccessViews,
  [in, optional] const UINT                *pUAVInitialCounts
);

Parameters

[in] NumRTVs

Type: UINT

Number of render targets to bind (ranges between 0 and D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT). If this parameter is nonzero, the number of entries in the array to which ppRenderTargetViews points must equal the number in this parameter. If you set NumRTVs to D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL (0xffffffff), this method does not modify the currently bound render-target views (RTVs) and also does not modify depth-stencil view (DSV).

[in, optional] ppRenderTargetViews

Type: ID3D11RenderTargetView*

Pointer to an array of ID3D11RenderTargetViews that represent the render targets to bind to the device. If this parameter is NULL and NumRTVs is 0, no render targets are bound.

[in, optional] pDepthStencilView

Type: ID3D11DepthStencilView*

Pointer to a ID3D11DepthStencilView that represents the depth-stencil view to bind to the device. If this parameter is NULL, the depth-stencil view is not bound.

[in] UAVStartSlot

Type: UINT

Index into a zero-based array to begin setting unordered-access views (ranges from 0 to D3D11_PS_CS_UAV_REGISTER_COUNT - 1).

For the Direct3D 11.1 runtime, which is available starting with Windows 8, this value can range from 0 to D3D11_1_UAV_SLOT_COUNT - 1. D3D11_1_UAV_SLOT_COUNT is defined as 64.

For pixel shaders, UAVStartSlot should be equal to the number of render-target views being bound.

[in] NumUAVs

Type: UINT

Number of unordered-access views (UAVs) in ppUnorderedAccessViews. If you set NumUAVs to D3D11_KEEP_UNORDERED_ACCESS_VIEWS (0xffffffff), this method does not modify the currently bound unordered-access views.

For the Direct3D 11.1 runtime, which is available starting with Windows 8, this value can range from 0 to D3D11_1_UAV_SLOT_COUNT - UAVStartSlot.

[in, optional] ppUnorderedAccessViews

Type: ID3D11UnorderedAccessView*

Pointer to an array of ID3D11UnorderedAccessViews that represent the unordered-access views to bind to the device. If this parameter is NULL and NumUAVs is 0, no unordered-access views are bound.

[in, optional] pUAVInitialCounts

Type: const UINT*

An array of append and consume buffer offsets. A value of -1 indicates to keep the current offset. Any other values set the hidden counter for that appendable and consumable UAV. pUAVInitialCounts is relevant only for UAVs that were created with either D3D11_BUFFER_UAV_FLAG_APPEND or D3D11_BUFFER_UAV_FLAG_COUNTER specified when the UAV was created; otherwise, the argument is ignored.

Return value

None

Remarks

For pixel shaders, the render targets and unordered-access views share the same resource slots when being written out. This means that UAVs must be given an offset so that they are placed in the slots after the render target views that are being bound.

Note  RTVs, DSV, and UAVs cannot be set independently; they all need to be set at the same time.
 
Two RTVs conflict if they share a subresource (and therefore share the same resource).

Two UAVs conflict if they share a subresource (and therefore share the same resource).

An RTV conflicts with a UAV if they share a subresource or share a bind point.

OMSetRenderTargetsAndUnorderedAccessViews operates properly in the following situations:

  1. NumRTVs != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL and NumUAVs != D3D11_KEEP_UNORDERED_ACCESS_VIEWS

    The following conditions must be true for OMSetRenderTargetsAndUnorderedAccessViews to succeed and for the runtime to pass the bind information to the driver:

    • NumRTVs <= 8
    • UAVStartSlot >= NumRTVs
    • UAVStartSlot + NumUAVs <= 8
    • There must be no conflicts in the set of all ppRenderTargetViews and ppUnorderedAccessViews.
    • ppDepthStencilView must match the render-target views. For more information about resource views, see Introduction to a Resource in Direct3D 11.
    OMSetRenderTargetsAndUnorderedAccessViews performs the following tasks:
    • Unbinds all currently bound conflicting resources (stream-output target resources (SOTargets), compute shader (CS) UAVs, shader-resource views (SRVs)).
    • Binds ppRenderTargetViews, ppDepthStencilView, and ppUnorderedAccessViews.
  2. NumRTVs == D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL

    In this situation, OMSetRenderTargetsAndUnorderedAccessViews binds only UAVs.

    The following conditions must be true for OMSetRenderTargetsAndUnorderedAccessViews to succeed and for the runtime to pass the bind information to the driver:

    • UAVStartSlot + NumUAVs <= 8
    • There must be no conflicts in ppUnorderedAccessViews.
    OMSetRenderTargetsAndUnorderedAccessViews unbinds the following items:
    • All RTVs in slots >= UAVStartSlot
    • All RTVs that conflict with any UAVs in ppUnorderedAccessViews
    • All currently bound resources (SOTargets, CS UAVs, SRVs) that conflict with ppUnorderedAccessViews
    OMSetRenderTargetsAndUnorderedAccessViews binds ppUnorderedAccessViews.

    OMSetRenderTargetsAndUnorderedAccessViews ignores ppDepthStencilView, and the current depth-stencil view remains bound.

  3. NumUAVs == D3D11_KEEP_UNORDERED_ACCESS_VIEWS

    In this situation, OMSetRenderTargetsAndUnorderedAccessViews binds only RTVs and DSV.

    The following conditions must be true for OMSetRenderTargetsAndUnorderedAccessViews to succeed and for the runtime to pass the bind information to the driver:

    • NumRTVs <= 8
    • There must be no conflicts in ppRenderTargetViews.
    • ppDepthStencilView must match the render-target views. For more information about resource views, see Introduction to a Resource in Direct3D 11.
    OMSetRenderTargetsAndUnorderedAccessViews unbinds the following items:
    • All UAVs in slots < NumRTVs
    • All UAVs that conflict with any RTVs in ppRenderTargetViews
    • All currently bound resources (SOTargets, CS UAVs, SRVs) that conflict with ppRenderTargetViews
    OMSetRenderTargetsAndUnorderedAccessViews binds ppRenderTargetViews and ppDepthStencilView.

    OMSetRenderTargetsAndUnorderedAccessViews ignores UAVStartSlot.

Windows Phone 8: This API is supported.

Requirements

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

See also

ID3D11DeviceContext