@@ -1037,6 +1037,8 @@ pub(super) fn copy_buffer_to_buffer(
10371037 . into ( ) ) ;
10381038 }
10391039
1040+ // This must happen after parameter validation (so that errors are reported
1041+ // as required by the spec), but before any side effects.
10401042 if size == 0 {
10411043 log:: trace!( "Ignoring copy_buffer_to_buffer of size 0" ) ;
10421044 return Ok ( ( ) ) ;
@@ -1255,6 +1257,8 @@ pub(super) fn copy_texture_to_buffer(
12551257 . check_usage ( BufferUsages :: COPY_DST )
12561258 . map_err ( TransferError :: MissingBufferUsage ) ?;
12571259
1260+ // This must happen after parameter validation (so that errors are reported
1261+ // as required by the spec), but before any side effects.
12581262 if copy_size. width == 0 || copy_size. height == 0 || copy_size. depth_or_array_layers == 0 {
12591263 log:: trace!( "Ignoring copy_texture_to_buffer of size 0" ) ;
12601264 return Ok ( ( ) ) ;
@@ -1376,12 +1380,6 @@ pub(super) fn copy_texture_to_texture(
13761380 . into ( ) ) ;
13771381 }
13781382
1379- // Handle texture init *before* dealing with barrier transitions so we
1380- // have an easier time inserting "immediate-inits" that may be required
1381- // by prior discards in rare cases.
1382- handle_src_texture_init ( state, source, copy_size, src_texture) ?;
1383- handle_dst_texture_init ( state, destination, copy_size, dst_texture) ?;
1384-
13851383 let src_raw = src_texture. try_raw ( state. snatch_guard ) ?;
13861384 src_texture
13871385 . check_usage ( TextureUsages :: COPY_SRC )
@@ -1391,11 +1389,19 @@ pub(super) fn copy_texture_to_texture(
13911389 . check_usage ( TextureUsages :: COPY_DST )
13921390 . map_err ( TransferError :: MissingTextureUsage ) ?;
13931391
1392+ // This must happen after parameter validation (so that errors are reported
1393+ // as required by the spec), but before any side effects.
13941394 if copy_size. width == 0 || copy_size. height == 0 || copy_size. depth_or_array_layers == 0 {
13951395 log:: trace!( "Ignoring copy_texture_to_texture of size 0" ) ;
13961396 return Ok ( ( ) ) ;
13971397 }
13981398
1399+ // Handle texture init *before* dealing with barrier transitions so we
1400+ // have an easier time inserting "immediate-inits" that may be required
1401+ // by prior discards in rare cases.
1402+ handle_src_texture_init ( state, source, copy_size, src_texture) ?;
1403+ handle_dst_texture_init ( state, destination, copy_size, dst_texture) ?;
1404+
13991405 let src_pending =
14001406 state
14011407 . tracker
0 commit comments