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>
This commit is contained in:
Jiawei Shao 2023-02-14 00:29:52 +00:00 committed by Dawn LUCI CQ
parent 01456d97ea
commit 7c2fa23a7e
1 changed files with 9 additions and 0 deletions

View File

@ -156,6 +156,15 @@ void Adapter::InitializeSupportedFeaturesImpl() {
mSupportedFeatures.EnableFeature(Feature::ShaderF16); 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) { MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {