Graphics Reference
In-Depth Information
built-in data types. In this way, a standard buffer resource is similar to an array of values.
Each value is stored at a unique array location and can be referenced by the index of its
location. This allows the resource to be easily accessed by many different instances of a
shader program simultaneously on the GPU. Since each element is uniquely identified, the
developer can easily structure the program to avoid any memory collisions. Figure 2.14
graphically represents a buffer resource.
Very similar to the buffer resource is a structured buffer resource. The only differ-
ence between the two is that a structured buffer allows the user to define a structure as the
basic element, instead of one of the built-in data types. This makes mapping the data of a
particular processing problem to a resource relatively simple. If the developer can define a
suitable structure in C++, a corresponding structure in HLSL can be defined, and the buffer
will contain an array of these structures, which can be used by the programmable shader
stages as a resource object.
The structured buffer is intended to provide a flexible memory resource for simplify-
ing custom algorithm development. Since the data format within the structure can use any
of the available types within HLSL, it can be customized to suit a particular scenario. The
available structure formation is quite similar to that of the constant buffer, except that the
structured buffer provides an array of the desired structures, instead of a single instance
like the constant buffer. This concept is depicted graphically in Figure 2.15. In this figure,
a hypothetical structure is shown that could represent the data for a particle in a particle
system.
Here we see that the particle structure uses multiple variables, and that the complete
particle system is contained within the structured buffer. A very interesting point to note
is that these buffer types are the first resources that we have discussed that can be used for
writing, as well as reading, by the programmable pipeline stages. We will explore the de-
tails of how to use this functionality throughout the remainder of this section.
Figure 2.14. A depiction of a standard buffer
resource.
Figure 2.15. A structured buffer used to contain
data from a particle system.
Search WWH ::




Custom Search