Graphics Reference
In-Depth Information
Using buffers/structured buffers. Due to this ability to provide a large amount of struc-
tured data, the buffer and structured buffer are great options for larger data structures that
are to be accessed by the programmable shader stages. These buffers are the first resources
that are attached to the pipeline with resource views instead of being directly bound. These
buffers are available with read access to all of the programmable pipeline stages, and read/
write access is also possible in the pixel and compute shader stages, depending on which
resource view is used. This means that these resources can potentially provide a means
of communication between the various pipeline stages, as well as between the individual
processing elements within the same pipeline stage.
A pipeline stage's resource access capabilities are determined by which type of re-
source view is used to bind the resource to the pipeline. Unlike the constant buffer, the
buffer/structured buffer must be bound to the pipeline through a resource view, which
means that it must be created with an appropriate bind flag for binding with either a shader
resource view, an unordered access view, or both. The shader resource view allows bind-
ing to all of the programmable pipeline stages, while the unordered access view is only
allowed to be bound to the pixel and compute shader stages. Since an unordered access
view is required to perform write accesses to a resource, the available binding locations for
UAVs effectively determine where these write accesses can be performed. The available
connection points for both shader resource views and unordered access views are shown
in Figure 2.16. Like a constant buffer, a buffer/structured buffer can be bound to multiple
locations when used for read-only uses. This is done by binding it to the pipeline with a
shader resource view. However, when an unordered access view is used, it may only be
bound to a single location. This is enforced by the runtime, which will print error messages
if the resource is bound to multiple locations for writing. The use of an unordered access
view also excludes simultaneous use of shader resource views, due to the read-after-write
issues that it could introduce.
Creating buffers/structured buffers. As we have seen in the other buffer resource cre-
ation discussions, it must be determined which usage scenario the buffers/structured buf-
fers will experience. There are in general three different types of usage patterns for these
resources. The first case is that the data within the buffer will be static throughout the
lifetime of the application. An example of this would be to use the buffer/structured buffer
resource to hold precalculated data, such as precomputed radiance transfer data or some
other form of a lookup table. The second case is when data needs to be loaded periodically
into the buffer by the CPU. This is a likely scenario in many general purpose computation
systems, where the GPU is being used as a co-processor to the CPU and is continually feed-
ing the GPU with new data to process. In both of these cases, the GPU is only allowed to
read the buffer data and is not able to write to the resource.
The final case arises when the buffer contents are updated in some way by the GPU
itself. A common example of this can be found in situations where the GPU is performing
Search WWH ::




Custom Search