Graphics Reference
In-Depth Information
Listing 3.13 shows a sample attribute declaration for a hull shader program for a three-
point control patch list topology.
HS_C0NTROL_POINT_OUTPUT HSMAIN( InputPatch<HS_CONTROL_POINT_INPUT, 3> ip,
uint i : SV_OutputControlPointID,
uint PatchID : SV_PrimitiveID )
{
HS_CONTROL_POINT_OUTPUT output;
// Insert code to compute Output here,
output.WorldPosition = ip[i].WorldPosition;
return output;
}
Listing 3.13. A sample hull shader program, demonstrating its attribute declaration.
Listing 3.13 also shows a pair of system value attributes. The particular control point
that a hull shader invocation is processing is indicated in the SV_OutputControlPointID
system value, which must be declared as an input attribute. This system value semantic pro-
vides a single-component unsigned integer that identifies the current hull shader invocation
control point within the specified output control patch size. By using this attribute, the hull
shader program can determine which portion of the input control points to use when gen-
erating the output control point. The second system value is the SV_PrimitiveID, which
provides a unique single-component unsigned integer identifier for each control patch. This
is the first pipeline stage where this system value semantic is available, since the vertex
shader has no concept of primitives.
The patch constant function runs only once for a complete control patch primitive that
is passed into the hull shader stage. Like the hull shader program, it has access to the com-
plete set of input control points, and all their attributes. It can also use the SV_PrimitiveID
system value, but not the SV_OutputControlPointID system value semantic. This makes
sense, because this function operates once for the entire patch—it would have no use for an
identifier of individual control points.
3.5.2 Hull Shader State Configuration
Since the hull shader stage is one of the programmable shader stages and has access to the
same set of resources that have been discussed for the vertex shader. They are covered here
for completeness, but in fact, the names of the methods used to set and get the resources
are simply updated to indicate which pipeline stage should be affected by the method, so
we won't repeat the code listings here. The method names are provided here for reference.
Search WWH ::




Custom Search