Graphics Reference
In-Depth Information
Custom coverage masks. Under normal conditions, the value output from a pixel shader
is based on the coverage mask generated by the coverage test performed in the rasterizer
stage. However it is possible for pixel shaders to instead output their own coverage mask
instead, using the SV_Coverage semantic. The value output is a uint, where each bit cor-
responds to a subsample in the render target. Setting a bit to 1 causes the output value to be
written to a subsample, while setting it to 0 prevents it from being written. The obvious use
of this semantic is for implementing a custom mask for alpha-to-coverage transparency,
rather than relying on the fixed screen-space mask implemented in most hardware. Another
possible use is for implementing MSAA is a deferred Tenderer, which is explored further in
Chapter 11, "Deferred Rendering."
3.11.4 Pixel Shader Pipeline Output
Since the pixel shader stage sends its output to the end of the pipeline, the output merger
stage, there are limitations on the output attributes that it can write to. The output merger
can only process the color values and depth described above, and no additional information
can be received. This is enforced by the shader compiler, which requires that any output
attributes be limited to those system value semantics that represent color and depth, namely
SV_Target[n] and SV_Depth.
The only exceptions to these attributes are the SV_DepthGreaterThan, SV_
DepthLessThan, and SV_Coverage semantics. The first two provide the mechanism to con-
tinue to enable the hierarchical z-culling algorithm when the SV_Depth attribute is written
to. Therefore, it is not useful to write either of these semantic attributes if the depth is not
manually modified in the pixel shader. The SVCoverage semantic makes it possible to use
customized subsample coverage masks, as detailed above. Since it specifies a pattern to be
used in an MSAA render target, it also should only be used in situations that use MSAA
render targets.
3.12 Output Merger
The final stop in the pipeline is the output merger stage. This is a fixed function stage that
receives color and depth results from the pixel shader stage, and then merges those results
into the render targets bound to it for output. However, this stage provides significantly
more functionality than simply writing color and depth values to resources. The output
merger also performs visibility determination with the depth test, which implements the
traditional Z-buffer algorithm. In addition, it can also perform a stencil test to precisely
control which areas of the render target are written to. We will examine how these two
Search WWH ::




Custom Search