From ce69059fdf9a7829bb6864fd88e880c1d5715af1 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 23 May 2025 17:06:29 -0400 Subject: [PATCH] refactor(dx12): extract `copy_aligned` in `copy_texture_to_buffer` --- wgpu-hal/src/dx12/command.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index efa77918e..e3d9e3ae0 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -653,8 +653,11 @@ impl crate::CommandEncoder for super::CommandEncoder { ) where T: Iterator, { - for r in regions { - let list = self.list.as_ref().unwrap(); + let copy_aligned = |this: &mut Self, + src: &super::Texture, + dst: &super::Buffer, + r: crate::BufferTextureCopy| { + let list = this.list.as_ref().unwrap(); let src_location = Direct3D12::D3D12_TEXTURE_COPY_LOCATION { pResource: unsafe { borrow_interface_temporarily(&src.resource) }, @@ -675,6 +678,10 @@ impl crate::CommandEncoder for super::CommandEncoder { unsafe { list.CopyTextureRegion(&dst_location, 0, 0, 0, &src_location, Some(&src_box)) }; + }; + + for r in regions { + copy_aligned(this, src, dst, r); } }