bevy/crates/bevy_ecs/src/schedule
Zhixing Zhang f2a65c2dd3
Schedule build pass (#11094)
# Objective

This is a follow up to #9822, which automatically adds sync points
during the Schedule build process.

However, the implementation in #9822 feels very "special case" to me. As
the number of things we want to do with the `Schedule` grows, we need a
modularized way to manage those behaviors. For example, in one of my
current experiments I want to automatically add systems to apply GPU
pipeline barriers between systems accessing GPU resources.

For dynamic modifications of the schedule, we mostly need these
capabilities:
- Storing custom data on schedule edges
- Storing custom data on schedule nodes
- Modify the schedule graph whenever it builds

These should be enough to allows us to add "hooks" to the schedule build
process for various reasons.

cc @hymm 

## Solution
This PR abstracts the process of schedule modification and created a new
trait, `ScheduleBuildPass`. Most of the logics in #9822 were moved to an
implementation of `ScheduleBuildPass`, `AutoInsertApplyDeferredPass`.

Whether a dependency edge should "ignore deferred" is now indicated by
the presence of a marker struct, `IgnoreDeferred`.

This PR has no externally visible effects. However, in a future PR I
propose to change the `before_ignore_deferred` and
`after_ignore_deferred` API into a more general form,
`before_with_options` and `after_with_options`.

```rs
schedule.add_systems(
    system.before_with_options(another_system, IgnoreDeferred)
);

schedule.add_systems(
    system.before_with_options(another_system, (
        IgnoreDeferred,
        AnyOtherOption {
            key: value
        }
    ))
);

schedule.add_systems(
    system.before_with_options(another_system, ())
);
```
2025-02-05 23:14:05 +00:00
..
executor Create bevy_platform_support Crate (#17250) 2025-01-20 20:45:30 +00:00
graph Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
auto_insert_apply_deferred.rs Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
condition.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
config.rs Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
mod.rs Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
pass.rs Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
schedule.rs Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
set.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
stepping.rs Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00