Run individual SystemSets in Schedules#21893
Run individual SystemSets in Schedules#21893ItsDoot wants to merge 9 commits intobevyengine:mainfrom
SystemSets in Schedules#21893Conversation
|
I don't feel qualified to review the code per-se, but I want to express my support for this PR. Yeeting schedules would be lovely, and this looks like a great step in this direction :) |
cBournhonesque
left a comment
There was a problem hiding this comment.
This is great!
I've always wanted this functionality; I actually an old PR that did the same for system-stepping: #13219
I also want to blur the distinction between Schedules and SystemSet; as for me schedules are basically a big system-set and it can be confusing to have both concepts
cBournhonesque
left a comment
There was a problem hiding this comment.
LGTM! Can we add one test where a system is added/removed?
hymm
left a comment
There was a problem hiding this comment.
This seems like somewhat niche functionality as running part of a schedule seems like a footgun outside of unit tests. But the added complexity and perf hit is not too significant so I'm fine with adding this. Just have a few nits.
Indirectly contributes to #16432
Indirectly contributes to #9792
schedules into system sets by giving system sets a power that previously only schedules had: the ability to be executed.
I don't understand how this pr contributes to these. Seems mostly orthogonal to me.
fd2c28d to
edff0a7
Compare
|
@hymm if we want to remove schedules and replace them with system sets, we need a way to replace |
|
Yea I expect that if we eventually merge |
|
Marked as contentious: on its own, this is niche and not too controversial. The broader plan of unifying all of the |
|
@ItsDoot, can you resolve merge conflicts? Then I'll get back to you with a review. |
Objective
app::run_system_set()function #12717Bevy users occasionally ask for the ability to run specific
SystemSets in aSchedule, commonly for unit testing behaviors. Beyond that, this functionality brings us closer to turning ourUpdate,PostUpdate, etc schedules into system sets by giving system sets a power that previously only schedules had: the ability to be executed.Solution
SystemExecutor::run:subgraph: Option<SystemSetKey>Some, the providedSystemSetKeyis used to fetch a bitset of the systems that are part of the set (including transitively), which is used to filter theSystemExecutorto execute only those systems.None, theSystemExecutorfunctions as previously.SystemSchedule::systems_in_setwhich holds a sparse mapping of system sets to bitsets of the systems part of that set.Schedule::run_system_setwhich invokesSystemExecutor::runwith the given system set.World/Commands::run_system_set/try_run_system_setwhich invokesSchedule::run_system_set.Note:
Schedule::run_system_setis not re-entrant.Testing
Future work
slotmap::SparseSecondaryMapwork under alloc rather than std, so we can replaceSystemSchedule::systems_in_sets'sHashMapwith it.Showcase
You can now run a specific system set within a schedule without executing the entire
schedule! This is particularly useful for testing, debugging, or selectively running
parts of your game logic, all without needing to factor features out into separate
schedules: