Skip to content

Commit b804b94

Browse files
refactor(dx12): extract copy_aligned in copy_texture_to_buffer
1 parent 8ea1569 commit b804b94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

wgpu-hal/src/dx12/command.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,11 @@ impl crate::CommandEncoder for super::CommandEncoder {
653653
) where
654654
T: Iterator<Item = crate::BufferTextureCopy>,
655655
{
656-
for r in regions {
657-
let list = self.list.as_ref().unwrap();
656+
let copy_aligned = |this: &mut Self,
657+
src: &super::Texture,
658+
dst: &super::Buffer,
659+
r: crate::BufferTextureCopy| {
660+
let list = this.list.as_ref().unwrap();
658661

659662
let src_location = Direct3D12::D3D12_TEXTURE_COPY_LOCATION {
660663
pResource: unsafe { borrow_interface_temporarily(&src.resource) },
@@ -675,6 +678,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
675678
unsafe {
676679
list.CopyTextureRegion(&dst_location, 0, 0, 0, &src_location, Some(&src_box))
677680
};
681+
};
682+
683+
for r in regions {
684+
copy_aligned(this, src, dst, r);
678685
}
679686
}
680687

0 commit comments

Comments
 (0)