Graphics Reference
In-Depth Information
3.5 Hull Shader
Our next stop in the pipeline brings us to the new tessellation stages. These three stages
work together to implement a flexible and configurable system. The stages, in order of
appearance in the pipeline, are the hull shader stage, the tessellator stage, and the domain
shader stage. Of these stages, the hull shader and domain shader stages are programmable,
while the tessellator stage performs fixed-function operations. The hull shader stage can be
thought of as performing the setup operations that prepare the input primitives for further
processing. It instructs the Tessellator stage how finely to split up the input geometry, and
provides the processed control point primitives
1
2
for the domain shader stage, which will
fill in the freshly tessellated vertices with data. Thus, the hull shader plays a very important
role in configuring the overall tessellation scheme. The location of the hull shader within
the pipeline is highlighted in Figure 3.20.
The responsibilities of the hull shader stage are divided into two separate HLSL func-
tions. The first is the hull shader program. The hull shader program is invoked once for
each control point needed to create an output control patch. It receives input control
patch
primitives constructed from the control points produced by the vertex shader, and must
create one processed output control
point
for each invocation of the hull shader program.
Unlike the vertex shader, the hull shader program is aware of both the input and output
primitive topology of the geometry being passed through it. In fact,
every
invocation of the
hull shader has access to all of the input control points that belong to its input control patch.
With access to the complete input data, the hull shader stage can also statically expand or
reduce the number of control points in the control patch before the control patch is passed
to the next stage in the pipeline. This change in control point count is statically declared
with a special attribute in HLSL, and all control patches passed in to the hull shader will be
reduced or expanded in the same way. This is the first time we have seen a pipeline stage
that can perform an amplification of the primitive data stream passing through it.
The second HLSL function that performs operations within the hull shader stage is
referred to as a patch constant function. In contrast to the hull shader program, the patch
Figure 3.20. The hull shader stage.
1
2
The control patch primitive types are described in the "Primitive Topology" section earlier in this chapter.
Search WWH ::
Custom Search