Graphics Reference
In-Depth Information
array-like layout structure provides a surprisingly wide variety of available buffer types.
Some buffer types will be used primarily in the C++ side of an application, while others will
be used primarily by HLSL shader programs after being attached to the pipeline. This section
will explore each of the different types of buffers, describe what functionality they provide,
and demonstrate how to create them. In addition, we will discuss common uses for buffers
and provide the basic HLSL syntax to declare and use these resources in shader programs.
Vertex Buffers
The first buffer type that we will examine is the vertex buffer. The purpose of a vertex buffer
is to house all of the data that will eventually be assembled into vertices and sent through the
rendering pipeline. The simplest vertex buffer configuration is an array of vertex structures,
where each vertex contains elements such as position, normal vector, and texture coordi-
nates. These vertex elements must conform to the available format and type specifications.
However, whatever generic information that is desired within the vertex can also be packed
into a vertex structure to allow customized input data for a particular rendering algorithm.
In addition to the simple array-style vertex buffers described above, these buffers also
allow for some other, more complex configurations. For instance, it is possible to use more
than one vertex buffer at the same time. This allows vertex data to be split among multiple
buffers. For example, vertex positions could be stored in one buffer, and vertex normal vec-
tors in another buffer. This allows the application to selectively add in vertex data as it is
needed, instead of using one large overall buffer for all rendering scenarios. This technique
could be used to reduce the amount of bandwidth required for rendering operations.
It is also possible to perform instanced rendering, where one or more vertex buffers
provide a model's per-vertex data, and an additional vertex buffer provides per-instance data
instead of per-vertex data. The model defined in the first buffer is then rendered as a series of
models, with the per-instance data from the second buffer applied to each instance. Figure 2.8
depicts these different vertex submission configurations. The per-instance data could include
Figure 2.8. The various vertex buffer configurations that are available to an application.
Search WWH ::




Custom Search