Graphics Reference
In-Depth Information
enum D3D11_USAGE {
D3D11_USAGE_DEFAULT,
D3D11_USAGE_IMMUTABLE,
D3D11_USA6E_DYNAMIC,
D3D11JJSAGE_STAGING
}
Listing 2.1. The D3D11_USAGE enumeration.
Each of these flags indicates one usage pattern, which identifies the required read/
write capabilities of the resource for both the CPU and the GPU. For example, a resource
that is only read and written by the GPU and is never accessed by the CPU can be safely
placed in video memory. It will never be transferred back to system memory, since the CPU
is not able to access it. This provides an optimization by keeping the resource closer to the
GPU. Table 2.1 shows the read/write permissions for each of these flags.
Resource Usage
Default
Dynamic
Immutable
Staging
GPU-Read
yes
yes
yes
yes
GPU-Write
yes
yes
CPU-Read
yes
CPU-Write
yes
yes
Table 2.1. The accessibility defined for each usage flag.
Immutable usage. The simplest usage pattern is the immutable usage. A resource created
with this usage pattern can only be read by the GPU and is not accessible by the CPU.
Since the resource can't be written to by the GPU or CPU, it can't be modified after it is
created. This requires that the resource be initialized with its data at creation time. Since the
resource can't be modified, the usage type's name is appropriately immutable. Common
examples of this resource type are static constant, vertex, and index buffers that are created
with data that won't change over the lifetime of the application. In general, these resources
are used to provide data to the GPU.
Default usage. As can be seen in the table above, the default usage provides read and write
access to the GPU, but provides no access to the CPU. This is the most optimal usage set-
ting for any resources that will not only be used by the GPU, but that will also be modified
by the GPU at some point. Some common examples of this usage pattern are render tex-
tures (which are rendered into the GPU and subsequently read from it), and stream output
vertex buffers (which have data streamed into them by the GPU and are later read by the
Search WWH ::




Custom Search