ID3D11UnorderedAccessView
Represents an unordered-access view of a resource. Unordered-access views allow read-and-write access to a resource from shaders.
Inheritance
The ID3D11UnorderedAccessView
interface inherits from ID3D11View
.
Members
The ID3D11UnorderedAccessView
interface does not define any new members beyond those inherited from ID3D11View
.
Remarks
Unordered-access views can be created from the following resource types:
To create an unordered-access view, use the D3D11CreateUnorderedAccessView
function or the CreateUnorderedAccessView
method of ID3D11Device
.
An unordered-access view is defined by a D3D11_UNORDERED_ACCESS_VIEW_DESC
structure, which specifies the resource, view dimension, format, and other view parameters.
Note
Unordered access allows for non-sequential access patterns, which are ideal for compute shaders performing complex simulations, particle systems, or data processing where access order is not guaranteed or important.
Example Usage
Creating an unordered-access view for a buffer:
// Assume pDevice is a valid ID3D11Device pointer
// Assume pBuffer is a valid ID3D11Buffer pointer representing a buffer intended for UAV use
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
uavDesc.Format = DXGI_FORMAT_R32_UINT; // Example format
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
uavDesc.Buffer.FirstElement = 0;
uavDesc.Buffer.NumElements = 1024; // Number of elements in the buffer
ID3D11UnorderedAccessView* pUAV = nullptr;
HRESULT hr = pDevice->CreateUnorderedAccessView(pBuffer, &uavDesc, &pUAV);
if (SUCCEEDED(hr))
{
// pUAV is now a valid unordered-access view
// You can bind it to the pipeline using ID3D11DeviceContext::CSSetUnorderedAccessViews or OMSetRenderTargetsAndUnorderedAccessViews
}
else
{
// Handle error
}
// Remember to release the UAV when done
// if (pUAV) pUAV->Release();
Key Concepts
- Atomic Operations: Unordered-access views support atomic operations like
InterlockedAdd
,InterlockedCompareExchange
, etc., allowing thread-safe modifications. - Shader Binding: UAVs are bound to the compute shader stage or the output merger stage using specific context methods.
- Resource Compatibility: The format and dimensions of the view must be compatible with the underlying resource.