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;