Graphics Reference
In-Depth Information
must declare the appropriate resource object to interact with the buffers. There are two dif-
ferent objects that can be declared, each of which corresponds to the type of access that the
HLSL code will have to the resource. If the buffer is bound to the pipeline with a shader
resource view, the corresponding HLSL object will be declared as a ByteAddressBuffer. If
it is bound to the pipeline with an unordered access view, the corresponding HLSL object
will be declared as a RWByteAddressBuffer. Samples of these byte address buffer type
declarations are provided in Listing 2.17.
ByteAddressBuffer rawBufferl
RWByteAddressBuffer rawBuffer2j
Listing 2.17. Declaring byte address buffers in HLSL.
In general, the methods of these objects require an address to specify the location
within the buffer at which to perform the given operation. These addresses must be 4-byte
aligned, and always work with the uint data type. If other data types are required, the
returned data can be reinterpreted using one of the conversion intrinsic methods. 2 Each
of these two objects support the various Load methods that can be used to retrieve data from
the buffer resource, and up to four 32-bit memory locations can be read at a time. However,
the read/write byte address buffer also provides a large array of methods for manipulating the
contents of the buffer. There are the simple Store analogs to the Load methods, in addition to
a host of atomic instructions for updating the resource simultaneously from many threads.
Indirect Argument Buffers
The final buffer configuration that we will inspect is the indirect argument buffer. As we
will see in many cases throughout this topic, Direct3D 11 has taken many steps toward
making the GPU more useful and able to operate on its own. The indirect argument buf-
fer is one of these steps. It is used to provide parameters to the rendering and computation
pipeline invocation methods from within a resource, instead of having those parameters
directly passed by the host program. The concept behind allowing this type of pipeline
control is to allow the GPU to generate the needed geometry or input data resources in one
execution pass, and to then process or render that data in a following pass, without the CPU
having any knowledge of how many primitives are being processed. Even though the CPU
must still initiate the pipeline execution and pass the indirect argument buffer reference,
this scenario reduces the CPU's role to a simple broker between GPU passes.
Using indirect argument buffers. Indirect argument buffers can be used in several differ-
ent pipeline execution methods. We haven't covered the pipeline execution in detail yet,
2 The conversion intrinsic methods are discussed in Chapter 6, "High Level Shading Language."
Search WWH ::




Custom Search