d3d11: Fix texture format view reinterpretation
Bug: dawn:1810
Bug: dawn:1705
Change-Id: I2e50c90a8cc7293bce4c1409bf4d4f468bb4fb2d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/137206
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp
index 1c5b975..ed6c981 100644
--- a/src/dawn/native/d3d11/TextureD3D11.cpp
+++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -197,6 +197,8 @@
// To sample from a depth or stencil texture, we need to create a typeless texture.
bool needsTypelessFormat =
GetFormat().HasDepthOrStencil() && (GetUsage() & wgpu::TextureUsage::TextureBinding);
+ // We need to use the typeless format if view format reinterpretation is required.
+ needsTypelessFormat |= GetViewFormats().any();
desc.Format = needsTypelessFormat ? d3d::DXGITypelessTextureFormat(GetFormat().format)
: d3d::DXGITextureFormat(GetFormat().format);
desc.Usage = mIsStaging ? D3D11_USAGE_STAGING : D3D11_USAGE_DEFAULT;
diff --git a/src/dawn/tests/end2end/TextureViewTests.cpp b/src/dawn/tests/end2end/TextureViewTests.cpp
index e2e918b..68174bf 100644
--- a/src/dawn/tests/end2end/TextureViewTests.cpp
+++ b/src/dawn/tests/end2end/TextureViewTests.cpp
@@ -442,9 +442,6 @@
// TODO(crbug.com/dawn/1360): OpenGLES doesn't support view format reinterpretation.
DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
- // TODO(dawn:1810): D3D11 doesn't support view format reinterpretation.
- DAWN_SUPPRESS_TEST_IF(IsD3D11());
-
wgpu::TextureViewDescriptor viewDesc = {};
viewDesc.format = wgpu::TextureFormat::RGBA8UnormSrgb;
@@ -776,9 +773,6 @@
// TODO(crbug.com/dawn/1360): OpenGLES doesn't support view format reinterpretation.
DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
- // TODO(dawn:1810): D3D11 doesn't support view format reinterpretation.
- DAWN_SUPPRESS_TEST_IF(IsD3D11());
-
// Test will render into an SRGB view
wgpu::TextureViewDescriptor viewDesc = {};
viewDesc.format = wgpu::TextureFormat::RGBA8UnormSrgb;
@@ -885,9 +879,6 @@
// TODO(crbug.com/dawn/1360): OpenGLES doesn't support view format reinterpretation.
DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
- // TODO(dawn:1810): D3D11 doesn't support view format reinterpretation.
- DAWN_SUPPRESS_TEST_IF(IsD3D11());
-
// Test will resolve into an SRGB view
wgpu::TextureViewDescriptor viewDesc = {};
viewDesc.format = wgpu::TextureFormat::RGBA8UnormSrgb;