D3D12: Never select full subresource range for Stencil8 textures
This patch fixes the subresource range of Stencil8 textures on D3D12
backends. On D3D12 backend Stencil8 is implemented by a depth-stencil
format, while through WebGPU API we can only choose the stencil aspect
of the Stencil8 textures, so actually we cannot select the full
subresource range for Stencil8 textures in the D3D12 transition barrier.
Bug: dawn:1273
Fixed: dawn:1835
Change-Id: I8986f353de9d6823a9d68d06554b793b35ed3844
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/145401
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp
index 0e17279..97b4e6e 100644
--- a/src/dawn/native/d3d12/TextureD3D12.cpp
+++ b/src/dawn/native/d3d12/TextureD3D12.cpp
@@ -540,10 +540,13 @@
barrier.Transition.StateBefore = lastState;
barrier.Transition.StateAfter = newState;
- bool isFullRange = range.baseArrayLayer == 0 && range.baseMipLevel == 0 &&
- range.layerCount == GetArrayLayers() &&
- range.levelCount == GetNumMipLevels() &&
- range.aspects == GetFormat().aspects;
+ // Currently Stencil8 is implemented with DXGI_FORMAT_D24_UNORM_S8_UINT, while we can only
+ // choose the stencil aspect for Stencil8 textures, so actually we cannot select the full
+ // subresource range on the Stencil8 textures.
+ bool isFullRange =
+ range.baseArrayLayer == 0 && range.baseMipLevel == 0 &&
+ range.layerCount == GetArrayLayers() && range.levelCount == GetNumMipLevels() &&
+ range.aspects == GetFormat().aspects && GetFormat().format != wgpu::TextureFormat::Stencil8;
// Use a single transition for all subresources if possible.
if (isFullRange) {
diff --git a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
index 17db845..647986e 100644
--- a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
+++ b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
@@ -890,10 +890,6 @@
uint32_t textureArrayLayerCount,
uint32_t testLevel,
bool checkBufferContent) {
- // TODO(crbug.com/dawn/1835): ResourceBarrier state mismatch.
- DAWN_SUPPRESS_TEST_IF(textureArrayLayerCount > 1 && IsD3D12() &&
- IsBackendValidationEnabled());
-
// TODO(crbug.com/dawn/667): Work around the fact that some platforms are unable to read
// stencil.
DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("disable_depth_stencil_read"));
@@ -957,9 +953,6 @@
DAWN_TEST_UNSUPPORTED_IF(IsOpenGL());
DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
- // TODO(crbug.com/dawn/1273): Fails on Win11 with D3D12 debug layer and full validation
- DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsBackendValidationEnabled());
-
// Create a stencil texture
constexpr uint32_t kWidth = 4;
constexpr uint32_t kHeight = 4;