Graphics Reference
In-Depth Information
won't repeat any code listings here, since they are essentially the same as we have seen in
the vertex shader section. These common methods are listed below easy reference.
ID3DllDeviceContext::PSSetShader()
ID3DllDeviceContext::PSSetConstantBuffers()
ID3DllDeviceContext::PSSetShaderResources()
ID3DllDeviceContext::PSSetSamplers()
In addition to the standard resources of the common shader core, the pixel shader
also has access to the new unordered access views, which provides random access to read
and write to resources directly from the pixel shader. Finally, a function attribute called
earlydepthstencil can be used to force the depth stencil test to be performed prior to
the pixel shader. We will investigate these unique configurations in more detail in the fol-
lowing sections.
Unordered Access Views
The pixel shader stage can use utilize unordered access views. As opposed to the shader
resource views that provide read-only random access to resources, the unordered access
views allow read and write random access. This lets the pixel shader program perform scat-
ter writing operations, meaning that it can programmatically decide where to store the data
it writes to a resource. Before having access to UAVs, the pixel shader could only write to
the output render target and depth stencil render target in the location determined by the
rasterizer stage when it generated the fragment.
The method for binding an unordered access view to the pipeline for use in the pixel
shader is performed through the device context, just as it is for all other pipeline configura-
tions. In this case though, the UAV is actually bound to the pipeline in the output merger
stage instead of the pixel shader stage. This is done so that the render targets, depth stencil
target, and any UAVs that will receive output from the pipeline are all bound for output
from the pixel shader in the same method call. This also groups all possible pipeline output
resources into a single pipeline stage, which somewhat simplifies the pipeline concept. In
the output merger section we will see how resources are bound for use in the pixel shader
with a UAV.
Early Depth Stencil Test
The other unique configuration for the pixel shader stage is performed from within the
pixel shader program's source code. The earlydepthstencil function attribute can be
declared before a pixel shader program to indicate that the depth and stencil tests should be
Search WWH ::




Custom Search