Graphics Reference
In-Depth Information
is considered to execute separately from the traditional rendering pipeline. In this way, it
implements a single-stage pipeline devoted to general purpose computation. The general
trend of using the GPU for purposes other than rendering has been incorporated directly
into the Direct3D 11 API, and is manifested in the compute shader.
Several features have been provided to the compute shader that facilitate a flexible
processing environment for implementing more general algorithms. The first new func-
tionality is the addition of a structured threading model that gives the developer significant
freedom in using the available parallelism of the GPU to implement highly parallel algo-
rithms. Previously, the invocation of a shader program was restricted to how an input was
processed by a particular stage (for example, the pixel shader program was invoked once
for each fragment generated), and the developer didn't have direct control over how the
threads were used. This is no longer the case with the compute shader stage.
The second new functionality that makes the computer shader stage more flexible is
the ability to declare and use a "Group Shared Memory" block. This memory block is then
accessible to all of the threads within a thread group. This allows communication between
threads during execution, which has typically not been possible with the rendering pipe-
line. With communication possible, there is a potential for significant efficiency improve-
ments by sharing loaded data or intermediate calculations.
Finally, the concept of random read and write access to resources has been introduced
(which we will discuss further in the "Resources" section of this chapter). This represents
a significant change from the shader stages we have already discussed, which only allow
a resource to be bound as either an input or as an output. The ability to read and write to a
complete resource provides another avenue for communication between threads.
These three new concepts, when taken together, introduce a very flexible general-
purpose processing stage that can be used for both rendering calculations, as well as for
general purpose computations. We will take a much closer look at the compute shader in
Chapter 5, "The Computation Pipeline," and there are several sample algorithms through-
out the second half of the topic that make extensive use of the compute shader.
1.3 Resources
The rendering and computation pipelines that we discussed in the previous section are two
of the major concepts that one must understand when learning about the Direct3D 11 API.
The next major concept that we need to understand is the resources that are connected at
various locations throughout the pipeline. If you consider the rendering pipeline to be an
automobile assembly line, the resources would be all of the components that come into
the line that are put together to create the automobile. When used without resources, the
pipeline can't do anything, and vice versa.
Search WWH ::




Custom Search