Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels to render systems #1511

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 54 additions & 14 deletions crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod texture;
pub mod wireframe;

use bevy_ecs::{
schedule::SystemStage,
schedule::{ExclusiveSystemDescriptorCoercion, ParallelSystemDescriptorCoercion, SystemStage},
system::{IntoExclusiveSystem, IntoSystem},
};
use draw::Visible;
Expand All @@ -37,7 +37,7 @@ use crate::prelude::*;
use base::Msaa;
use bevy_app::prelude::*;
use bevy_asset::{AddAsset, AssetStage};
use bevy_ecs::schedule::StageLabel;
use bevy_ecs::schedule::{StageLabel, SystemLabel};
use camera::{
ActiveCameras, Camera, OrthographicProjection, PerspectiveProjection, VisibleEntities,
};
Expand Down Expand Up @@ -68,6 +68,20 @@ pub enum RenderStage {
Render,
PostRender,
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemLabel)]
pub enum RenderSystem {
ClearDraw,
ActiveCameras,
OrthographicCamera,
PerspectiveCamera,
VisibleEntities,
ShaderUpdate,
MeshResourceProvider,
TextureResource,
RenderGraphScheduleExecutor,
DrawRenderPipelines,
ClearShaderDefs,
}

/// Adds core render types and systems to an App
pub struct RenderPlugin {
Expand Down Expand Up @@ -144,47 +158,73 @@ impl Plugin for RenderPlugin {
.init_resource::<RenderResourceBindings>()
.init_resource::<AssetRenderResourceBindings>()
.init_resource::<ActiveCameras>()
.add_system_to_stage(CoreStage::PreUpdate, draw::clear_draw_system.system())
.add_system_to_stage(
CoreStage::PreUpdate,
draw::clear_draw_system
.system()
.label(RenderSystem::ClearDraw),
)
.add_system_to_stage(
CoreStage::PostUpdate,
camera::active_cameras_system.system(),
camera::active_cameras_system
.system()
.label(RenderSystem::ActiveCameras),
)
.add_system_to_stage(
CoreStage::PostUpdate,
camera::camera_system::<OrthographicProjection>.system(),
camera::camera_system::<OrthographicProjection>
.system()
.label(RenderSystem::OrthographicCamera),
)
.add_system_to_stage(
CoreStage::PostUpdate,
camera::camera_system::<PerspectiveProjection>.system(),
camera::camera_system::<PerspectiveProjection>
.system()
.label(RenderSystem::PerspectiveCamera),
)
// registration order matters here. this must come after all camera_system::<T> systems
.add_system_to_stage(
CoreStage::PostUpdate,
camera::visible_entities_system.system(),
camera::visible_entities_system
.system()
.label(RenderSystem::VisibleEntities)
.after(RenderSystem::OrthographicCamera)
.after(RenderSystem::PerspectiveCamera),
)
.add_system_to_stage(
RenderStage::RenderResource,
shader::shader_update_system.system(),
shader::shader_update_system
.system()
.label(RenderSystem::ShaderUpdate),
)
.add_system_to_stage(
RenderStage::RenderResource,
mesh::mesh_resource_provider_system.system(),
mesh::mesh_resource_provider_system
.system()
.label(RenderSystem::MeshResourceProvider),
)
.add_system_to_stage(
RenderStage::RenderResource,
Texture::texture_resource_system.system(),
Texture::texture_resource_system
.system()
.label(RenderSystem::TextureResource),
)
.add_system_to_stage(
RenderStage::RenderGraphSystems,
render_graph::render_graph_schedule_executor_system.exclusive_system(),
render_graph::render_graph_schedule_executor_system
.exclusive_system()
.label(RenderSystem::RenderGraphScheduleExecutor),
)
.add_system_to_stage(
RenderStage::Draw,
pipeline::draw_render_pipelines_system.system(),
pipeline::draw_render_pipelines_system
.system()
.label(RenderSystem::DrawRenderPipelines),
)
.add_system_to_stage(
RenderStage::PostRender,
shader::clear_shader_defs_system.system(),
shader::clear_shader_defs_system
.system()
.label(RenderSystem::ClearShaderDefs),
);

if let Some(ref config) = self.base_render_graph_config {
Expand Down