From 15cbb6b76ab031142ffe4a1423acf609cab45be5 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Wed, 10 Jun 2020 21:38:50 +0000 Subject: [PATCH] Enable CopyTests_T2T/CopyWithinSameTexture* tests on D3D12 This patch enables the tests CopyTests_T2T/CopyWithinSameTexture* on D3D12 after the D3D12 texture subresource tracking has been supported. This patch also changes the related comment in Vulkan as WebGPU CG has already decided to disallow the overlaps among source and destination subresources in texture-to-texture copies. BUG=dawn:453 TEST=dawn_end2end_tests Change-Id: Ibf008c800cfea62658050f565f321a391412c54c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23000 Commit-Queue: Kai Ninomiya Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya --- src/dawn_native/d3d12/CommandBufferD3D12.cpp | 12 ++++++++++++ src/dawn_native/vulkan/CommandBufferVk.cpp | 2 +- src/tests/end2end/CopyTests.cpp | 8 +------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 86254d781f..9c57c29e96 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -17,6 +17,7 @@ #include "common/Assert.h" #include "dawn_native/BindGroupAndStorageBarrierTracker.h" #include "dawn_native/CommandEncoder.h" +#include "dawn_native/CommandValidation.h" #include "dawn_native/Commands.h" #include "dawn_native/RenderBundle.h" #include "dawn_native/d3d12/BindGroupD3D12.h" @@ -689,6 +690,17 @@ namespace dawn_native { namespace d3d12 { commandContext, copy->destination.mipLevel, 1, copy->destination.arrayLayer, copy->copySize.depth); } + + if (copy->source.texture.Get() == copy->destination.texture.Get() && + copy->source.mipLevel == copy->destination.mipLevel) { + // When there are overlapped subresources, the layout of the overlapped + // subresources should all be COMMON instead of what we set now. Currently + // it is not allowed to copy with overlapped subresources, but we still + // add the ASSERT here as a reminder for this possible misuse. + ASSERT(!IsRangeOverlapped(copy->source.arrayLayer, + copy->destination.arrayLayer, + copy->copySize.depth)); + } source->TrackUsageAndTransitionNow( commandContext, wgpu::TextureUsage::CopySrc, copy->source.mipLevel, 1, copy->source.arrayLayer, copy->copySize.depth); diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp index 54c06860a3..b306660468 100644 --- a/src/dawn_native/vulkan/CommandBufferVk.cpp +++ b/src/dawn_native/vulkan/CommandBufferVk.cpp @@ -528,7 +528,7 @@ namespace dawn_native { namespace vulkan { // When there are overlapped subresources, the layout of the overlapped // subresources should all be GENERAL instead of what we set now. Currently // it is not allowed to copy with overlapped subresources, but we still - // add the ASSERT here as a reminder for possible changes in the future. + // add the ASSERT here as a reminder for this possible misuse. ASSERT(!IsRangeOverlapped(src.arrayLayer, dst.arrayLayer, copy->copySize.depth)); } diff --git a/src/tests/end2end/CopyTests.cpp b/src/tests/end2end/CopyTests.cpp index d450fab6ed..0f9207601d 100644 --- a/src/tests/end2end/CopyTests.cpp +++ b/src/tests/end2end/CopyTests.cpp @@ -769,10 +769,6 @@ TEST_P(CopyTests_T2T, Texture2DArrayCopyMultipleSlices) { // Test copying one texture slice within the same texture. TEST_P(CopyTests_T2T, CopyWithinSameTextureOneSlice) { - // TODO(jiawei.shao@intel.com): support texture-to-texture copy within same texture on D3D12 - // after D3D12 subresource tracking is implemented. - DAWN_SKIP_TEST_IF(IsD3D12()); - constexpr uint32_t kWidth = 256u; constexpr uint32_t kHeight = 128u; constexpr uint32_t kLayers = 6u; @@ -788,9 +784,7 @@ TEST_P(CopyTests_T2T, CopyWithinSameTextureOneSlice) { // slices. TEST_P(CopyTests_T2T, CopyWithinSameTextureNonOverlappedSlices) { // TODO(jiawei.shao@intel.com): investigate why this test fails with swiftshader. - // TODO(jiawei.shao@intel.com): support texture-to-texture copy within same texture on D3D12 - // after D3D12 subresource tracking is implemented. - DAWN_SKIP_TEST_IF(IsSwiftshader() || IsD3D12()); + DAWN_SKIP_TEST_IF(IsSwiftshader()); constexpr uint32_t kWidth = 256u; constexpr uint32_t kHeight = 128u;