Graphics Reference
In-Depth Information
ByteAddressBuffer
The ByteAddressBuffer type allows access to a buffer using a byte offset, rather than an
index. This functionality is exposed through the Load, Load2, Load3, and Load4 methods,
which return 1, 2, 3, or 4 uint values, respectively. Since those methods only return type
uint, buffers containing other types of data must have the return value manually converted
using one of the conversion/casting intrinsics.
StructuredBuffer
A StructuredBuffer provides read-only access to a buffer containing elements defined by
a structure, as opposed to the regular Buffer type, which can only access types correspond-
ing to DXGI_FORMAT values. The structure must be declared in HLSL as a struct, and that
type must be specified as the template argument when declaring the StructuredBuffer
object.
Read/Write Buffers
Read/Write buffers allow random-access reads and writes to buffer resources. Since the
reads and writes are not automatically synchronized by the device, synchronization in-
trinsics or atomics must be used to control memory access across threads. By default,
a synchronization intrinsic will only cause a write to flush across that thread group. In
order for the write to be flushed across the entire GPU, the buffer declaration must use
the globallycoherent prefix.
The three types of read/write buffers are RWBuffer, RWByteAddressBuffer, and
RWStructuredBuf f er. For reads, they behave exactly like their read-only equivalents, and
use the same methods. For writing to memory, the array operator can be used for RWBuffer
and RWStructuredBuffer, while RWByteAddressBuffer provides the Store, Store2,
Store3, and Store4 methods. RWByteAddressBuffer also provides a set of interlocked
methods that allow atomic operations to be performed on the contents of the resource. For
a RWStructuredBuffer that contains a hidden counter (which is the case for structured
buffer resources created with the D3D11_BUFFER_UAV_FLAG_C0UNTER flag), it can be incre-
mented or decremented with IncrementCounter and DecrementCounter. See Chapter 2
for more details on structured buffer resources.
6.5.2 Append/Consume Buffers
Append and consume buffers allow adding and removing of values from a resource in
a pixel or compute shader. The addition and-removal operations are done at the end of a
buffer, causing it to behave somewhat like a stack. However unlike traditional stacks, the
Search WWH ::




Custom Search