Graphics Reference
In-Depth Information
to the pipeline either directly or with a resource view, where they are then used during a
pipeline execution event. The resource creation process uses a different ID3DllDevice
method for each type of resource, but they all follow the same general pattern.
The creation methods all take three parameters. The first parameter is a structure
that specifies all of the various options that a resource can be created with. It is referred
to as a resource description. Each resource type uses its own description structure, since
they each have a different set of available properties, but the structures all serve the same
purpose to define the desired characteristics of the created resource. These structures will
be investigated in detail in this chapter, and their proper configuration comprises the bulk
of the work required to make a resource do what you want it to. The second parameter in
the resource creation methods is a pointer to a D3D11_SUBRESOURCE_DATA structure,
which is used to provide the initial data to be loaded into a resource. For example, if a
buffer resource will hold static vertex data, this structure would be used to pass a model's
vertex data into the buffer. This eliminates the need to manually manipulate the buffer after
it is created, if its contents will not be changing. This parameter can also just be set to null
if no initialization is required. The final parameter is a pointer to a pointer to the appropriate
resource interface, which is where the created resource pointer is stored after a successful
resource creation event.
In each of these methods, the real configuration occurs in the resource description
structure. As mentioned above, each resource type has its own structure used to define its
properties. However, there are some common elements that are shared across all of the
structures. These include the usage flags, bind flags, CPU access flags, and miscellaneous
flags. Since these parameters are common across all the various resource types, we will
discuss them here in detail. The individual parameters that are unique to certain types of
resources will be discussed in their respective resource type sections later in this chapter.
Resource Usage Flags
The first resource parameter that we will inspect is the usage specification. Stated simply,
this parameter is used to specify what the application intends to do with the resource. In
general, we can consider a resource to be a block of memory somewhere within the com-
puter. Both video memory and system memory can hold resources, and resources can be
copied to and from each type of memory by the Direct3D 11 runtime. To optimize where
a resource resides and how it is handled internally by the runtime/driver, the application
must specify its intentions with this usage parameter. This differs from previous versions
of Direct3D, which allowed the user to specify the memory pool that the resource would
reside in. However, by indicating the usage intent of the resource, a similar level of control
is provided. The list of available values is encapsulated in the D3D11_USAGE enumeration,
which is shown in Listing 2.1.
Search WWH ::




Custom Search