Skip to content

Commit fc1ee23

Browse files
committed
Fix CopyT2T of multi-layer depth/stencil textures
1 parent 2d8fcb2 commit fc1ee23

File tree

2 files changed

+31
-38
lines changed

2 files changed

+31
-38
lines changed

cts_runner/test.lst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
unittests:*
22
webgpu:api,operation,command_buffer,basic:*
33
webgpu:api,operation,command_buffer,copyBufferToBuffer:*
4+
fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth24plus"
5+
fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth24plus-stencil8"
6+
fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth16unorm"
7+
fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth32float"
8+
fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth32float-stencil8"
9+
webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="stencil8"
410
webgpu:api,operation,command_buffer,image_copy:offsets_and_sizes:*
511
webgpu:api,operation,compute,basic:memcpy:*
612
//FAIL: webgpu:api,operation,compute,basic:large_dispatch:*

wgpu-core/src/command/transfer.rs

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloc::{format, string::String, sync::Arc, vec, vec::Vec};
1+
use alloc::{format, string::String, sync::Arc, vec::Vec};
22

33
use arrayvec::ArrayVec;
44
use thiserror::Error;
@@ -1337,45 +1337,32 @@ impl Global {
13371337
height: src_copy_size.height.min(dst_copy_size.height),
13381338
depth: src_copy_size.depth.min(dst_copy_size.depth),
13391339
};
1340+
1341+
let regions = (0..array_layer_count).map(|rel_array_layer| {
1342+
let mut src_base = src_tex_base.clone();
1343+
let mut dst_base = dst_tex_base.clone();
1344+
src_base.array_layer += rel_array_layer;
1345+
dst_base.array_layer += rel_array_layer;
1346+
hal::TextureCopy {
1347+
src_base,
1348+
dst_base,
1349+
size: hal_copy_size,
1350+
}
1351+
});
1352+
13401353
let regions = if dst_tex_base.aspect == hal::FormatAspects::DEPTH_STENCIL {
1341-
vec![
1342-
hal::TextureCopy {
1343-
src_base: hal::TextureCopyBase {
1344-
aspect: hal::FormatAspects::DEPTH,
1345-
..src_tex_base
1346-
},
1347-
dst_base: hal::TextureCopyBase {
1348-
aspect: hal::FormatAspects::DEPTH,
1349-
..dst_tex_base
1350-
},
1351-
size: hal_copy_size,
1352-
},
1353-
hal::TextureCopy {
1354-
src_base: hal::TextureCopyBase {
1355-
aspect: hal::FormatAspects::STENCIL,
1356-
..src_tex_base
1357-
},
1358-
dst_base: hal::TextureCopyBase {
1359-
aspect: hal::FormatAspects::STENCIL,
1360-
..dst_tex_base
1361-
},
1362-
size: hal_copy_size,
1363-
},
1364-
]
1365-
} else {
1366-
(0..array_layer_count)
1367-
.map(|rel_array_layer| {
1368-
let mut src_base = src_tex_base.clone();
1369-
let mut dst_base = dst_tex_base.clone();
1370-
src_base.array_layer += rel_array_layer;
1371-
dst_base.array_layer += rel_array_layer;
1372-
hal::TextureCopy {
1373-
src_base,
1374-
dst_base,
1375-
size: hal_copy_size,
1376-
}
1354+
regions
1355+
.flat_map(|region| {
1356+
let (mut depth, mut stencil) = (region.clone(), region);
1357+
depth.src_base.aspect = hal::FormatAspects::DEPTH;
1358+
depth.dst_base.aspect = hal::FormatAspects::DEPTH;
1359+
stencil.src_base.aspect = hal::FormatAspects::STENCIL;
1360+
stencil.dst_base.aspect = hal::FormatAspects::STENCIL;
1361+
[depth, stencil]
13771362
})
1378-
.collect()
1363+
.collect::<Vec<_>>()
1364+
} else {
1365+
regions.collect::<Vec<_>>()
13791366
};
13801367
let cmd_buf_raw = cmd_buf_data.encoder.open()?;
13811368
unsafe {

0 commit comments

Comments
 (0)