@@ -483,13 +483,12 @@ pub(crate) fn validate_texture_copy_range<T>(
483483/// [srtc]: https://gpuweb.github.io/gpuweb/#abstract-opdef-set-of-subresources-for-texture-copy
484484pub ( crate ) fn validate_copy_within_same_texture < T > (
485485 src : & wgt:: TexelCopyTextureInfo < T > ,
486- src_format : wgt:: TextureFormat ,
487486 dst : & wgt:: TexelCopyTextureInfo < T > ,
488- dst_format : wgt:: TextureFormat ,
487+ format : wgt:: TextureFormat ,
489488 array_layer_count : u32 ,
490489) -> Result < ( ) , TransferError > {
491- let src_aspects = hal:: FormatAspects :: new ( src_format , src. aspect ) ;
492- let dst_aspects = hal:: FormatAspects :: new ( dst_format , dst. aspect ) ;
490+ let src_aspects = hal:: FormatAspects :: new ( format , src. aspect ) ;
491+ let dst_aspects = hal:: FormatAspects :: new ( format , dst. aspect ) ;
493492 if ( src_aspects & dst_aspects) . is_empty ( ) {
494493 // Copying between different aspects (if it even makes sense), is okay.
495494 return Ok ( ( ) ) ;
@@ -502,6 +501,11 @@ pub(crate) fn validate_copy_within_same_texture<T>(
502501 return Ok ( ( ) ) ;
503502 }
504503
504+ if src. mip_level != dst. mip_level {
505+ // Copying between different mip levels is okay.
506+ return Ok ( ( ) ) ;
507+ }
508+
505509 Err ( TransferError :: InvalidCopyWithinSameTexture {
506510 src_aspects : src. aspect ,
507511 dst_aspects : dst. aspect ,
@@ -922,40 +926,19 @@ impl Global {
922926 ) ,
923927 ) ;
924928
925- let regions = if dst_base. aspect == hal:: FormatAspects :: DEPTH_STENCIL {
926- vec ! [
927- hal:: BufferTextureCopy {
928- texture_base: hal:: TextureCopyBase {
929- aspect: hal:: FormatAspects :: DEPTH ,
930- ..dst_base
931- } ,
932- buffer_layout: source. layout,
933- size: hal_copy_size,
934- } ,
929+ let regions = ( 0 ..array_layer_count)
930+ . map ( |rel_array_layer| {
931+ let mut texture_base = dst_base. clone ( ) ;
932+ texture_base. array_layer += rel_array_layer;
933+ let mut buffer_layout = source. layout ;
934+ buffer_layout. offset += rel_array_layer as u64 * bytes_per_array_layer;
935935 hal:: BufferTextureCopy {
936- texture_base: hal:: TextureCopyBase {
937- aspect: hal:: FormatAspects :: STENCIL ,
938- ..dst_base
939- } ,
940- buffer_layout: source. layout,
936+ buffer_layout,
937+ texture_base,
941938 size : hal_copy_size,
942- } ,
943- ]
944- } else {
945- ( 0 ..array_layer_count)
946- . map ( |rel_array_layer| {
947- let mut texture_base = dst_base. clone ( ) ;
948- texture_base. array_layer += rel_array_layer;
949- let mut buffer_layout = source. layout ;
950- buffer_layout. offset += rel_array_layer as u64 * bytes_per_array_layer;
951- hal:: BufferTextureCopy {
952- buffer_layout,
953- texture_base,
954- size : hal_copy_size,
955- }
956- } )
957- . collect ( )
958- } ;
939+ }
940+ } )
941+ . collect :: < Vec < _ > > ( ) ;
959942
960943 let cmd_buf_raw = cmd_buf_data. encoder . open ( ) ?;
961944 unsafe {
@@ -1212,9 +1195,8 @@ impl Global {
12121195 if Arc :: as_ptr ( & src_texture) == Arc :: as_ptr ( & dst_texture) {
12131196 validate_copy_within_same_texture (
12141197 source,
1215- src_texture. desc . format ,
12161198 destination,
1217- dst_texture . desc . format ,
1199+ src_texture . desc . format ,
12181200 array_layer_count,
12191201 ) ?;
12201202 }
0 commit comments