@@ -483,13 +483,12 @@ pub(crate) fn validate_texture_copy_range<T>(
483
483
/// [srtc]: https://gpuweb.github.io/gpuweb/#abstract-opdef-set-of-subresources-for-texture-copy
484
484
pub ( crate ) fn validate_copy_within_same_texture < T > (
485
485
src : & wgt:: TexelCopyTextureInfo < T > ,
486
- src_format : wgt:: TextureFormat ,
487
486
dst : & wgt:: TexelCopyTextureInfo < T > ,
488
- dst_format : wgt:: TextureFormat ,
487
+ format : wgt:: TextureFormat ,
489
488
array_layer_count : u32 ,
490
489
) -> 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 ) ;
493
492
if ( src_aspects & dst_aspects) . is_empty ( ) {
494
493
// Copying between different aspects (if it even makes sense), is okay.
495
494
return Ok ( ( ) ) ;
@@ -502,6 +501,11 @@ pub(crate) fn validate_copy_within_same_texture<T>(
502
501
return Ok ( ( ) ) ;
503
502
}
504
503
504
+ if src. mip_level != dst. mip_level {
505
+ // Copying between different mip levels is okay.
506
+ return Ok ( ( ) ) ;
507
+ }
508
+
505
509
Err ( TransferError :: InvalidCopyWithinSameTexture {
506
510
src_aspects : src. aspect ,
507
511
dst_aspects : dst. aspect ,
@@ -922,40 +926,19 @@ impl Global {
922
926
) ,
923
927
) ;
924
928
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;
935
935
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,
941
938
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 < _ > > ( ) ;
959
942
960
943
let cmd_buf_raw = cmd_buf_data. encoder . open ( ) ?;
961
944
unsafe {
@@ -1212,9 +1195,8 @@ impl Global {
1212
1195
if Arc :: as_ptr ( & src_texture) == Arc :: as_ptr ( & dst_texture) {
1213
1196
validate_copy_within_same_texture (
1214
1197
source,
1215
- src_texture. desc . format ,
1216
1198
destination,
1217
- dst_texture . desc . format ,
1199
+ src_texture . desc . format ,
1218
1200
array_layer_count,
1219
1201
) ?;
1220
1202
}
0 commit comments