@@ -66,6 +66,7 @@ pub enum TransferError {
6666// once only to get the aspect flags, which is unfortunate.
6767pub ( crate ) fn texture_copy_view_to_hal < B : hal:: Backend > (
6868 view : & TextureCopyView ,
69+ size : & wgt:: Extent3d ,
6970 texture_guard : & Storage < Texture < B > , TextureId > ,
7071) -> (
7172 hal:: image:: SubresourceLayers ,
@@ -75,11 +76,13 @@ pub(crate) fn texture_copy_view_to_hal<B: hal::Backend>(
7576 let texture = & texture_guard[ view. texture ] ;
7677 let aspects = texture. full_range . aspects ;
7778 let level = view. mip_level as hal:: image:: Level ;
78- let ( layer, z) = match texture. dimension {
79- wgt:: TextureDimension :: D1 | wgt:: TextureDimension :: D2 => {
80- ( view. origin . z as hal:: image:: Layer , 0 )
81- }
82- wgt:: TextureDimension :: D3 => ( 0 , view. origin . z as i32 ) ,
79+ let ( layer, layer_count, z) = match texture. dimension {
80+ wgt:: TextureDimension :: D1 | wgt:: TextureDimension :: D2 => (
81+ view. origin . z as hal:: image:: Layer ,
82+ size. depth as hal:: image:: Layer ,
83+ 0 ,
84+ ) ,
85+ wgt:: TextureDimension :: D3 => ( 0 , 1 , view. origin . z as i32 ) ,
8386 } ;
8487
8588 // TODO: Can't satisfy clippy here unless we modify
@@ -89,12 +92,12 @@ pub(crate) fn texture_copy_view_to_hal<B: hal::Backend>(
8992 hal:: image:: SubresourceLayers {
9093 aspects,
9194 level : view. mip_level as hal:: image:: Level ,
92- layers : layer..layer + 1 ,
95+ layers : layer..layer + layer_count ,
9396 } ,
9497 hal:: image:: SubresourceRange {
9598 aspects,
9699 levels : level..level + 1 ,
97- layers : layer..layer + 1 ,
100+ layers : layer..layer + layer_count ,
98101 } ,
99102 hal:: image:: Offset {
100103 x : view. origin . x as i32 ,
@@ -329,7 +332,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
329332 let ( buffer_guard, mut token) = hub. buffers . read ( & mut token) ;
330333 let ( texture_guard, _) = hub. textures . read ( & mut token) ;
331334 let ( dst_layers, dst_range, dst_offset) =
332- texture_copy_view_to_hal ( destination, & * texture_guard) ;
335+ texture_copy_view_to_hal ( destination, copy_size , & * texture_guard) ;
333336
334337 #[ cfg( feature = "trace" ) ]
335338 match cmb. commands {
@@ -432,7 +435,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
432435 let cmb = & mut cmb_guard[ command_encoder_id] ;
433436 let ( buffer_guard, mut token) = hub. buffers . read ( & mut token) ;
434437 let ( texture_guard, _) = hub. textures . read ( & mut token) ;
435- let ( src_layers, src_range, src_offset) = texture_copy_view_to_hal ( source, & * texture_guard) ;
438+ let ( src_layers, src_range, src_offset) =
439+ texture_copy_view_to_hal ( source, copy_size, & * texture_guard) ;
436440
437441 #[ cfg( feature = "trace" ) ]
438442 match cmb. commands {
@@ -539,9 +543,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
539543 // we can't hold both src_pending and dst_pending in scope because they
540544 // borrow the buffer tracker mutably...
541545 let mut barriers = Vec :: new ( ) ;
542- let ( src_layers, src_range, src_offset) = texture_copy_view_to_hal ( source, & * texture_guard) ;
546+ let ( src_layers, src_range, src_offset) =
547+ texture_copy_view_to_hal ( source, copy_size, & * texture_guard) ;
543548 let ( dst_layers, dst_range, dst_offset) =
544- texture_copy_view_to_hal ( destination, & * texture_guard) ;
549+ texture_copy_view_to_hal ( destination, copy_size , & * texture_guard) ;
545550 if src_layers. aspects != dst_layers. aspects {
546551 return Err ( TransferError :: MismatchedAspects ) ;
547552 }
0 commit comments