@@ -375,10 +375,10 @@ mod frame_capture {
375
375
prelude:: * ,
376
376
render:: {
377
377
camera:: RenderTarget ,
378
- render_resource:: {
379
- Extent3d , TextureDescriptor , TextureDimension , TextureFormat , TextureUsages ,
380
- } ,
378
+ render_asset:: RenderAssetUsages ,
379
+ render_resource:: { Extent3d , TextureDimension , TextureFormat , TextureUsages } ,
381
380
renderer:: RenderDevice ,
381
+ texture:: BevyDefault ,
382
382
} ,
383
383
} ;
384
384
use std:: path:: PathBuf ;
@@ -440,40 +440,26 @@ mod frame_capture {
440
440
} ;
441
441
442
442
// This is the texture that will be rendered to.
443
- let mut render_target_image = Image {
444
- texture_descriptor : TextureDescriptor {
445
- label : None ,
446
- size,
447
- dimension : TextureDimension :: D2 ,
448
- format : TextureFormat :: Rgba8UnormSrgb ,
449
- mip_level_count : 1 ,
450
- sample_count : 1 ,
451
- usage : TextureUsages :: COPY_SRC
452
- | TextureUsages :: COPY_DST
453
- | TextureUsages :: TEXTURE_BINDING
454
- | TextureUsages :: RENDER_ATTACHMENT ,
455
- view_formats : & [ ] ,
456
- } ,
457
- ..Default :: default ( )
458
- } ;
459
- render_target_image. resize ( size) ;
443
+ let mut render_target_image = Image :: new_fill (
444
+ size,
445
+ TextureDimension :: D2 ,
446
+ & [ 0 ; 4 ] ,
447
+ TextureFormat :: bevy_default ( ) ,
448
+ RenderAssetUsages :: default ( ) ,
449
+ ) ;
450
+ render_target_image. texture_descriptor . usage |= TextureUsages :: COPY_SRC
451
+ | TextureUsages :: RENDER_ATTACHMENT
452
+ | TextureUsages :: TEXTURE_BINDING ;
460
453
let render_target_image_handle = images. add ( render_target_image) ;
461
454
462
455
// This is the texture that will be copied to.
463
- let mut cpu_image = Image {
464
- texture_descriptor : TextureDescriptor {
465
- label : None ,
466
- size,
467
- dimension : TextureDimension :: D2 ,
468
- format : TextureFormat :: Rgba8UnormSrgb ,
469
- mip_level_count : 1 ,
470
- sample_count : 1 ,
471
- usage : TextureUsages :: COPY_DST | TextureUsages :: TEXTURE_BINDING ,
472
- view_formats : & [ ] ,
473
- } ,
474
- ..Default :: default ( )
475
- } ;
476
- cpu_image. resize ( size) ;
456
+ let cpu_image = Image :: new_fill (
457
+ size,
458
+ TextureDimension :: D2 ,
459
+ & [ 0 ; 4 ] ,
460
+ TextureFormat :: bevy_default ( ) ,
461
+ RenderAssetUsages :: default ( ) ,
462
+ ) ;
477
463
let cpu_image_handle = images. add ( cpu_image) ;
478
464
479
465
commands. spawn ( ImageCopier :: new (
@@ -510,7 +496,7 @@ mod frame_capture {
510
496
if !image_data. is_empty ( ) {
511
497
for image in images_to_save. iter ( ) {
512
498
let img_bytes = images. get_mut ( image. id ( ) ) . unwrap ( ) ;
513
- img_bytes. data = image_data . clone ( ) ;
499
+ img_bytes. data . clone_from ( & image_data ) ;
514
500
515
501
let img = match img_bytes. clone ( ) . try_into_dynamic ( ) {
516
502
Ok ( img) => img. to_rgba8 ( ) ,
0 commit comments