Fix ValidateEntireSubresourceCopied

This function was validating the depth of the copy which is
incorrect for 2D array textures. Remove this check for now
since it would be only relevant for 3D textures which Dawn
does not support yet.

Bug: dawn:424
Change-Id: I756080a899a7c5effe5843a530d4db0571bc10d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22323
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp
index db0271b..6c1df3a 100644
--- a/src/dawn_native/CommandEncoder.cpp
+++ b/src/dawn_native/CommandEncoder.cpp
@@ -145,9 +145,10 @@
                                                    const Extent3D& copySize) {
             Extent3D srcSize = src.texture->GetSize();
 
+            ASSERT(src.texture->GetDimension() == wgpu::TextureDimension::e2D &&
+                   dst.texture->GetDimension() == wgpu::TextureDimension::e2D);
             if (dst.origin.x != 0 || dst.origin.y != 0 || dst.origin.z != 0 ||
-                srcSize.width != copySize.width || srcSize.height != copySize.height ||
-                srcSize.depth != copySize.depth) {
+                srcSize.width != copySize.width || srcSize.height != copySize.height) {
                 return DAWN_VALIDATION_ERROR(
                     "The entire subresource must be copied when using a depth/stencil texture or "
                     "when samples are greater than 1.");
diff --git a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp
index 917446b..ffade8b 100644
--- a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp
+++ b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp
@@ -1157,6 +1157,45 @@
                 {15, 15, 1});
 }
 
+TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
+    {
+        wgpu::Texture source = Create2DTexture(16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8,
+                                           wgpu::TextureUsage::CopySrc);
+        wgpu::Texture destination = Create2DTexture(
+            16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
+
+        // Success when entire depth stencil subresource (layer) is the copy source
+        TestT2TCopy(utils::Expectation::Success, source, 0, 1, {0, 0, 0}, destination, 0, 0, {0, 0, 0},
+                    {16, 16, 1});
+    }
+
+    {
+        wgpu::Texture source = Create2DTexture(16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8,
+                                           wgpu::TextureUsage::CopySrc);
+        wgpu::Texture destination = Create2DTexture(
+            16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
+
+        // Success when entire depth stencil subresource (layer) is the copy destination
+        TestT2TCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0, 1, {0, 0, 0},
+                    {16, 16, 1});
+    }
+
+    {
+        wgpu::Texture source = Create2DTexture(16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8,
+                                           wgpu::TextureUsage::CopySrc);
+        wgpu::Texture destination = Create2DTexture(
+            16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
+
+        // Success when src and dst are an entire depth stencil subresource (layer)
+        TestT2TCopy(utils::Expectation::Success, source, 0, 2, {0, 0, 0}, destination, 0, 1, {0, 0, 0},
+                    {16, 16, 1});
+
+        // Success when src and dst are an array of entire depth stencil subresources
+        TestT2TCopy(utils::Expectation::Success, source, 0, 1, {0, 0, 0}, destination, 0, 0, {0, 0, 0},
+                    {16, 16, 2});
+    }
+}
+
 TEST_F(CopyCommandTest_T2T, FormatsMismatch) {
     wgpu::Texture source =
         Create2DTexture(16, 16, 5, 2, wgpu::TextureFormat::RGBA8Uint, wgpu::TextureUsage::CopySrc);