@@ -74,12 +74,11 @@ use core::ops::Range;
7474
7575use bevy_camera:: { Camera , Camera3d , Camera3dDepthLoadOp } ;
7676use bevy_render:: {
77- batching:: gpu_preprocessing:: { GpuPreprocessingMode , GpuPreprocessingSupport } ,
7877 camera:: CameraRenderGraph ,
7978 experimental:: occlusion_culling:: OcclusionCulling ,
8079 mesh:: allocator:: SlabId ,
8180 render_phase:: PhaseItemBatchSetKey ,
82- view:: { prepare_view_targets, NoIndirectDrawing , RetainedViewEntity } ,
81+ view:: { prepare_view_targets, NoIndirectDrawing } ,
8382} ;
8483pub use main_opaque_pass_3d_node:: * ;
8584pub use main_transparent_pass_3d_node:: * ;
@@ -90,7 +89,7 @@ use bevy_color::LinearRgba;
9089use bevy_ecs:: prelude:: * ;
9190use bevy_image:: { BevyDefault , ToExtents } ;
9291use bevy_math:: FloatOrd ;
93- use bevy_platform:: collections:: { HashMap , HashSet } ;
92+ use bevy_platform:: collections:: HashMap ;
9493use bevy_render:: {
9594 camera:: ExtractedCamera ,
9695 extract_component:: ExtractComponentPlugin ,
@@ -106,10 +105,10 @@ use bevy_render::{
106105 TextureDimension , TextureFormat , TextureUsages , TextureView ,
107106 } ,
108107 renderer:: RenderDevice ,
109- sync_world:: { MainEntity , RenderEntity } ,
108+ sync_world:: MainEntity ,
110109 texture:: { ColorAttachment , TextureCache } ,
111110 view:: { ExtractedView , ViewDepthTexture , ViewTarget } ,
112- Extract , ExtractSchedule , Render , RenderApp , RenderSystems ,
111+ Render , RenderApp , RenderSystems ,
113112} ;
114113use nonmax:: NonMaxU32 ;
115114use tracing:: warn;
@@ -167,8 +166,6 @@ impl Plugin for Core3dPlugin {
167166 . init_resource :: < ViewBinnedRenderPhases < AlphaMask3dDeferred > > ( )
168167 . init_resource :: < ViewSortedRenderPhases < Transmissive3d > > ( )
169168 . init_resource :: < ViewSortedRenderPhases < Transparent3d > > ( )
170- . add_systems ( ExtractSchedule , extract_core_3d_camera_phases)
171- . add_systems ( ExtractSchedule , extract_camera_prepass_phase)
172169 . add_systems (
173170 Render ,
174171 (
@@ -616,159 +613,6 @@ impl CachedRenderPipelinePhaseItem for Transparent3d {
616613 }
617614}
618615
619- pub fn extract_core_3d_camera_phases (
620- mut opaque_3d_phases : ResMut < ViewBinnedRenderPhases < Opaque3d > > ,
621- mut alpha_mask_3d_phases : ResMut < ViewBinnedRenderPhases < AlphaMask3d > > ,
622- mut transmissive_3d_phases : ResMut < ViewSortedRenderPhases < Transmissive3d > > ,
623- mut transparent_3d_phases : ResMut < ViewSortedRenderPhases < Transparent3d > > ,
624- cameras_3d : Extract < Query < ( Entity , & Camera , Has < NoIndirectDrawing > ) , With < Camera3d > > > ,
625- mut live_entities : Local < HashSet < RetainedViewEntity > > ,
626- gpu_preprocessing_support : Res < GpuPreprocessingSupport > ,
627- ) {
628- live_entities. clear ( ) ;
629-
630- for ( main_entity, camera, no_indirect_drawing) in & cameras_3d {
631- if !camera. is_active {
632- continue ;
633- }
634-
635- // If GPU culling is in use, use it (and indirect mode); otherwise, just
636- // preprocess the meshes.
637- let gpu_preprocessing_mode = gpu_preprocessing_support. min ( if !no_indirect_drawing {
638- GpuPreprocessingMode :: Culling
639- } else {
640- GpuPreprocessingMode :: PreprocessingOnly
641- } ) ;
642-
643- // This is the main 3D camera, so use the first subview index (0).
644- let retained_view_entity = RetainedViewEntity :: new ( main_entity. into ( ) , None , 0 ) ;
645-
646- opaque_3d_phases. prepare_for_new_frame ( retained_view_entity, gpu_preprocessing_mode) ;
647- alpha_mask_3d_phases. prepare_for_new_frame ( retained_view_entity, gpu_preprocessing_mode) ;
648- transmissive_3d_phases. insert_or_clear ( retained_view_entity) ;
649- transparent_3d_phases. insert_or_clear ( retained_view_entity) ;
650-
651- live_entities. insert ( retained_view_entity) ;
652- }
653-
654- opaque_3d_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
655- alpha_mask_3d_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
656- transmissive_3d_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
657- transparent_3d_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
658- }
659-
660- // Extract the render phases for the prepass
661-
662- pub fn extract_camera_prepass_phase (
663- mut commands : Commands ,
664- mut opaque_3d_prepass_phases : ResMut < ViewBinnedRenderPhases < Opaque3dPrepass > > ,
665- mut alpha_mask_3d_prepass_phases : ResMut < ViewBinnedRenderPhases < AlphaMask3dPrepass > > ,
666- mut opaque_3d_deferred_phases : ResMut < ViewBinnedRenderPhases < Opaque3dDeferred > > ,
667- mut alpha_mask_3d_deferred_phases : ResMut < ViewBinnedRenderPhases < AlphaMask3dDeferred > > ,
668- cameras_3d : Extract <
669- Query <
670- (
671- Entity ,
672- RenderEntity ,
673- & Camera ,
674- Has < NoIndirectDrawing > ,
675- Has < DepthPrepass > ,
676- Has < NormalPrepass > ,
677- Has < MotionVectorPrepass > ,
678- Has < DeferredPrepass > ,
679- ) ,
680- With < Camera3d > ,
681- > ,
682- > ,
683- mut live_entities : Local < HashSet < RetainedViewEntity > > ,
684- gpu_preprocessing_support : Res < GpuPreprocessingSupport > ,
685- ) {
686- live_entities. clear ( ) ;
687-
688- for (
689- main_entity,
690- entity,
691- camera,
692- no_indirect_drawing,
693- depth_prepass,
694- normal_prepass,
695- motion_vector_prepass,
696- deferred_prepass,
697- ) in cameras_3d. iter ( )
698- {
699- if !camera. is_active {
700- continue ;
701- }
702-
703- // If GPU culling is in use, use it (and indirect mode); otherwise, just
704- // preprocess the meshes.
705- let gpu_preprocessing_mode = gpu_preprocessing_support. min ( if !no_indirect_drawing {
706- GpuPreprocessingMode :: Culling
707- } else {
708- GpuPreprocessingMode :: PreprocessingOnly
709- } ) ;
710-
711- // This is the main 3D camera, so we use the first subview index (0).
712- let retained_view_entity = RetainedViewEntity :: new ( main_entity. into ( ) , None , 0 ) ;
713-
714- if depth_prepass || normal_prepass || motion_vector_prepass {
715- opaque_3d_prepass_phases
716- . prepare_for_new_frame ( retained_view_entity, gpu_preprocessing_mode) ;
717- alpha_mask_3d_prepass_phases
718- . prepare_for_new_frame ( retained_view_entity, gpu_preprocessing_mode) ;
719- } else {
720- opaque_3d_prepass_phases. remove ( & retained_view_entity) ;
721- alpha_mask_3d_prepass_phases. remove ( & retained_view_entity) ;
722- }
723-
724- if deferred_prepass {
725- opaque_3d_deferred_phases
726- . prepare_for_new_frame ( retained_view_entity, gpu_preprocessing_mode) ;
727- alpha_mask_3d_deferred_phases
728- . prepare_for_new_frame ( retained_view_entity, gpu_preprocessing_mode) ;
729- } else {
730- opaque_3d_deferred_phases. remove ( & retained_view_entity) ;
731- alpha_mask_3d_deferred_phases. remove ( & retained_view_entity) ;
732- }
733- live_entities. insert ( retained_view_entity) ;
734-
735- // Add or remove prepasses as appropriate.
736-
737- let mut camera_commands = commands
738- . get_entity ( entity)
739- . expect ( "Camera entity wasn't synced." ) ;
740-
741- if depth_prepass {
742- camera_commands. insert ( DepthPrepass ) ;
743- } else {
744- camera_commands. remove :: < DepthPrepass > ( ) ;
745- }
746-
747- if normal_prepass {
748- camera_commands. insert ( NormalPrepass ) ;
749- } else {
750- camera_commands. remove :: < NormalPrepass > ( ) ;
751- }
752-
753- if motion_vector_prepass {
754- camera_commands. insert ( MotionVectorPrepass ) ;
755- } else {
756- camera_commands. remove :: < MotionVectorPrepass > ( ) ;
757- }
758-
759- if deferred_prepass {
760- camera_commands. insert ( DeferredPrepass ) ;
761- } else {
762- camera_commands. remove :: < DeferredPrepass > ( ) ;
763- }
764- }
765-
766- opaque_3d_prepass_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
767- alpha_mask_3d_prepass_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
768- opaque_3d_deferred_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
769- alpha_mask_3d_deferred_phases. retain ( |view_entity, _| live_entities. contains ( view_entity) ) ;
770- }
771-
772616pub fn prepare_core_3d_depth_textures (
773617 mut commands : Commands ,
774618 mut texture_cache : ResMut < TextureCache > ,
0 commit comments