Implement the optional feature "bgra8unorm-storage" on D3D12 This patch adds the support of the optional feature "bgra8unorm-storage" on D3D12 when the platform allows using DXGI_FORMAT_B8G8R8A8_UNORM as UAVs. According to D3D12 documents, enabling the flag D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS when creating textures requires "either the texture format must support unordered access capabilities at the current feature level. Or, when the format is a typeless format, a format within the same typeless group must support unordered access capabilities at the current feature level". Bug: dawn:1641 Test: dawn_end2end_tests Change-Id: If16271b5da52423e73ad4f7ba258af83dbf66dd2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119345 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/d3d12/AdapterD3D12.cpp b/src/dawn/native/d3d12/AdapterD3D12.cpp index 5104d80..aa6492a 100644 --- a/src/dawn/native/d3d12/AdapterD3D12.cpp +++ b/src/dawn/native/d3d12/AdapterD3D12.cpp
@@ -156,6 +156,15 @@ mSupportedFeatures.EnableFeature(Feature::ShaderF16); } } + + D3D12_FEATURE_DATA_FORMAT_SUPPORT bgra8unormFormatInfo = {}; + bgra8unormFormatInfo.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + HRESULT hr = mD3d12Device->CheckFeatureSupport( + D3D12_FEATURE_FORMAT_SUPPORT, &bgra8unormFormatInfo, sizeof(bgra8unormFormatInfo)); + if (SUCCEEDED(hr) && + (bgra8unormFormatInfo.Support1 & D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW)) { + mSupportedFeatures.EnableFeature(Feature::BGRA8UnormStorage); + } } MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {