Graphics Reference
In-Depth Information
the bottom of the stage. The shader program that executes within these stages is a function
written in HLSL for a specific purpose. While the data is being processed within the shader
stage, the shader program has access to constant buffers, samplers, and shader resource
views that are bound to that stage by the application. Once the shader program has finished
processing its data, that data is passed out of the stage, and the next piece of data is brought
in to start the process over again.
The configurability of the programmable pipeline stages is not limited to the process-
ing performed within the shader programs. The input and output data structures for these
stages are also specified by the shader program, which provides a flexible way to pass data
from stage to stage. Some rules are imposed on these interfaces between stages, such as
requiring certain types of data to be included in the interfaces of particular stages. A typi-
cal example of a required output is for one of the stages before the rasterizer to provide a
position output that can be used to determine which pixels of a render target are covered
by a primitive. Depending on which stages are passing the data, the parameters are either
provided unmodified, or can be interpolated before being passed on to the next stage.
While all the programmable stages share a common set of functionality, each stage
can also provide additional specialized features and functionalities unique to it. These are
usually related to input and output semantics, and are hence only applicable to particular
stages. The individual behaviors of each stage will be discussed in more detail later in this
chapter as we describe each stage of the pipeline.
With so much flexibility, and a wide variety of different pipeline stages, there are
many algorithms that do not require all stages to be active. Thus, it is possible to disable
the programmable shader stage's by clearing its shader program. In addition, since there
is a large amount of flexibility in the processing done in each stage, it is quite possible to
perform some or all of the required work in different combinations of all of the program-
mable stages. This ability to choose where to perform a particular calculation can be used
to our advantage. If a calculation can be done prior to any data amplification, it is possible
to calculate the same data with far fewer operations. We will see a good example of this in
the Chapter 8, "Mesh Rendering," where vertex skinning is performed prior to a model be-
ing tessellated, to reduce the number of vertices being skinned. (The details of what vertex
skinning is can be found in Chapter 8.)
Shader Core Architecture
In the previous section, we have seen the general concept of how a programmable stage
operates. It receives input from the previous stage, executes an HLSL program on it, and
passes the results on to the next pipeline stage. However, this is just an overview descrip-
tion of what is really going on. The shader program that executes in a programmable stage
is actually compiled from HLSL into a vector-register-based assembly language designed
for use in specialized shader processor cores in the GPU. Even though all shader programs
Search WWH ::




Custom Search