Graphics Reference
In-Depth Information
render targets after they are bound, and it will keep the reference until the render target is
replaced with a NULL reference.
One other resource type can be bound to the output merger stage. We have seen in
the section on the pixel shader stage that it can use using unordered access views (UAVs).
However, the pixel shader stage cannot accept UAVs for binding. Instead, they are bound
to the output merger stage in the same way that render targets are. When UAVs are used,
they are bound with the ID3D11DeviceContext::OMSetRenderTargetsAndUnordered
AccessViews() method. The first three arguments of this method are identical to the ren-
der-target-only version, while the remaining four are used to bind the UAVs. There are a to-
tal of eight UAV slots available, and the range of slots affected by this call is selected with
the UAVStartSlot and the NumUAVs parameters. The ppUnorderedAccessView parameter
is a pointer to an array of UAVs to be bound. Naturally, the number of UAVs in this array
must match the number of views specified in the NumUAVs parameter.
The final parameter to this method is another pointer to an array of UINT values.
These values provide the current buffer counter value for use in Append / Consume buffers.
As described in Chapter 2, buffers used with a UAV contain an internal counter indicat-
ing the number of elements present in the buffer. This counter is hidden in the buffer and
is maintained by the runtime. However, the value stored in these counters at the time of
binding is controlled by what is passed into this array. This lets the application effectively
reset the data in the buffer if desired, or if a value of -1 is passed, the current internal buffer
counter value is maintained.
The total number of render targets and UAVs being bound must not exceed eight.
However, any combination that adds up to eight or less is allowed—including using eight
UAVs and no render targets. If there are no render targets bound to the pipeline, the UAVs
represent the only outputs for the entire pipeline. Both methods for binding render targets
to the output merger are shown in Listing 3.27.
void OMSetRenderTargets(
UINT NumViews,
ID3D11RenderTargetView **ppRenderTargetViews,
ID3D11DepthStencilView *pDepthStencilView
);
void OMSetRenderTargetsAndUnorderedAccessViews(
UINT NumViews,
ID3D11RenderTargetView **ppRenderTargetViews,
ID3D11DepthStencilView *ppDepthStencilView,
UINT UAVStartSlot,
UINT NumUAVs,
ID3DllUnorderedAccessView **ppUnorderedAccessView,
const UINT *pUAVInitialCounts
);
Listing 3.27. The device context methods for binding resources to the output merger stage.
Search WWH ::




Custom Search