@@ -15,8 +15,7 @@ use bevy::{
1515 render:: {
1616 RenderApp ,
1717 render_resource:: {
18- CommandEncoderDescriptor , Extent3d , LoadOp , MapMode , Operations , Origin3d , PollType ,
19- RenderPassColorAttachment , RenderPassDescriptor , StoreOp , TexelCopyBufferInfo ,
18+ CommandEncoderDescriptor , Extent3d , MapMode , Origin3d , PollType , TexelCopyBufferInfo ,
2019 TexelCopyBufferLayout , TexelCopyTextureInfo , Texture , TextureFormat , TextureUsages ,
2120 } ,
2221 renderer:: { RenderDevice , RenderQueue } ,
@@ -448,16 +447,6 @@ pub fn begin_draw(In(entity): In<Entity>, mut state_query: Query<&mut RenderStat
448447}
449448
450449pub fn flush ( app : & mut App , entity : Entity ) -> Result < ( ) > {
451- // f there's nothing to render, skip the whole render pass. this avoids some issues on
452- // macos with msaa resolve where nothing is rendered
453- let is_empty = graphics_mut ! ( app, entity)
454- . get :: < CommandBuffer > ( )
455- . map ( |c| c. commands . is_empty ( ) )
456- . unwrap_or ( true ) ;
457- if is_empty {
458- return Ok ( ( ) ) ;
459- }
460-
461450 graphics_mut ! ( app, entity) . insert ( Flush ) ;
462451 app. update ( ) ;
463452 graphics_mut ! ( app, entity) . remove :: < Flush > ( ) ;
@@ -494,49 +483,15 @@ pub fn end_draw(app: &mut App, entity: Entity) -> Result<()> {
494483///
495484// TODO: why is metal particularly affected by this? can we remove this?
496485pub fn warmup ( app : & mut App , entity : Entity ) -> Result < ( ) > {
497- let main_texture = {
498- let render_world = app. sub_app_mut ( RenderApp ) . world_mut ( ) ;
499- let mut query = render_world. query :: < ( & MainEntity , & ViewTarget ) > ( ) ;
500- let mut found = None ;
501- for ( main_entity, vt) in query. iter ( render_world) {
502- if * * main_entity == entity {
503- found = Some ( vt. main_texture ( ) . clone ( ) ) ;
504- break ;
505- }
506- }
507- found. ok_or ( ProcessingError :: GraphicsNotFound ) ?
508- } ;
509-
510- let render_app = app. sub_app ( RenderApp ) ;
511- let render_device = render_app. world ( ) . resource :: < RenderDevice > ( ) ;
512- let render_queue = render_app. world ( ) . resource :: < RenderQueue > ( ) ;
513-
514- let view = main_texture. create_view ( & bevy:: render:: render_resource:: TextureViewDescriptor {
515- label : Some ( "processing_warmup_view" ) ,
516- ..Default :: default ( )
517- } ) ;
518- let mut encoder = render_device. create_command_encoder ( & CommandEncoderDescriptor {
519- label : Some ( "processing_warmup_encoder" ) ,
520- } ) ;
521- {
522- let _pass = encoder. begin_render_pass ( & RenderPassDescriptor {
523- label : Some ( "processing_warmup_clear" ) ,
524- color_attachments : & [ Some ( RenderPassColorAttachment {
525- view : & view,
526- depth_slice : None ,
527- resolve_target : None ,
528- ops : Operations {
529- load : LoadOp :: Clear ( wgpu:: Color :: TRANSPARENT ) ,
530- store : StoreOp :: Store ,
531- } ,
532- } ) ] ,
533- depth_stencil_attachment : None ,
534- timestamp_writes : None ,
535- occlusion_query_set : None ,
536- multiview_mask : None ,
537- } ) ;
486+ for _ in 0 ..3 {
487+ app. world_mut ( )
488+ . run_system_cached_with (
489+ record_command,
490+ ( entity, DrawCommand :: BackgroundColor ( DEFAULT_CLEAR_COLOR ) ) ,
491+ )
492+ . unwrap ( ) ?;
493+ flush ( app, entity) ?;
538494 }
539- render_queue. submit ( [ encoder. finish ( ) ] ) ;
540495 Ok ( ( ) )
541496}
542497
0 commit comments