ID3D12Device::CreateUnorderedAccessView method

Creates a view for unordered accessing.

Syntax


void CreateUnorderedAccessView(
  [in, optional]       ID3D12Resource                   *pResource,
  [in, optional]       ID3D12Resource                   *pCounterResource,
  [in, optional] const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc,
  [in]                 D3D12_CPU_DESCRIPTOR_HANDLE      DestDescriptor
);

Parameters

pResource [in, optional]

Type: ID3D12Resource*

A pointer to the ID3D12Resource object that represents the unordered access.

At least one of pResource or pDesc must be provided. A null pResource is used to initialize a null descriptor, which guarantees D3D11-like null binding behavior (reading 0s, writes are discarded), but must have a valid pDesc in order to determine the descriptor type.

pCounterResource [in, optional]

Type: ID3D12Resource*

The ID3D12Resource for the counter (if any) associated with the UAV.

If pCounterResource is not specified, the CounterOffsetInBytes member of the D3D12_BUFFER_UAV structure must be 0.

If pCounterResource is specified, then there is a counter associated with the UAV, and the runtime performs validation of the following requirements:

  • The StructureByteStride member of the D3D12_BUFFER_UAV structure must be greater than 0.
  • The format must be DXGI_FORMAT_UNKNOWN.
  • The D3D12_BUFFER_UAV_FLAG_RAW flag (a D3D12_BUFFER_UAV_FLAGS enumeration constant) must not be set.
  • Both of the resources (pResource and pCounterResource) must be buffers.
  • The CounterOffsetInBytes member of the D3D12_BUFFER_UAV structure must be a multiple of 4 bytes, and must be within the range of the counter resource.
  • pResource cannot be NULL
  • pDesc cannot be NULL.
pDesc [in, optional]

Type: const D3D12_UNORDERED_ACCESS_VIEW_DESC*

A pointer to a D3D12_UNORDERED_ACCESS_VIEW_DESC structure that describes the unordered-access view.

A null pDesc is used to initialize a default descriptor, if possible. This behavior is identical to the D3D11 null descriptor behavior, where defaults are filled in. This behavior inherits the resource format and dimension (if not typeless) and for buffers UAVs target a full buffer and are typed, and for textures UAVs target the first mip and all array slices. Not all resources support null descriptor initialization.

DestDescriptor [in]

Type: D3D12_CPU_DESCRIPTOR_HANDLE

Describes the CPU descriptor handle that represents the start of the heap that holds the unordered-access view.

Return value

Returns nothing.

Examples

The D3D12nBodyGravity sample uses ID3D12Device::CreateUnorderedAccessView as follows:

Describe and create an unordered access view.


D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
uavDesc.Buffer.FirstElement = 0;
uavDesc.Buffer.NumElements = ParticleCount;
uavDesc.Buffer.StructureByteStride = sizeof(Particle);
uavDesc.Buffer.CounterOffsetInBytes = 0;
uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE;

CD3DX12_CPU_DESCRIPTOR_HANDLE uavHandle0(m_srvUavHeap->GetCPUDescriptorHandleForHeapStart(), UavParticlePosVelo0 + index, m_srvUavDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE uavHandle1(m_srvUavHeap->GetCPUDescriptorHandleForHeapStart(), UavParticlePosVelo1 + index, m_srvUavDescriptorSize);
m_device->CreateUnorderedAccessView(m_particleBuffer0[index].Get(), nullptr, &uavDesc, uavHandle0);
m_device->CreateUnorderedAccessView(m_particleBuffer1[index].Get(), nullptr, &uavDesc, uavHandle1);


Refer to the Example Code in the D3D12 Reference.

Requirements

Header

D3D12.h

Library

D3D12.lib

DLL

D3D12.dll

See also

ID3D12Device

 

 

Show: