Graphics Reference
In-Depth Information
// For structured buffers, DXGI_FORMAT_UNKNOWN must be used!
// For standard buffers, utilize the appropriate format,
desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
desc.ViewDimension = D3D11_SRV_DIMENSI0N_BUFFER;
desc.Buffer.ElementOffset = 0;
desc. Buff er.ElementWidth = 100;
ID3DllShaderResourceView* pView = 0;
HRESULT hr = g_pDevice->CreateShaderResourceView( pResource, & desc,
&pView );
return ( pView );
Listing 2.1 1 . A method for creating a shader resource view for a buffer resource.
By adjusting the ElementOffset and ElementWidth parameters, a single large buffer
resource can be used to contain a collection of smaller datasets, each with its own SRV, to
provide access to them. By using the shader resource view to restrict access to a particular
subset of the resource and creating an appropriate number of shader resource views, the
application can effectively control which data is visible to each invocation of a shader
program by using a particular shader resource view. It is also possible to use more than one
view to simultaneously select different ranges of a buffer.
The unordered access view uses the same element range selection and format speci-
fication, and also provides an additional set of flags that can be specified for special-use
scenarios. These flags enable the unordered access view to be used for append/consume
buffers and byte address buffers, both of which are specialized ways to use buffer resources
through unordered access views. The specific details of how these function are discussed
in more detail in the following two sections. Listing 2.12 demonstrates how to create an
unordered access view.
ID3D11UnorderedAccessView* CreateBufferUAV( ID3DllResource* pResource )
{
D3D11_UN0RDERED_ACCESS_VIEW_DESC desc;
// For structured buffers, DXGI_FORMAT_UNKNOWN must be used!
// For standard buffers, utilize the appropriate format,
desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
desc.ViewDimension = D3D11_UAV_DIMENSI0N_BUFFER;
desc.Buffer.FirstElement = 0;
desc.Buffer.NumElements = 100;
desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_C0UNTER;
//desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_APPEND;
//desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_RAW;
Search WWH ::




Custom Search