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 Explicit Ordering for DefaultPlugins Systems #9828

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
1 change: 1 addition & 0 deletions crates/bevy_animation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.12.0-dev" }
bevy_ui = { path = "../bevy_ui", version = "0.12.0-dev" }
4 changes: 3 additions & 1 deletion crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,9 @@ impl Plugin for AnimationPlugin {
.register_type::<AnimationPlayer>()
.add_systems(
PostUpdate,
animation_player.before(TransformSystem::TransformPropagate),
animation_player
.before(TransformSystem::TransformPropagate)
.before(bevy_ui::UiSystem::Layout),
);
}
}
1 change: 1 addition & 0 deletions crates/bevy_audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bevy_app = { path = "../bevy_app", version = "0.12.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.12.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.12.0-dev" }
bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = ["bevy"] }
bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.12.0-dev" }
Expand Down
11 changes: 9 additions & 2 deletions crates/bevy_audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@ impl AddAudioSource for App {
{
self.init_asset::<T>().add_systems(
PostUpdate,
play_queued_audio_system::<T>.in_set(AudioPlaySet),
play_queued_audio_system::<T>
.in_set(AudioPlaySet)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
);
self.add_systems(
PostUpdate,
cleanup_finished_audio::<T>
.in_set(AudioPlaySet)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
);
self.add_systems(PostUpdate, cleanup_finished_audio::<T>.in_set(AudioPlaySet));
self
}
}
1 change: 1 addition & 0 deletions crates/bevy_gilrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bevy_input = { path = "../bevy_input", version = "0.12.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.12.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }
bevy_time = { path = "../bevy_time", version = "0.12.0-dev" }
bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" }

# other
gilrs = "0.10.1"
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_gilrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ impl Plugin for GilrsPlugin {
.init_non_send_resource::<RunningRumbleEffects>()
.add_systems(PreStartup, gilrs_event_startup_system)
.add_systems(PreUpdate, gilrs_event_system.before(InputSystem))
.add_systems(PostUpdate, play_gilrs_rumble.in_set(RumbleSystem));
.add_systems(
PostUpdate,
play_gilrs_rumble
.in_set(RumbleSystem)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
);
}
Err(err) => error!("Failed to start Gilrs. {}", err),
}
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ impl Plugin for GizmoPlugin {
draw_aabbs,
draw_all_aabbs.run_if(|config: Res<GizmoConfig>| config.aabb.draw_all),
)
.after(TransformSystem::TransformPropagate),
.after(TransformSystem::TransformPropagate)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
);

