Skip to content

Commit 0bce784

Browse files
committed
Cleanup system sets called labels (#7678)
# Objective We have a few old system labels that are now system sets but are still named or documented as labels. Documentation also generally mentioned system labels in some places. ## Solution - Clean up naming and documentation regarding system sets ## Migration Guide `PrepareAssetLabel` is now called `PrepareAssetSet`
1 parent f1c0850 commit 0bce784

File tree

15 files changed

+39
-39
lines changed

15 files changed

+39
-39
lines changed

.github/contributing/example_style_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ For more advice on writing examples, see the [relevant section](../../CONTRIBUTI
3838
4. In Queries, prefer `With<T>` filters over actually fetching unused data with `&T`.
3939
5. Prefer disjoint queries using `With` and `Without` over param sets when you need more than one query in a single system.
4040
6. Prefer structs with named fields over tuple structs except in the case of single-field wrapper types.
41-
7. Use enum-labels over string-labels for system / schedule / etc. labels.
41+
7. Use enum-labels over string-labels for app / schedule / etc. labels.
4242

4343
## "Feature" examples
4444

benches/benches/bevy_ecs/scheduling/schedule.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ pub fn build_schedule(criterion: &mut Criterion) {
6464
// Use multiple different kinds of label to ensure that dynamic dispatch
6565
// doesn't somehow get optimized away.
6666
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
67-
struct NumLabel(usize);
67+
struct NumSet(usize);
6868
#[derive(Debug, Clone, Copy, SystemSet, PartialEq, Eq, Hash)]
69-
struct DummyLabel;
69+
struct DummySet;
7070

71-
impl SystemSet for NumLabel {
71+
impl SystemSet for NumSet {
7272
fn dyn_clone(&self) -> Box<dyn SystemSet> {
7373
Box::new(self.clone())
7474
}
@@ -81,7 +81,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
8181
// Method: generate a set of `graph_size` systems which have a One True Ordering.
8282
// Add system to the schedule with full constraints. Hopefully this should be maximimally
8383
// difficult for bevy to figure out.
84-
let labels: Vec<_> = (0..1000).map(|i| NumLabel(i)).collect();
84+
let labels: Vec<_> = (0..1000).map(|i| NumSet(i)).collect();
8585

8686
// Benchmark graphs of different sizes.
8787
for graph_size in [100, 500, 1000] {
@@ -100,12 +100,12 @@ pub fn build_schedule(criterion: &mut Criterion) {
100100
group.bench_function(format!("{graph_size}_schedule"), |bencher| {
101101
bencher.iter(|| {
102102
let mut app = App::new();
103-
app.add_system(empty_system.in_set(DummyLabel));
103+
app.add_system(empty_system.in_set(DummySet));
104104

105105
// Build a fully-connected dependency graph describing the One True Ordering.
106106
// Not particularly realistic but this can be refined later.
107107
for i in 0..graph_size {
108-
let mut sys = empty_system.in_set(labels[i]).before(DummyLabel);
108+
let mut sys = empty_system.in_set(labels[i]).before(DummySet);
109109
for label in labels.iter().take(i) {
110110
sys = sys.after(*label);
111111
}

crates/bevy_app/src/app.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ impl App {
313313
/// for each state variant, an instance of [`apply_state_transition::<S>`] in
314314
/// [`CoreSet::StateTransitions`] so that transitions happen before [`CoreSet::Update`] and
315315
/// a instance of [`run_enter_schedule::<S>`] in [`CoreSet::StateTransitions`] with a
316-
/// with a [`run_once`](`run_once_condition`) condition to run the on enter schedule of the
316+
/// [`run_once`](`run_once_condition`) condition to run the on enter schedule of the
317317
/// initial state.
318318
///
319319
/// This also adds an [`OnUpdate`] system set for each state variant,
320-
/// which run during [`CoreSet::Update`] after the transitions are applied.
321-
/// These systems sets only run if the [`State<S>`] resource matches their label.
320+
/// which runs during [`CoreSet::Update`] after the transitions are applied.
321+
/// These system sets only run if the [`State<S>`] resource matches the respective state variant.
322322
///
323323
/// If you would like to control how other systems run based on the current state,
324324
/// you can emulate this behavior using the [`in_state`] [`Condition`](bevy_ecs::schedule::Condition).

crates/bevy_app/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl CoreSet {
124124
/// Sets up the base structure of [`CoreSchedule::Main`].
125125
///
126126
/// The sets defined in this enum are configured to run in order,
127-
/// and a copy of [`apply_system_buffers`] is inserted at each `*Flush` label.
127+
/// and a copy of [`apply_system_buffers`] is inserted into each `*Flush` set.
128128
pub fn base_schedule() -> Schedule {
129129
use CoreSet::*;
130130
let mut schedule = Schedule::new();
@@ -185,7 +185,7 @@ impl StartupSet {
185185
/// Sets up the base structure of [`CoreSchedule::Startup`].
186186
///
187187
/// The sets defined in this enum are configured to run in order,
188-
/// and a copy of [`apply_system_buffers`] is inserted at each `*Flush` label.
188+
/// and a copy of [`apply_system_buffers`] is inserted into each `*Flush` set.
189189
pub fn base_schedule() -> Schedule {
190190
use StartupSet::*;
191191
let mut schedule = Schedule::new();

crates/bevy_asset/src/debug_asset_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl DerefMut for DebugAssetApp {
3232
}
3333
}
3434

35-
/// A label describing the system that runs [`DebugAssetApp`].
35+
/// A set containing the system that runs [`DebugAssetApp`].
3636
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
3737
pub struct DebugAssetAppRun;
3838

crates/bevy_ecs/macros/src/set.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use syn::parse::{Parse, ParseStream};
55
pub static SYSTEM_SET_ATTRIBUTE_NAME: &str = "system_set";
66
pub static BASE_ATTRIBUTE_NAME: &str = "base";
77

8-
/// Derive a label trait
8+
/// Derive a set trait
99
///
1010
/// # Args
1111
///
12-
/// - `input`: The [`syn::DeriveInput`] for struct that is deriving the label trait
13-
/// - `trait_path`: The path [`syn::Path`] to the label trait
12+
/// - `input`: The [`syn::DeriveInput`] for the struct that we want to derive the set trait for
13+
/// - `trait_path`: The [`syn::Path`] to the set trait
1414
pub fn derive_set(input: syn::DeriveInput, trait_path: &syn::Path) -> TokenStream {
1515
let ident = input.ident;
1616

crates/bevy_pbr/src/material.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use bevy_render::{
2121
extract_component::ExtractComponentPlugin,
2222
mesh::{Mesh, MeshVertexBufferLayout},
2323
prelude::Image,
24-
render_asset::{PrepareAssetLabel, RenderAssets},
24+
render_asset::{PrepareAssetSet, RenderAssets},
2525
render_phase::{
2626
AddRenderCommand, DrawFunctions, PhaseItem, RenderCommand, RenderCommandResult,
2727
RenderPhase, SetItemPipeline, TrackedRenderPass,
@@ -199,7 +199,7 @@ where
199199
.add_system(
200200
prepare_materials::<M>
201201
.in_set(RenderSet::Prepare)
202-
.after(PrepareAssetLabel::PreAssetPrepare),
202+
.after(PrepareAssetSet::PreAssetPrepare),
203203
)
204204
.add_system(queue_material_meshes::<M>.in_set(RenderSet::Queue));
205205
}

crates/bevy_render/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl RenderSet {
105105
/// Sets up the base structure of the rendering [`Schedule`].
106106
///
107107
/// The sets defined in this enum are configured to run in order,
108-
/// and a copy of [`apply_system_buffers`] is inserted at each `*Flush` label.
108+
/// and a copy of [`apply_system_buffers`] is inserted into each `*Flush` set.
109109
pub fn base_schedule() -> Schedule {
110110
use RenderSet::*;
111111

crates/bevy_render/src/render_asset.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub trait RenderAsset: Asset {
4141
}
4242

4343
#[derive(Clone, Hash, Debug, Default, PartialEq, Eq, SystemSet)]
44-
pub enum PrepareAssetLabel {
44+
pub enum PrepareAssetSet {
4545
PreAssetPrepare,
4646
#[default]
4747
AssetPrepare,
@@ -54,14 +54,14 @@ pub enum PrepareAssetLabel {
5454
/// Therefore it sets up the [`ExtractSchedule`](crate::ExtractSchedule) and
5555
/// [`RenderSet::Prepare`](crate::RenderSet::Prepare) steps for the specified [`RenderAsset`].
5656
pub struct RenderAssetPlugin<A: RenderAsset> {
57-
prepare_asset_label: PrepareAssetLabel,
57+
prepare_asset_set: PrepareAssetSet,
5858
phantom: PhantomData<fn() -> A>,
5959
}
6060

6161
impl<A: RenderAsset> RenderAssetPlugin<A> {
62-
pub fn with_prepare_asset_label(prepare_asset_label: PrepareAssetLabel) -> Self {
62+
pub fn with_prepare_asset_set(prepare_asset_set: PrepareAssetSet) -> Self {
6363
Self {
64-
prepare_asset_label,
64+
prepare_asset_set,
6565
phantom: PhantomData,
6666
}
6767
}
@@ -70,7 +70,7 @@ impl<A: RenderAsset> RenderAssetPlugin<A> {
7070
impl<A: RenderAsset> Default for RenderAssetPlugin<A> {
7171
fn default() -> Self {
7272
Self {
73-
prepare_asset_label: Default::default(),
73+
prepare_asset_set: Default::default(),
7474
phantom: PhantomData,
7575
}
7676
}
@@ -82,9 +82,9 @@ impl<A: RenderAsset> Plugin for RenderAssetPlugin<A> {
8282
render_app
8383
.configure_sets(
8484
(
85-
PrepareAssetLabel::PreAssetPrepare,
86-
PrepareAssetLabel::AssetPrepare,
87-
PrepareAssetLabel::PostAssetPrepare,
85+
PrepareAssetSet::PreAssetPrepare,
86+
PrepareAssetSet::AssetPrepare,
87+
PrepareAssetSet::PostAssetPrepare,
8888
)
8989
.chain()
9090
.in_set(RenderSet::Prepare),
@@ -93,7 +93,7 @@ impl<A: RenderAsset> Plugin for RenderAssetPlugin<A> {
9393
.init_resource::<RenderAssets<A>>()
9494
.init_resource::<PrepareNextFrameAssets<A>>()
9595
.add_system_to_schedule(ExtractSchedule, extract_render_asset::<A>)
96-
.add_system(prepare_assets::<A>.in_set(self.prepare_asset_label.clone()));
96+
.add_system(prepare_assets::<A>.in_set(self.prepare_asset_set.clone()));
9797
}
9898
}
9999
}

crates/bevy_render/src/texture/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use image_texture_loader::*;
2727
pub use texture_cache::*;
2828

2929
use crate::{
30-
render_asset::{PrepareAssetLabel, RenderAssetPlugin},
30+
render_asset::{PrepareAssetSet, RenderAssetPlugin},
3131
renderer::RenderDevice,
3232
RenderApp, RenderSet,
3333
};
@@ -84,8 +84,8 @@ impl Plugin for ImagePlugin {
8484
app.init_asset_loader::<HdrTextureLoader>();
8585
}
8686

87-
app.add_plugin(RenderAssetPlugin::<Image>::with_prepare_asset_label(
88-
PrepareAssetLabel::PreAssetPrepare,
87+
app.add_plugin(RenderAssetPlugin::<Image>::with_prepare_asset_set(
88+
PrepareAssetSet::PreAssetPrepare,
8989
))
9090
.register_type::<Image>()
9191
.add_asset::<Image>()

0 commit comments

Comments
 (0)