mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
expose ambiguities of ScheduleGraph
(#7716)
# Objective - other tools (bevy_mod_debugdump) would like to have access to the ambiguities so that they can do their own reporting/visualization ## Solution - store `conflicting_systems` in `ScheduleGraph` after calling `build_schedule` The solution isn't very pretty and as pointed out it https://github.com/bevyengine/bevy/pull/7522, there may be a better way of exposing this, but this is the quick and dirty way if we want to have this functionality exposed in 0.10.
This commit is contained in:
parent
c5702b9b5d
commit
45442f7367
1 changed files with 16 additions and 0 deletions
|
@ -234,6 +234,11 @@ impl Schedule {
|
|||
&self.graph
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the [`ScheduleGraph`].
|
||||
pub fn graph_mut(&mut self) -> &mut ScheduleGraph {
|
||||
&mut self.graph
|
||||
}
|
||||
|
||||
/// Iterates the change ticks of all systems in the schedule and clamps any older than
|
||||
/// [`MAX_CHANGE_AGE`](crate::change_detection::MAX_CHANGE_AGE).
|
||||
/// This prevents overflow and thus prevents false positives.
|
||||
|
@ -377,6 +382,7 @@ pub struct ScheduleGraph {
|
|||
ambiguous_with: UnGraphMap<NodeId, ()>,
|
||||
ambiguous_with_flattened: UnGraphMap<NodeId, ()>,
|
||||
ambiguous_with_all: HashSet<NodeId>,
|
||||
conflicting_systems: Vec<(NodeId, NodeId, Vec<ComponentId>)>,
|
||||
changed: bool,
|
||||
settings: ScheduleBuildSettings,
|
||||
default_base_set: Option<BoxedSystemSet>,
|
||||
|
@ -398,6 +404,7 @@ impl ScheduleGraph {
|
|||
ambiguous_with: UnGraphMap::new(),
|
||||
ambiguous_with_flattened: UnGraphMap::new(),
|
||||
ambiguous_with_all: HashSet::new(),
|
||||
conflicting_systems: Vec::new(),
|
||||
changed: false,
|
||||
settings: default(),
|
||||
default_base_set: None,
|
||||
|
@ -500,6 +507,14 @@ impl ScheduleGraph {
|
|||
&self.dependency
|
||||
}
|
||||
|
||||
/// Returns the list of systems that conflict with each other, i.e. have ambiguities in their access.
|
||||
///
|
||||
/// If the `Vec<ComponentId>` is empty, the systems conflict on [`World`] access.
|
||||
/// Must be called after [`ScheduleGraph::build_schedule`] to be non-empty.
|
||||
pub fn conflicting_systems(&self) -> &[(NodeId, NodeId, Vec<ComponentId>)] {
|
||||
&self.conflicting_systems
|
||||
}
|
||||
|
||||
fn add_systems<P>(&mut self, systems: impl IntoSystemConfigs<P>) {
|
||||
let SystemConfigs { systems, chained } = systems.into_configs();
|
||||
let mut system_iter = systems.into_iter();
|
||||
|
@ -1149,6 +1164,7 @@ impl ScheduleGraph {
|
|||
return Err(ScheduleBuildError::Ambiguity);
|
||||
}
|
||||
}
|
||||
self.conflicting_systems = conflicting_systems;
|
||||
|
||||
// build the schedule
|
||||
let dg_system_ids = self.dependency_flattened.topsort.clone();
|
||||
|
|
Loading…
Reference in a new issue