Graphics Reference
In-Depth Information
The input assembler can also produce three different system value semantics: SV_
VertexID, SV_PrimitiveID, and SV_InstanceID. These system value semantics are not
supplied by the user, but are instead generated by the input assembler as it creates the out-
put data streams. The SV_VertexID system value is an unsigned integer, which uniquely
identifies each vertex in the assembled vertex stream. It is first available in the vertex
shader, and provides a simple way to differentiate between vertices later in the pipeline.
The SV_PrimitiveID provides a similar unique identifier for each primitive in the primi-
tive stream. It is first available in the hull shader stage, since the vertex shader doesn't use
primitive-level information. Finally, the SV_InstanceID uniquely identifies each instance
of the geometry in an instanced draw call. It is first available for use in the vertex shader
stage. Together, these three system values provide a fairly extensive method for identifying
each of the data elements that the input assembler produces.
3.4 Vertex Shader
The first programmable shader stage in the rendering pipeline is the vertex shader. As
described above, the programmable shader stages execute a custom function written in
HTSL. In the case of the vertex shader stage, the vertex shader program is a function that
is invoked once for each vertex in the vertex stream produced by the input assembler. Each
of the input vertices is received as the argument to the vertex shader program, and the
processed vertices are returned as the result of the function. Each vertex shader invocation
is executed in complete isolation from the others, with no communication between them
possible. Since it is executed once for each input vertex, there will be a one-to-one mapping
of input vertices to output vertices from the vertex shader stage. The location of the vertex
shader within the pipeline is highlighted in Figure 3.12.
In addition, each invocation of the vertex shader is not aware of the primitive stream
produced by the input assembler. Its sole purpose is to process vertex data and leave any
higher-level processing to the stages further down the pipeline. With no knowledge of
primitives, the vertex shader operates in the same way for all different topology types.
Regardless of whether it is processing geometry that was submitted as points, lines,
Figure 3.12. The vertex shader stage.
Search WWH ::




Custom Search