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

[Merged by Bors] - use better set inheritance in render systems #7524

Closed
Show file tree
Hide file tree
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
15 changes: 6 additions & 9 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ impl Plugin for PbrPlugin {

// Extract the required data from the main world
render_app
.configure_set(RenderLightSystems::PrepareLights.in_set(RenderSet::Prepare))
.configure_set(RenderLightSystems::PrepareClusters.in_set(RenderSet::Prepare))
.configure_set(RenderLightSystems::QueueShadows.in_set(RenderSet::Queue))
.add_systems_to_schedule(
ExtractSchedule,
(
Expand All @@ -264,8 +267,7 @@ impl Plugin for PbrPlugin {
.add_system(
render::prepare_lights
.before(ViewSet::PrepareUniforms)
.in_set(RenderLightSystems::PrepareLights)
.in_set(RenderSet::Prepare),
.in_set(RenderLightSystems::PrepareLights),
)
// A sync is needed after prepare_lights, before prepare_view_uniforms,
// because prepare_lights creates new views for shadow mapping
Expand All @@ -277,14 +279,9 @@ impl Plugin for PbrPlugin {
.add_system(
render::prepare_clusters
.after(render::prepare_lights)
.in_set(RenderLightSystems::PrepareClusters)
.in_set(RenderSet::Prepare),
)
.add_system(
render::queue_shadows
.in_set(RenderLightSystems::QueueShadows)
.in_set(RenderSet::Queue),
.in_set(RenderLightSystems::PrepareClusters),
)
.add_system(render::queue_shadows.in_set(RenderLightSystems::QueueShadows))
.add_system(render::queue_shadow_view_bind_group.in_set(RenderSet::Queue))
.add_system(sort_phase_system::<Shadow>.in_set(RenderSet::PhaseSort))
.init_resource::<ShadowPipeline>()
Expand Down
6 changes: 1 addition & 5 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ where
.init_resource::<RenderMaterials<M>>()
.init_resource::<SpecializedMeshPipelines<MaterialPipeline<M>>>()
.add_system_to_schedule(ExtractSchedule, extract_materials::<M>)
.add_system(
prepare_materials::<M>
.after(PrepareAssetLabel::PreAssetPrepare)
.in_set(RenderSet::Prepare),
)
.add_system(prepare_materials::<M>.after(PrepareAssetLabel::PreAssetPrepare))
.add_system(queue_material_meshes::<M>.in_set(RenderSet::Queue));
}

Expand Down
23 changes: 10 additions & 13 deletions crates/bevy_render/src/render_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,21 @@ impl<A: RenderAsset> Default for RenderAssetPlugin<A> {
impl<A: RenderAsset> Plugin for RenderAssetPlugin<A> {
fn build(&self, app: &mut App) {
if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
let prepare_asset_system = prepare_assets::<A>.in_set(self.prepare_asset_label.clone());

let prepare_asset_system = match self.prepare_asset_label {
PrepareAssetLabel::PreAssetPrepare => prepare_asset_system,
PrepareAssetLabel::AssetPrepare => {
prepare_asset_system.after(PrepareAssetLabel::PreAssetPrepare)
}
PrepareAssetLabel::PostAssetPrepare => {
prepare_asset_system.after(PrepareAssetLabel::AssetPrepare)
}
};

render_app
.configure_sets(
(
PrepareAssetLabel::PreAssetPrepare,
PrepareAssetLabel::AssetPrepare,
PrepareAssetLabel::PostAssetPrepare,
)
Comment on lines +83 to +88
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only needs to be configured once. But because this is in RenderAssetPlugin<A>, it will be configured for every render asset A. I don't think there is a better place to put it, because the RenderAssetPlugin should work without e.g. the PbrPlugin.

Is configure_sets idempotent? Or should there be a if !initialized { configure(); initialized = true } is some way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configure_sets should be idempotent. If it's not, that's a bug.

.chain()
.in_set(RenderSet::Prepare),
)
.init_resource::<ExtractedAssets<A>>()
.init_resource::<RenderAssets<A>>()
.init_resource::<PrepareNextFrameAssets<A>>()
.add_system_to_schedule(ExtractSchedule, extract_render_asset::<A>)
.add_system(prepare_asset_system.in_set(RenderSet::Prepare));
.add_system(prepare_assets::<A>.in_set(self.prepare_asset_label.clone()));
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions crates/bevy_render/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ impl Plugin for ViewPlugin {
if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
render_app
.init_resource::<ViewUniforms>()
.add_system(
prepare_view_uniforms
.in_set(RenderSet::Prepare)
.in_set(ViewSet::PrepareUniforms),
)
.configure_set(ViewSet::PrepareUniforms.in_set(RenderSet::Prepare))
.add_system(prepare_view_uniforms.in_set(ViewSet::PrepareUniforms))
.add_system(
prepare_view_targets
.after(WindowSystem::Prepare)
Expand Down
7 changes: 2 additions & 5 deletions crates/bevy_render/src/view/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ impl Plugin for WindowRenderPlugin {
.init_resource::<WindowSurfaces>()
.init_non_send_resource::<NonSendMarker>()
.add_system_to_schedule(ExtractSchedule, extract_windows)
.add_system(
prepare_windows
.in_set(WindowSystem::Prepare)
.in_set(RenderSet::Prepare),
);
.configure_set(WindowSystem::Prepare.in_set(RenderSet::Prepare))
.add_system(prepare_windows.in_set(WindowSystem::Prepare));
}
}
}
Expand Down