Typed Unordered Access View Loads

Unordered Access View (UAV) Typed Load is the ability for a shader to read from a UAV with a specific DXGI_FORMAT.

Overview

An unordered access view (UAV) is a view of an unordered access resource (which can include buffers, textures, and texture arrays, though without multi-sampling). A UAV allows temporally unordered read/write access from multiple threads. This means that this resource type can be read/written simultaneously by multiple threads without generating memory conflicts. This simultaneous access is handled through the use of Atomic Functions.

D3D12 and D3D11.3 expands on the list of formats that can be used with typed UAV loads.

Supported formats and API calls

Previously, the following three formats supported typed UAV loads, and were required for D3D11.0 hardware. They are supported for all D3D11.3 and D3D12 hardware.

  • R32_FLOAT
  • R32_UINT
  • R32_SINT

The following formats are supported as a set on D3D12 or D3D11.3 hardware, so if any one is supported, all are supported.

  • R32G32B32A32_FLOAT
  • R32G32B32A32_UINT
  • R32G32B32A32_SINT
  • R16G16B16A16_FLOAT
  • R16G16B16A16_UINT
  • R16G16B16A16_SINT
  • R8G8B8A8_UNORM
  • R8G8B8A8_UINT
  • R8G8B8A8_SINT
  • R16_FLOAT
  • R16_UINT
  • R16_SINT
  • R8_UNORM
  • R8_UINT
  • R8_SINT

The following formats are optionally and individually supported on D3D12 and D3D11.3 hardware, so a single query would need to be made on each format to test for support.

  • R16G16B16A16_UNORM
  • R16G16B16A16_SNORM
  • R32G32_FLOAT
  • R32G32_UINT
  • R32G32_SINT
  • R10G10B10A2_UNORM
  • R10G10B10A2_UINT
  • R11G11B10_FLOAT
  • R8G8B8A8_SNORM
  • R16G16_FLOAT
  • R16G16_UNORM
  • R16G16_UINT
  • R16G16_SNORM
  • R16G16_SINT
  • R8G8_UNORM
  • R8G8_UINT
  • R8G8_SNORM
  • 8G8_SINT
  • R16_UNORM
  • R16_SNORM
  • R8_SNORM
  • A8_UNORM
  • B5G6R5_UNORM
  • B5G5R5A1_UNORM
  • B4G4R4A4_UNORM

To determine the support for any additional formats, call ID3D11Device::CheckFeatureSupport with the D3D11_FEATURE_DATA_D3D11_OPTIONS2 structure as the first parameter. The TypedUAVLoadAdditionalFormats bit will be set if the "supported as a set" list above is supported. Make a second call to CheckFeatureSupport, using a D3D11_FEATURE_DATA_FORMAT_SUPPORT2 structure (checking the returned structure against the D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD member of the D3D11_FORMAT_SUPPORT2 enum) to determine support in the list of optionally supported formats above, for example:

D3D11_FEATURE_DATA_D3D11_OPTIONS2 FeatureData;
ZeroMemory(&FeatureData, sizeof(FeatureData));
HRESULT hr = pDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS2, &FeatureData, sizeof(FeatureData));
if (SUCCEEDED(hr))
{
    // TypedUAVLoadAdditionalFormats contains a Boolean that tells you whether the feature is supported or not
    if (FeatureData.TypedUAVLoadAdditionalFormats)
    {
        // Can assume “all-or-nothing” subset is supported (e.g. R32G32B32A32_FLOAT)
        // Cannot assume other formats are supported, so we check:
        D3D11_FEATURE_DATA_FORMAT_SUPPORT2 FormatSupport;
        ZeroMemory(&FormatSupport, sizeof(FormatSupport));
        FormatSupport.InFormat = DXGI_FORMAT_R32G32_FLOAT;
        hr = pDevice->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT2, &FormatSupport, sizeof(FormatSupport));
        if (SUCCEEDED(hr) && (FormatSupport.OutFormatSupport2 & D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD) != 0)
        {
            // DXGI_FORMAT_R32G32_FLOAT supports UAV Typed Load!
        }
    }
}

Using typed UAV loads from HLSL

For typed UAVs, the HLSL flag is D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS.

Here is example shader code to process a typed UAV load:

RWTexture2D<float4> uav1;
uint2 coord;
float4 main() : SV_Target
{
  return uav1.Load(coord);
}

Direct3D 11.3 Features

Shader Model 5.1