From 4a88a3287eaedb947eaec06ebe14e362dab875d8 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 21 Feb 2023 23:14:46 +0000 Subject: [PATCH] D3D12: derive T2T workaround from TextureCopyBetweenDimensionsSupported Query D3D12_FEATURE_DATA_D3D12_OPTIONS13 to determine whether the device supports copies between textures of different dimensions. If it does not, or if D3D12_FEATURE_D3D12_OPTIONS13 is not supported, force enable toggle D3D12UseTempBufferInTextureToTextureCopyBetweenDifferentDimensions. Fixed: dawn:1216 Change-Id: I976e7fad291126f8dcee31ce6b681314d38e69e7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120882 Reviewed-by: Corentin Wallez Commit-Queue: Austin Eng Kokoro: Kokoro Auto-Submit: Austin Eng --- src/dawn/native/d3d12/AdapterD3D12.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dawn/native/d3d12/AdapterD3D12.cpp b/src/dawn/native/d3d12/AdapterD3D12.cpp index e7808cbc78..0478b8ce50 100644 --- a/src/dawn/native/d3d12/AdapterD3D12.cpp +++ b/src/dawn/native/d3d12/AdapterD3D12.cpp @@ -554,10 +554,18 @@ void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { deviceToggles->ForceSet(Toggle::NoWorkaroundDstAlphaBlendDoesNotWork, true); } - // TODO(http://crbug.com/dawn/1216): Actually query D3D12_FEATURE_DATA_D3D12_OPTIONS13. - // This is blocked on updating the Windows SDK. - deviceToggles->ForceSet( - Toggle::D3D12UseTempBufferInTextureToTextureCopyBetweenDifferentDimensions, true); + D3D12_FEATURE_DATA_D3D12_OPTIONS13 featureData13; + if (FAILED(mD3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS13, &featureData13, + sizeof(featureData13)))) { + // If the platform doesn't support D3D12_FEATURE_D3D12_OPTIONS13, default initialize the + // struct to set all features to false. + featureData13 = {}; + } + + if (!featureData13.TextureCopyBetweenDimensionsSupported) { + deviceToggles->ForceSet( + Toggle::D3D12UseTempBufferInTextureToTextureCopyBetweenDifferentDimensions, true); + } } ResultOrError> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor,