Training
Module
Declare variable types in TypeScript - Training
Learn about the available types and how to associate them with variables.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Unordered Access View (UAV) Typed Load is the ability for a shader to read from a UAV with a specific DXGI_FORMAT.
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.
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.
The following formats are supported as a set on D3D12 or D3D11.3 hardware, so if any one is supported, all are supported.
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.
To determine the support for any additional formats, call CheckFeatureSupport with the D3D12_FEATURE_DATA_D3D12_OPTIONS structure as the first parameter (refer to Capability Querying). The TypedUAVLoadAdditionalFormats field will be set if the "supported as a set" list above is supported. Make a second call to CheckFeatureSupport, using a D3D12_FEATURE_DATA_FORMAT_SUPPORT structure (checking the returned structure against the D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD member of the D3D12_FORMAT_SUPPORT2 enum) to determine support in the list of optionally supported formats listed above, for example:
D3D12_FEATURE_DATA_D3D12_OPTIONS FeatureData;
ZeroMemory(&FeatureData, sizeof(FeatureData));
HRESULT hr = pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &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:
D3D12_FEATURE_DATA_FORMAT_SUPPORT FormatSupport = {DXGI_FORMAT_R32G32_FLOAT, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE};
hr = pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &FormatSupport, sizeof(FormatSupport));
if (SUCCEEDED(hr) && (FormatSupport.Support2 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD) != 0)
{
// DXGI_FORMAT_R32G32_FLOAT supports UAV Typed Load!
}
}
}
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);
}
When using typed UAV loads to read from a UNORM or SNORM resource, you must properly declare the element type of the HLSL object to be unorm
or snorm
. It is specified as undefined behavior to mismatch the element type declared in HLSL with the underlying resource data type. For example, if you are using typed UAV loads on a buffer resource with R8_UNORM data, then you must declare the element type as unorm float
:
RWBuffer<unorm float> uav;
Training
Module
Declare variable types in TypeScript - Training
Learn about the available types and how to associate them with variables.