let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_pbr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bevy_render = { path = "../bevy_render", version = "0.12.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }
bevy_window = { path = "../bevy_window", version = "0.12.0-dev" }
bevy_winit = { path = "../bevy_winit", version = "0.12.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.12.0-dev" }

# other
Expand Down
15 changes: 13 additions & 2 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,25 @@ impl Plugin for PbrPlugin {
.add_systems(
PostUpdate,
(
add_clusters.in_set(SimulationLightSystems::AddClusters),
apply_deferred.in_set(SimulationLightSystems::AddClustersFlush),
add_clusters
.in_set(SimulationLightSystems::AddClusters)
.after(bevy_render::view::VisibilitySystems::CalculateBoundsFlush),
apply_deferred
.in_set(SimulationLightSystems::AddClustersFlush)
.after(bevy_render::view::VisibilitySystems::CalculateBounds)
.after(VisibilitySystems::CheckVisibility)
.after(bevy_winit::accessibility::AccessKitSystemSet)
.before(bevy_window::exit_on_all_closed)
.after(TransformSystem::TransformPropagate)
.after(bevy_render::mesh::morph::inherit_weights),
assign_lights_to_clusters
.in_set(SimulationLightSystems::AssignLightsToClusters)
.after(TransformSystem::TransformPropagate)
.after(VisibilitySystems::CheckVisibility)
.after(CameraUpdateSystem),
update_directional_light_cascades
.in_set(SimulationLightSystems::UpdateDirectionalLightCascades)
.after(SimulationLightSystems::AddClustersFlush)
.after(TransformSystem::TransformPropagate)
.after(CameraUpdateSystem),
update_directional_light_frusta
Expand All @@ -212,6 +222,7 @@ impl Plugin for PbrPlugin {
.after(VisibilitySystems::CheckVisibility)
.after(TransformSystem::TransformPropagate)
.after(SimulationLightSystems::UpdateDirectionalLightCascades)
.after(SimulationLightSystems::AddClustersFlush)
// We assume that no entity will be both a directional light and a spot light,
// so these systems will run independently of one another.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ bevy_render_macros = { path = "macros", version = "0.12.0-dev" }
bevy_time = { path = "../bevy_time", version = "0.12.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" }
bevy_window = { path = "../bevy_window", version = "0.12.0-dev" }
bevy_winit = { path = "../bevy_winit", version = "0.12.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }
bevy_tasks = { path = "../bevy_tasks", version = "0.12.0-dev" }

Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_render/src/camera/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ impl<T: CameraProjection + Component + GetTypeRegistration> Plugin for CameraPro
// We assume that each camera will only have one projection,
// so we can ignore ambiguities with all other monomorphizations.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(CameraUpdateSystem),
.ambiguous_with(CameraUpdateSystem)
.after(crate::view::VisibilitySystems::CalculateBoundsFlush),
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_render/src/mesh/morph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ impl Plugin for MorphPlugin {
fn build(&self, app: &mut bevy_app::App) {
app.register_type::<MorphWeights>()
.register_type::<MeshMorphWeights>()
.add_systems(PostUpdate, inherit_weights);
.add_systems(
PostUpdate,
inherit_weights.after(crate::view::VisibilitySystems::CalculateBoundsFlush),
);
}
}

Expand Down
31 changes: 25 additions & 6 deletions crates/bevy_render/src/view/visibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,14 @@ impl Plugin for VisibilityPlugin {

app
// We add an AABB component in CalculateBounds, which must be ready on the same frame.
.add_systems(PostUpdate, apply_deferred.in_set(CalculateBoundsFlush))
.add_systems(
PostUpdate,
apply_deferred
.in_set(CalculateBoundsFlush)
.before(TransformSystem::TransformPropagate)
.before(bevy_transform::systems::sync_simple_transforms)
.after(bevy_winit::accessibility::AccessKitSystemSet),
)
.configure_sets(PostUpdate, CalculateBoundsFlush.after(CalculateBounds))
.add_systems(
PostUpdate,
Expand All @@ -225,6 +232,7 @@ impl Plugin for VisibilityPlugin {
.in_set(UpdateOrthographicFrusta)
.after(camera_system::<OrthographicProjection>)
.after(TransformSystem::TransformPropagate)
.after(CalculateBoundsFlush)
// We assume that no camera will have more than one projection component,
// so these systems will run independently of one another.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
Expand All @@ -234,16 +242,19 @@ impl Plugin for VisibilityPlugin {
.in_set(UpdatePerspectiveFrusta)
.after(camera_system::<PerspectiveProjection>)
.after(TransformSystem::TransformPropagate)
.after(CalculateBoundsFlush)
// We assume that no camera will have more than one projection component,
// so these systems will run independently of one another.
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
.ambiguous_with(update_frusta::<Projection>),
update_frusta::<Projection>
.in_set(UpdateProjectionFrusta)
.after(camera_system::<Projection>)
.after(TransformSystem::TransformPropagate),
.after(TransformSystem::TransformPropagate)
.after(CalculateBoundsFlush),
(visibility_propagate_system, reset_view_visibility)
.in_set(VisibilityPropagate),
.in_set(VisibilityPropagate)
.after(crate::view::VisibilitySystems::CalculateBoundsFlush),
check_visibility
.in_set(CheckVisibility)
.after(CalculateBoundsFlush)
Expand Down Expand Up @@ -493,7 +504,10 @@ mod test {
#[test]
fn visibility_propagation() {
let mut app = App::new();
app.add_systems(Update, visibility_propagate_system);
app.add_systems(
Update,
visibility_propagate_system.after(crate::view::VisibilitySystems::CalculateBoundsFlush),
);

let root1 = app
.world
Expand Down Expand Up @@ -600,7 +614,10 @@ mod test {
#[test]
fn visibility_propagation_unconditional_visible() {
let mut app = App::new();
app.add_systems(Update, visibility_propagate_system);
app.add_systems(
Update,
visibility_propagate_system.after(crate::view::VisibilitySystems::CalculateBoundsFlush),
);

let root1 = app
.world
Expand Down Expand Up @@ -700,7 +717,9 @@ mod test {
fn visibility_progation_change_detection() {
let mut world = World::new();
let mut schedule = Schedule::default();
schedule.add_systems(visibility_propagate_system);
schedule.add_systems(
visibility_propagate_system.after(crate::view::VisibilitySystems::CalculateBoundsFlush),
);

// Set up an entity hierarchy.

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bevy_app = { path = "../bevy_app", version = "0.12.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.12.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.12.0-dev" }
bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = ["bevy"] }
bevy_render = { path = "../bevy_render", version = "0.12.0-dev" }
bevy_sprite = { path = "../bevy_sprite", version = "0.12.0-dev" }
Expand Down
7 changes: 5 additions & 2 deletions crates/bevy_text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ impl Plugin for TextPlugin {
// In practice, they run independently since `bevy_render::camera_update_system`
// will only ever observe its own render target, and `update_text2d_layout`
// will never modify a pre-existing `Image` asset.
.ambiguous_with(CameraUpdateSystem),
.ambiguous_with(CameraUpdateSystem)
.ambiguous_with(bevy_sprite::calculate_bounds_2d),
font_atlas_set::remove_dropped_font_atlas_sets,
),
)
.chain()
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
);

if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.12.0-dev" }
bevy_input = { path = "../bevy_input", version = "0.12.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.12.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.12.0-dev" }
bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = [
"bevy",
] }
Expand All @@ -28,6 +29,7 @@ bevy_sprite = { path = "../bevy_sprite", version = "0.12.0-dev" }
bevy_text = { path = "../bevy_text", version = "0.12.0-dev", optional = true }
bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" }
bevy_window = { path = "../bevy_window", version = "0.12.0-dev" }
bevy_winit = { path = "../bevy_winit", version = "0.12.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" }

# other
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_ui/src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ impl Plugin for AccessibilityPlugin {
button_changed,
image_changed,
label_changed,
),
)
.chain()
.after(bevy_winit::accessibility::AccessKitSystemSet)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
);
}
}
22 changes: 18 additions & 4 deletions crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl Plugin for UiPlugin {
PostUpdate,
(
widget::measure_text_system
.after(widget::update_atlas_content_size_system)
.before(UiSystem::Layout)
// Potential conflict: `Assets<Image>`
// In practice, they run independently since `bevy_render::camera_update_system`
Expand All @@ -144,13 +145,20 @@ impl Plugin for UiPlugin {
.ambiguous_with(bevy_text::update_text2d_layout),
widget::text_system
.after(UiSystem::Layout)
.after(bevy_render::view::VisibilitySystems::CalculateBounds)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush)
.after(bevy_text::update_text2d_layout)
.before(bevy_text::remove_dropped_font_atlas_sets)
.before(Assets::<Image>::track_assets),
),
);
#[cfg(feature = "bevy_text")]
app.add_plugins(accessibility::AccessibilityPlugin);
app.add_systems(PostUpdate, {
let system = widget::update_image_content_size_system.before(UiSystem::Layout);
let system = widget::update_image_content_size_system
.before(UiSystem::Layout)
.before(bevy_render::view::VisibilitySystems::CalculateBoundsFlush)
.after(widget::measure_text_system);
// Potential conflicts: `Assets<Image>`
// They run independently since `widget::image_node_system` will only ever observe
// its own UiImage, and `widget::text_system` & `bevy_text::update_text2d_layout`
Expand All @@ -171,9 +179,15 @@ impl Plugin for UiPlugin {
(
ui_layout_system
.in_set(UiSystem::Layout)
.before(TransformSystem::TransformPropagate),
ui_stack_system.in_set(UiSystem::Stack),
update_clipping_system.after(TransformSystem::TransformPropagate),
.before(TransformSystem::TransformPropagate)
.before(bevy_pbr::SimulationLightSystems::AddClustersFlush)
.before(bevy_render::view::VisibilitySystems::CalculateBoundsFlush),
ui_stack_system
.in_set(UiSystem::Stack)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
update_clipping_system
.after(TransformSystem::TransformPropagate)
.after(bevy_pbr::SimulationLightSystems::AddClustersFlush),
),
);

Expand Down
9 changes: 8 additions & 1 deletion crates/bevy_winit/src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
prelude::{DetectChanges, Entity, EventReader, EventWriter},
query::With,
schedule::{IntoSystemConfigs, SystemSet},
system::{NonSend, NonSendMut, Query, Res, ResMut, Resource},
};
use bevy_hierarchy::{Children, Parent};
Expand Down Expand Up @@ -161,6 +162,10 @@ fn update_accessibility_nodes(
}
}

/// Label for [`AccessibilityPlugin`] systems.
#[derive(SystemSet, Clone, Eq, PartialEq, Hash, Debug)]
pub struct AccessKitSystemSet;

/// Implements winit-specific `AccessKit` functionality.
pub struct AccessibilityPlugin;

Expand All @@ -176,7 +181,9 @@ impl Plugin for AccessibilityPlugin {
window_closed,
poll_receivers,
update_accessibility_nodes,
),
)
.chain()
.in_set(AccessKitSystemSet),
);
}
}