@@ -20,11 +20,20 @@ impl crate::BufferTextureCopy {
20
20
& self ,
21
21
device : & d3d12_ty:: ID3D12Device ,
22
22
mut desc : d3d12_ty:: D3D12_RESOURCE_DESC ,
23
+ format : wgt:: TextureFormat ,
23
24
) -> d3d12_ty:: D3D12_PLACED_SUBRESOURCE_FOOTPRINT {
24
25
desc. Width = self . size . width as u64 ;
25
26
desc. Height = self . size . height ;
26
27
desc. DepthOrArraySize = self . size . depth as u16 ;
27
28
desc. MipLevels = 1 ;
29
+ desc. Flags = 0 ;
30
+
31
+ if let Some ( fmt) =
32
+ auxil:: dxgi:: conv:: map_texture_format_for_copy ( format, self . texture_base . aspect )
33
+ {
34
+ desc. Format = fmt;
35
+ }
36
+
28
37
let mut fp = d3d12_ty:: D3D12_PLACED_SUBRESOURCE_FOOTPRINT :: default ( ) ;
29
38
unsafe {
30
39
device. GetCopyableFootprints (
@@ -38,6 +47,11 @@ impl crate::BufferTextureCopy {
38
47
ptr:: null_mut ( ) ,
39
48
) ;
40
49
}
50
+ fp. Footprint . RowPitch = wgt:: math:: align_to (
51
+ fp. Footprint . RowPitch ,
52
+ d3d12_ty:: D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ,
53
+ ) ;
54
+
41
55
fp
42
56
}
43
57
}
@@ -545,7 +559,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
545
559
let src_box = make_box ( & wgt:: Origin3d :: ZERO , & r. size ) ;
546
560
unsafe {
547
561
* src_location. u . PlacedFootprint_mut ( ) =
548
- r. to_subresource_footprint ( & self . device , dst. resource . GetDesc ( ) ) ;
562
+ r. to_subresource_footprint ( & self . device , dst. resource . GetDesc ( ) , dst . format ) ;
549
563
} ;
550
564
unsafe {
551
565
* dst_location. u . SubresourceIndex_mut ( ) =
@@ -592,7 +606,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
592
606
} ;
593
607
unsafe {
594
608
* dst_location. u . PlacedFootprint_mut ( ) =
595
- r. to_subresource_footprint ( & self . device , src. resource . GetDesc ( ) ) ;
609
+ r. to_subresource_footprint ( & self . device , src. resource . GetDesc ( ) , src . format ) ;
596
610
} ;
597
611
unsafe { list. CopyTextureRegion ( & dst_location, 0 , 0 , 0 , & src_location, & src_box) } ;
598
612
}
0 commit comments