Graphics Reference
In-Depth Information
// Create the buffer with the specified configuration
ID3DllBuffer* pBuffer = 0;
HRESULT hr = g_pDevice->CreateBuffer( &desc, pData, SpBuffer );
if ( FAILED( hr ) )
{
// Handle the error here...
return( 0 );
}
return( pBuffer );
}
Listing 2.14. A method for creating a buffer resource to be used as an append/consume buffer.
One can see that this is more or less one of the configurations that was already avail-
able for creating a buffer/structured buffer resource, with the exception that it is mandatory
to use the default usage flag. This means that the append/consume buffer usage does not
require a specially created buffer resource, but instead, it is the unordered access view that
must be specially configured to provide the additional functionality. The UAV used to bind
the buffer resource to the pipeline as an append/consume buffer must be created with the
D3D11_BUFFER_UAV_FLAG_APPEND flag specified in its description structure.
Resource view requirements. When creating the resource view to be used with the ap-
pend/consume buffer, there are a few differences from the previously discussed resource
views. The format parameter of the resource view must be set to DXGI_F0RMAT_R32_
UNKNOWN to use the append/consume functionality. In addition, the unordered access view
must be created with the D3Dll_BUFFER_UAV_FLAG_APPEND for both append and consume
buffers. These requirements are the only additional settings for creating an unordered ac-
cess view for using a buffer resource as an append/consume buffer.
As we have mentioned in previous buffer discussions, it is possible to simultaneously
use multiple resource views on the same resource. Unfortunately, this is not true for the
unordered access views. An entire buffer resource is
considered to be composed of a single subresource.
The unordered access views allow read and write ac-
cess to their resources, and are not allowed to have
more than one writable resource view attached to a
single subresource at the same time. This means that,
for example, it is not possible to use a single buffer
with two unordered access views to simultaneously
append and consume from different regions of the
buffer. In this case, the append and consume UAVs
would need to be attached to separate buffer resources
Figure 2.18. A single buffer resource
being used by multiple unordered ac-
cess views.
Search WWH ::




Custom Search