From db5372ef49a62666e4c5f6b148b5ae56fff6b3a3 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 31 May 2023 11:48:09 -0400 Subject: [PATCH 01/10] Rename apply_system_buffers to apply_deferred --- CHANGELOG.md | 2 +- Cargo.toml | 8 +- crates/bevy_ecs/src/event.rs | 2 +- crates/bevy_ecs/src/lib.rs | 2 +- crates/bevy_ecs/src/schedule/executor/mod.rs | 8 +- .../src/schedule/executor/multi_threaded.rs | 10 +- .../src/schedule/executor/single_threaded.rs | 12 +- crates/bevy_ecs/src/schedule/schedule.rs | 4 +- crates/bevy_ecs/src/system/commands/mod.rs | 10 +- crates/bevy_ecs/src/system/mod.rs | 4 +- crates/bevy_ecs/src/system/system_param.rs | 8 +- crates/bevy_pbr/src/lib.rs | 4 +- crates/bevy_pbr/src/prepass/mod.rs | 2 +- crates/bevy_render/src/lib.rs | 32 +- crates/bevy_render/src/view/visibility/mod.rs | 5 +- crates/bevy_transform/src/commands.rs | 4 +- examples/README.md | 454 +++++++++--------- examples/ecs/apply_system_buffers.rs | 8 +- examples/ecs/removal_detection.rs | 2 +- 19 files changed, 288 insertions(+), 293 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ade264b8a6473..958ee68c62abf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ current changes on git with [previous release tags][git_tag_comparison]. - [ECS: Add a missing impl of `ReadOnlySystemParam` for `Option>`][7245] - [ECS: add a spawn_on_external method to allow spawning on the scope’s thread or an external thread][7415] - [ECS: Add const `Entity::PLACEHOLDER`][6761] -- [ECS: Add example to show how to use `apply_system_buffers`][7793] +- [ECS: Add example to show how to use `apply_deferred`][7793] - [ECS: Add logging variants of system piping][6751] - [ECS: Add safe constructors for untyped pointers `Ptr` and `PtrMut`][6539] - [ECS: Add unit test with system that panics][7491] diff --git a/Cargo.toml b/Cargo.toml index 70817549915b7..777408de0dace 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1043,12 +1043,12 @@ category = "ECS (Entity Component System)" wasm = false [[example]] -name = "apply_system_buffers" -path = "examples/ecs/apply_system_buffers.rs" +name = "apply_deferred" +path = "examples/ecs/apply_deferred.rs" -[package.metadata.example.apply_system_buffers] +[package.metadata.example.apply_deferred] name = "Apply System Buffers" -description = "Show how to use `apply_system_buffers` system" +description = "Show how to use `apply_deferred` system" category = "ECS (Entity Component System)" wasm = false diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 998c7174c5f83..3be628eb08e2b 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -316,7 +316,7 @@ impl<'a, 'w, 's, E: Event> IntoIterator for &'a mut EventReader<'w, 's, E> { /// // custom events to unknown 3rd party plugins (modding API). /// // /// // NOTE: the event won't actually be sent until commands get applied during -/// // apply_system_buffers. +/// // apply_deferred. /// commands.add(|w: &mut World| { /// w.send_event(MyEvent); /// }); diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 67a65ee64e7c0..1ad0156801058 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -39,7 +39,7 @@ pub mod prelude { query::{Added, AnyOf, Changed, Or, QueryState, With, Without}, removal_detection::RemovedComponents, schedule::{ - apply_state_transition, apply_system_buffers, common_conditions::*, Condition, + apply_deferred, apply_state_transition, common_conditions::*, Condition, IntoSystemConfigs, IntoSystemSet, IntoSystemSetConfig, IntoSystemSetConfigs, NextState, OnEnter, OnExit, OnTransition, Schedule, Schedules, State, States, SystemSet, }, diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index 15c2f1536e6c0..e7150473ae092 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -84,11 +84,11 @@ impl SystemSchedule { /// - This function (currently) does nothing if it's called manually or wrapped inside a [`PipeSystem`](crate::system::PipeSystem). /// - Modifying a [`Schedule`](super::Schedule) may change the order buffers are applied. #[allow(unused_variables)] -pub fn apply_system_buffers(world: &mut World) {} +pub fn apply_deferred(world: &mut World) {} -/// Returns `true` if the [`System`](crate::system::System) is an instance of [`apply_system_buffers`]. -pub(super) fn is_apply_system_buffers(system: &BoxedSystem) -> bool { +/// Returns `true` if the [`System`](crate::system::System) is an instance of [`apply_deferred`]. +pub(super) fn is_apply_deferred(system: &BoxedSystem) -> bool { use std::any::Any; // deref to use `System::type_id` instead of `Any::type_id` - system.as_ref().type_id() == apply_system_buffers.type_id() + system.as_ref().type_id() == apply_deferred.type_id() } diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 569320c03117d..06707706801c7 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -18,7 +18,7 @@ use crate::{ prelude::Resource, query::Access, schedule::{ - is_apply_system_buffers, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, + is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, }, system::BoxedSystem, world::{unsafe_world_cell::UnsafeWorldCell, World}, @@ -233,7 +233,7 @@ impl SystemExecutor for MultiThreadedExecutor { if self.apply_final_buffers { // Do one final apply buffers after all systems have completed // Commands should be applied while on the scope's thread, not the executor's thread - let res = apply_system_buffers(&self.unapplied_systems, systems, world); + let res = apply_deferred(&self.unapplied_systems, systems, world); if let Err(payload) = res { let mut panic_payload = self.panic_payload.lock().unwrap(); *panic_payload = Some(payload); @@ -556,14 +556,14 @@ impl MultiThreadedExecutor { let sender = self.sender.clone(); let panic_payload = self.panic_payload.clone(); - if is_apply_system_buffers(system) { + if is_apply_deferred(system) { // TODO: avoid allocation let unapplied_systems = self.unapplied_systems.clone(); self.unapplied_systems.clear(); let task = async move { #[cfg(feature = "trace")] let system_guard = system_span.enter(); - let res = apply_system_buffers(&unapplied_systems, systems, world); + let res = apply_deferred(&unapplied_systems, systems, world); #[cfg(feature = "trace")] drop(system_guard); // tell the executor that the system finished @@ -681,7 +681,7 @@ impl MultiThreadedExecutor { } } -fn apply_system_buffers( +fn apply_deferred( unapplied_systems: &FixedBitSet, systems: &[SyncUnsafeCell], world: &mut World, diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index 0bd3c8dca6fc2..222afd48e3b6d 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -4,9 +4,7 @@ use fixedbitset::FixedBitSet; use std::panic::AssertUnwindSafe; use crate::{ - schedule::{ - is_apply_system_buffers, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, - }, + schedule::{is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, world::World, }; @@ -87,10 +85,10 @@ impl SystemExecutor for SingleThreadedExecutor { } let system = &mut schedule.systems[system_index]; - if is_apply_system_buffers(system) { + if is_apply_deferred(system) { #[cfg(feature = "trace")] let system_span = info_span!("system", name = &*name).entered(); - self.apply_system_buffers(schedule, world); + self.apply_deferred(schedule, world); #[cfg(feature = "trace")] system_span.exit(); } else { @@ -110,7 +108,7 @@ impl SystemExecutor for SingleThreadedExecutor { } if self.apply_final_buffers { - self.apply_system_buffers(schedule, world); + self.apply_deferred(schedule, world); } self.evaluated_sets.clear(); self.completed_systems.clear(); @@ -127,7 +125,7 @@ impl SingleThreadedExecutor { } } - fn apply_system_buffers(&mut self, schedule: &mut SystemSchedule, world: &mut World) { + fn apply_deferred(&mut self, schedule: &mut SystemSchedule, world: &mut World) { for system_index in self.unapplied_systems.ones() { let system = &mut schedule.systems[system_index]; system.apply_buffers(world); diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 2312fa5cc0fad..03c6fe2174317 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -221,7 +221,7 @@ impl Schedule { /// Set whether the schedule applies buffers on final time or not. This is a catchall /// incase a system uses commands but was not explicitly ordered after a - /// [`apply_system_buffers`](crate::prelude::apply_system_buffers). By default this + /// [`apply_deferred`](crate::prelude::apply_deferred). By default this /// setting is true, but may be disabled if needed. pub fn set_apply_final_buffers(&mut self, apply_final_buffers: bool) -> &mut Self { self.executor.set_apply_final_buffers(apply_final_buffers); @@ -295,7 +295,7 @@ impl Schedule { /// /// This is used in rendering to extract data from the main world, storing the data in system buffers, /// before applying their buffers in a different world. - pub fn apply_system_buffers(&mut self, world: &mut World) { + pub fn apply_deferred(&mut self, world: &mut World) { for system in &mut self.executable.systems { system.apply_buffers(world); } diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index e5db31f50b8a0..bf1374ac01871 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -50,11 +50,11 @@ pub trait Command: Send + 'static { /// /// Since each command requires exclusive access to the `World`, /// all queued commands are automatically applied in sequence -/// when the [`apply_system_buffers`] system runs. +/// when the [`apply_deferred`] system runs. /// /// The command queue of an individual system can also be manually applied /// by calling [`System::apply_buffers`]. -/// Similarly, the command queue of a schedule can be manually applied via [`Schedule::apply_system_buffers`]. +/// Similarly, the command queue of a schedule can be manually applied via [`Schedule::apply_deferred`]. /// /// Each command can be used to modify the [`World`] in arbitrary ways: /// * spawning or despawning entities @@ -68,7 +68,7 @@ pub trait Command: Send + 'static { /// /// # Usage /// -/// Add `mut commands: Commands` as a function argument to your system to get a copy of this struct that will be applied the next time a copy of [`apply_system_buffers`] runs. +/// Add `mut commands: Commands` as a function argument to your system to get a copy of this struct that will be applied the next time a copy of [`apply_deferred`] runs. /// Commands are almost always used as a [`SystemParam`](crate::system::SystemParam). /// /// ``` @@ -101,8 +101,8 @@ pub trait Command: Send + 'static { /// ``` /// /// [`System::apply_buffers`]: crate::system::System::apply_buffers -/// [`apply_system_buffers`]: crate::schedule::apply_system_buffers -/// [`Schedule::apply_system_buffers`]: crate::schedule::Schedule::apply_system_buffers +/// [`apply_deferred`]: crate::schedule::apply_deferred +/// [`Schedule::apply_deferred`]: crate::schedule::Schedule::apply_deferred #[derive(SystemParam)] pub struct Commands<'w, 's> { queue: Deferred<'s, CommandQueue>, diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 9bb99138da733..942157a0ca6f8 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -491,7 +491,7 @@ mod tests { prelude::AnyOf, query::{Added, Changed, Or, With, Without}, removal_detection::RemovedComponents, - schedule::{apply_system_buffers, IntoSystemConfigs, Schedule}, + schedule::{apply_deferred, IntoSystemConfigs, Schedule}, system::{ adapter::new, Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, QueryComponentError, Res, ResMut, Resource, System, SystemState, @@ -717,7 +717,7 @@ mod tests { let mut schedule = Schedule::default(); - schedule.add_systems((incr_e_on_flip, apply_system_buffers, World::clear_trackers).chain()); + schedule.add_systems((incr_e_on_flip, apply_deferred, World::clear_trackers).chain()); schedule.run(&mut world); assert_eq!(world.resource::().0, 1); diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index ea35eb06c82ee..5800c5780ccca 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -118,7 +118,7 @@ pub unsafe trait SystemParam: Sized { } /// Applies any deferred mutations stored in this [`SystemParam`]'s state. - /// This is used to apply [`Commands`] during [`apply_system_buffers`](crate::prelude::apply_system_buffers). + /// This is used to apply [`Commands`] during [`apply_deferred`](crate::prelude::apply_deferred). /// /// [`Commands`]: crate::prelude::Commands #[inline] @@ -766,7 +766,7 @@ pub trait SystemBuffer: FromWorld + Send + 'static { } /// A [`SystemParam`] that stores a buffer which gets applied to the [`World`] during -/// [`apply_system_buffers`](crate::schedule::apply_system_buffers). +/// [`apply_deferred`](crate::schedule::apply_deferred). /// This is used internally by [`Commands`] to defer `World` mutations. /// /// [`Commands`]: crate::system::Commands @@ -809,7 +809,7 @@ pub trait SystemBuffer: FromWorld + Send + 'static { /// struct AlarmFlag(bool); /// /// impl AlarmFlag { -/// /// Sounds the alarm the next time buffers are applied via apply_system_buffers. +/// /// Sounds the alarm the next time buffers are applied via apply_deferred. /// pub fn flag(&mut self) { /// self.0 = true; /// } @@ -817,7 +817,7 @@ pub trait SystemBuffer: FromWorld + Send + 'static { /// /// impl SystemBuffer for AlarmFlag { /// // When `AlarmFlag` is used in a system, this function will get -/// // called the next time buffers are applied via apply_system_buffers. +/// // called the next time buffers are applied via apply_deferred. /// fn apply(&mut self, system_meta: &SystemMeta, world: &mut World) { /// if self.0 { /// world.resource_mut::().0 = true; diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 140364787bd9a..cf33d33e330ad 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -202,7 +202,7 @@ impl Plugin for PbrPlugin { PostUpdate, ( add_clusters.in_set(SimulationLightSystems::AddClusters), - apply_system_buffers.in_set(SimulationLightSystems::AddClustersFlush), + apply_deferred.in_set(SimulationLightSystems::AddClustersFlush), assign_lights_to_clusters .in_set(SimulationLightSystems::AssignLightsToClusters) .after(TransformSystem::TransformPropagate) @@ -283,7 +283,7 @@ impl Plugin for PbrPlugin { .in_set(RenderLightSystems::PrepareLights), // A sync is needed after prepare_lights, before prepare_view_uniforms, // because prepare_lights creates new views for shadow mapping - apply_system_buffers + apply_deferred .in_set(RenderSet::Prepare) .after(RenderLightSystems::PrepareLights) .before(ViewSet::PrepareUniforms), diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 9307bc0d75aa9..077f59b307be0 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -165,7 +165,7 @@ where prepare_previous_view_projection_uniforms .in_set(RenderSet::Prepare) .after(PrepassLightsViewFlush), - apply_system_buffers + apply_deferred .in_set(RenderSet::Prepare) .in_set(PrepassLightsViewFlush) .after(prepare_lights), diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index f04e9eb230445..2a6947f0b8e87 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -72,39 +72,39 @@ pub struct RenderPlugin { /// The labels of the default App rendering sets. /// -/// The sets run in the order listed, with [`apply_system_buffers`] inserted between each set. +/// The sets run in the order listed, with [`apply_deferred`] inserted between each set. /// -/// The `*Flush` sets are assigned to the copy of [`apply_system_buffers`] +/// The `*Flush` sets are assigned to the copy of [`apply_deferred`] /// that runs immediately after the matching system set. /// These can be useful for ordering, but you almost never want to add your systems to these sets. #[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] pub enum RenderSet { - /// The copy of [`apply_system_buffers`] that runs at the beginning of this schedule. + /// The copy of [`apply_deferred`] that runs at the beginning of this schedule. /// This is used for applying the commands from the [`ExtractSchedule`] ExtractCommands, /// Prepare render resources from the extracted data for the GPU. Prepare, - /// The copy of [`apply_system_buffers`] that runs immediately after [`Prepare`](RenderSet::Prepare). + /// The copy of [`apply_deferred`] that runs immediately after [`Prepare`](RenderSet::Prepare). PrepareFlush, /// Create [`BindGroups`](render_resource::BindGroup) that depend on /// [`Prepare`](RenderSet::Prepare) data and queue up draw calls to run during the /// [`Render`](RenderSet::Render) step. Queue, - /// The copy of [`apply_system_buffers`] that runs immediately after [`Queue`](RenderSet::Queue). + /// The copy of [`apply_deferred`] that runs immediately after [`Queue`](RenderSet::Queue). QueueFlush, // TODO: This could probably be moved in favor of a system ordering abstraction in Render or Queue /// Sort the [`RenderPhases`](render_phase::RenderPhase) here. PhaseSort, - /// The copy of [`apply_system_buffers`] that runs immediately after [`PhaseSort`](RenderSet::PhaseSort). + /// The copy of [`apply_deferred`] that runs immediately after [`PhaseSort`](RenderSet::PhaseSort). PhaseSortFlush, /// Actual rendering happens here. /// In most cases, only the render backend should insert resources here. Render, - /// The copy of [`apply_system_buffers`] that runs immediately after [`Render`](RenderSet::Render). + /// The copy of [`apply_deferred`] that runs immediately after [`Render`](RenderSet::Render). RenderFlush, /// Cleanup render resources here. Cleanup, - /// The copy of [`apply_system_buffers`] that runs immediately after [`Cleanup`](RenderSet::Cleanup). + /// The copy of [`apply_deferred`] that runs immediately after [`Cleanup`](RenderSet::Cleanup). CleanupFlush, } @@ -116,7 +116,7 @@ impl Render { /// Sets up the base structure of the rendering [`Schedule`]. /// /// The sets defined in this enum are configured to run in order, - /// and a copy of [`apply_system_buffers`] is inserted into each `*Flush` set. + /// and a copy of [`apply_deferred`] is inserted into each `*Flush` set. pub fn base_schedule() -> Schedule { use RenderSet::*; @@ -124,11 +124,11 @@ impl Render { // Create "stage-like" structure using buffer flushes + ordering schedule.add_systems(( - apply_system_buffers.in_set(PrepareFlush), - apply_system_buffers.in_set(QueueFlush), - apply_system_buffers.in_set(PhaseSortFlush), - apply_system_buffers.in_set(RenderFlush), - apply_system_buffers.in_set(CleanupFlush), + apply_deferred.in_set(PrepareFlush), + apply_deferred.in_set(QueueFlush), + apply_deferred.in_set(PhaseSortFlush), + apply_deferred.in_set(RenderFlush), + apply_deferred.in_set(CleanupFlush), )); schedule.configure_sets( @@ -158,7 +158,7 @@ impl Render { /// running the next frame while rendering the current frame. /// /// This schedule is run on the main world, but its buffers are not applied -/// via [`Schedule::apply_system_buffers`](bevy_ecs::schedule::Schedule) until it is returned to the render world. +/// via [`Schedule::apply_deferred`](bevy_ecs::schedule::Schedule) until it is returned to the render world. #[derive(ScheduleLabel, PartialEq, Eq, Debug, Clone, Hash)] pub struct ExtractSchedule; @@ -404,6 +404,6 @@ fn apply_extract_commands(render_world: &mut World) { schedules .get_mut(&ExtractSchedule) .unwrap() - .apply_system_buffers(render_world); + .apply_deferred(render_world); }); } diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 9521c1567e5d5..7afa0e95f99d9 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -212,10 +212,7 @@ impl Plugin for VisibilityPlugin { app // We add an AABB component in CalculateBounds, which must be ready on the same frame. - .add_systems( - PostUpdate, - apply_system_buffers.in_set(CalculateBoundsFlush), - ) + .add_systems(PostUpdate, apply_deferred.in_set(CalculateBoundsFlush)) .configure_set(PostUpdate, CalculateBoundsFlush.after(CalculateBounds)) .add_systems( PostUpdate, diff --git a/crates/bevy_transform/src/commands.rs b/crates/bevy_transform/src/commands.rs index 7a5a7b2c02f88..ee005a62536a1 100644 --- a/crates/bevy_transform/src/commands.rs +++ b/crates/bevy_transform/src/commands.rs @@ -74,7 +74,7 @@ pub trait BuildChildrenTransformExt { /// /// Note that both the hierarchy and transform updates will only execute /// the next time commands are applied - /// (during [`apply_system_buffers`](bevy_ecs::schedule::apply_system_buffers)). + /// (during [`apply_deferred`](bevy_ecs::schedule::apply_deferred)). fn set_parent_in_place(&mut self, parent: Entity) -> &mut Self; /// Make this entity parentless while preserving this entity's [`GlobalTransform`] @@ -85,7 +85,7 @@ pub trait BuildChildrenTransformExt { /// /// Note that both the hierarchy and transform updates will only execute /// the next time commands are applied - /// (during [`apply_system_buffers`](bevy_ecs::schedule::apply_system_buffers)). + /// (during [`apply_deferred`](bevy_ecs::schedule::apply_deferred)). fn remove_parent_in_place(&mut self) -> &mut Self; } impl<'w, 's, 'a> BuildChildrenTransformExt for EntityCommands<'w, 's, 'a> { diff --git a/examples/README.md b/examples/README.md index 3e711817899c3..d8e71908fe355 100644 --- a/examples/README.md +++ b/examples/README.md @@ -81,192 +81,192 @@ git checkout v0.4.0 ## Hello, World! -Example | Description ---- | --- -[`hello_world.rs`](./hello_world.rs) | Runs a minimal example that outputs "hello world" +| Example | Description | +| ------------------------------------ | ------------------------------------------------- | +| [`hello_world.rs`](./hello_world.rs) | Runs a minimal example that outputs "hello world" | # Cross-Platform Examples ## 2D Rendering -Example | Description ---- | --- -[2D Bloom](../examples/2d/bloom_2d.rs) | Illustrates bloom post-processing in 2d -[2D Gizmos](../examples/2d/2d_gizmos.rs) | A scene showcasing 2D gizmos -[2D Rotation](../examples/2d/rotation.rs) | Demonstrates rotating entities in 2D with quaternions -[2D Shapes](../examples/2d/2d_shapes.rs) | Renders a rectangle, circle, and hexagon -[Custom glTF vertex attribute 2D](../examples/2d/custom_gltf_vertex_attribute.rs) | Renders a glTF mesh in 2D with a custom vertex attribute -[Manual Mesh 2D](../examples/2d/mesh2d_manual.rs) | Renders a custom mesh "manually" with "mid-level" renderer apis -[Mesh 2D](../examples/2d/mesh2d.rs) | Renders a 2d mesh -[Mesh 2D With Vertex Colors](../examples/2d/mesh2d_vertex_color_texture.rs) | Renders a 2d mesh with vertex color attributes -[Move Sprite](../examples/2d/move_sprite.rs) | Changes the transform of a sprite -[Pixel Perfect](../examples/2d/pixel_perfect.rs) | Demonstrates pixel perfect in 2d -[Sprite](../examples/2d/sprite.rs) | Renders a sprite -[Sprite Flipping](../examples/2d/sprite_flipping.rs) | Renders a sprite flipped along an axis -[Sprite Sheet](../examples/2d/sprite_sheet.rs) | Renders an animated sprite -[Text 2D](../examples/2d/text2d.rs) | Generates text in 2D -[Texture Atlas](../examples/2d/texture_atlas.rs) | Generates a texture atlas (sprite sheet) from individual sprites -[Transparency in 2D](../examples/2d/transparency_2d.rs) | Demonstrates transparency in 2d +| Example | Description | +| --------------------------------------------------------------------------------- | ---------------------------------------------------------------- | +| [2D Bloom](../examples/2d/bloom_2d.rs) | Illustrates bloom post-processing in 2d | +| [2D Gizmos](../examples/2d/2d_gizmos.rs) | A scene showcasing 2D gizmos | +| [2D Rotation](../examples/2d/rotation.rs) | Demonstrates rotating entities in 2D with quaternions | +| [2D Shapes](../examples/2d/2d_shapes.rs) | Renders a rectangle, circle, and hexagon | +| [Custom glTF vertex attribute 2D](../examples/2d/custom_gltf_vertex_attribute.rs) | Renders a glTF mesh in 2D with a custom vertex attribute | +| [Manual Mesh 2D](../examples/2d/mesh2d_manual.rs) | Renders a custom mesh "manually" with "mid-level" renderer apis | +| [Mesh 2D](../examples/2d/mesh2d.rs) | Renders a 2d mesh | +| [Mesh 2D With Vertex Colors](../examples/2d/mesh2d_vertex_color_texture.rs) | Renders a 2d mesh with vertex color attributes | +| [Move Sprite](../examples/2d/move_sprite.rs) | Changes the transform of a sprite | +| [Pixel Perfect](../examples/2d/pixel_perfect.rs) | Demonstrates pixel perfect in 2d | +| [Sprite](../examples/2d/sprite.rs) | Renders a sprite | +| [Sprite Flipping](../examples/2d/sprite_flipping.rs) | Renders a sprite flipped along an axis | +| [Sprite Sheet](../examples/2d/sprite_sheet.rs) | Renders an animated sprite | +| [Text 2D](../examples/2d/text2d.rs) | Generates text in 2D | +| [Texture Atlas](../examples/2d/texture_atlas.rs) | Generates a texture atlas (sprite sheet) from individual sprites | +| [Transparency in 2D](../examples/2d/transparency_2d.rs) | Demonstrates transparency in 2d | ## 3D Rendering -Example | Description ---- | --- -[3D Bloom](../examples/3d/bloom_3d.rs) | Illustrates bloom configuration using HDR and emissive materials -[3D Gizmos](../examples/3d/3d_gizmos.rs) | A scene showcasing 3D gizmos -[3D Scene](../examples/3d/3d_scene.rs) | Simple 3D scene with basic shapes and lighting -[3D Shapes](../examples/3d/3d_shapes.rs) | A scene showcasing the built-in 3D shapes -[Anti-aliasing](../examples/3d/anti_aliasing.rs) | Compares different anti-aliasing methods -[Atmospheric Fog](../examples/3d/atmospheric_fog.rs) | A scene showcasing the atmospheric fog effect -[Blend Modes](../examples/3d/blend_modes.rs) | Showcases different blend modes -[Fog](../examples/3d/fog.rs) | A scene showcasing the distance fog effect -[Lighting](../examples/3d/lighting.rs) | Illustrates various lighting options in a simple scene -[Lines](../examples/3d/lines.rs) | Create a custom material to draw 3d lines -[Load glTF](../examples/3d/load_gltf.rs) | Loads and renders a glTF file as a scene -[Orthographic View](../examples/3d/orthographic.rs) | Shows how to create a 3D orthographic view (for isometric-look in games or CAD applications) -[Parallax Mapping](../examples/3d/parallax_mapping.rs) | Demonstrates use of a normal map and depth map for parallax mapping -[Parenting](../examples/3d/parenting.rs) | Demonstrates parent->child relationships and relative transformations -[Physically Based Rendering](../examples/3d/pbr.rs) | Demonstrates use of Physically Based Rendering (PBR) properties -[Render to Texture](../examples/3d/render_to_texture.rs) | Shows how to render to a texture, useful for mirrors, UI, or exporting images -[Shadow Biases](../examples/3d/shadow_biases.rs) | Demonstrates how shadow biases affect shadows in a 3d scene -[Shadow Caster and Receiver](../examples/3d/shadow_caster_receiver.rs) | Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene -[Skybox](../examples/3d/skybox.rs) | Load a cubemap texture onto a cube like a skybox and cycle through different compressed texture formats. -[Spherical Area Lights](../examples/3d/spherical_area_lights.rs) | Demonstrates how point light radius values affect light behavior -[Split Screen](../examples/3d/split_screen.rs) | Demonstrates how to render two cameras to the same window to accomplish "split screen" -[Spotlight](../examples/3d/spotlight.rs) | Illustrates spot lights -[Texture](../examples/3d/texture.rs) | Shows configuration of texture materials -[Tonemapping](../examples/3d/tonemapping.rs) | Compares tonemapping options -[Transparency in 3D](../examples/3d/transparency_3d.rs) | Demonstrates transparency in 3d -[Two Passes](../examples/3d/two_passes.rs) | Renders two 3d passes to the same window from different perspectives -[Update glTF Scene](../examples/3d/update_gltf_scene.rs) | Update a scene from a glTF file, either by spawning the scene as a child of another entity, or by accessing the entities of the scene -[Vertex Colors](../examples/3d/vertex_colors.rs) | Shows the use of vertex colors -[Wireframe](../examples/3d/wireframe.rs) | Showcases wireframe rendering +| Example | Description | +| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| [3D Bloom](../examples/3d/bloom_3d.rs) | Illustrates bloom configuration using HDR and emissive materials | +| [3D Gizmos](../examples/3d/3d_gizmos.rs) | A scene showcasing 3D gizmos | +| [3D Scene](../examples/3d/3d_scene.rs) | Simple 3D scene with basic shapes and lighting | +| [3D Shapes](../examples/3d/3d_shapes.rs) | A scene showcasing the built-in 3D shapes | +| [Anti-aliasing](../examples/3d/anti_aliasing.rs) | Compares different anti-aliasing methods | +| [Atmospheric Fog](../examples/3d/atmospheric_fog.rs) | A scene showcasing the atmospheric fog effect | +| [Blend Modes](../examples/3d/blend_modes.rs) | Showcases different blend modes | +| [Fog](../examples/3d/fog.rs) | A scene showcasing the distance fog effect | +| [Lighting](../examples/3d/lighting.rs) | Illustrates various lighting options in a simple scene | +| [Lines](../examples/3d/lines.rs) | Create a custom material to draw 3d lines | +| [Load glTF](../examples/3d/load_gltf.rs) | Loads and renders a glTF file as a scene | +| [Orthographic View](../examples/3d/orthographic.rs) | Shows how to create a 3D orthographic view (for isometric-look in games or CAD applications) | +| [Parallax Mapping](../examples/3d/parallax_mapping.rs) | Demonstrates use of a normal map and depth map for parallax mapping | +| [Parenting](../examples/3d/parenting.rs) | Demonstrates parent->child relationships and relative transformations | +| [Physically Based Rendering](../examples/3d/pbr.rs) | Demonstrates use of Physically Based Rendering (PBR) properties | +| [Render to Texture](../examples/3d/render_to_texture.rs) | Shows how to render to a texture, useful for mirrors, UI, or exporting images | +| [Shadow Biases](../examples/3d/shadow_biases.rs) | Demonstrates how shadow biases affect shadows in a 3d scene | +| [Shadow Caster and Receiver](../examples/3d/shadow_caster_receiver.rs) | Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene | +| [Skybox](../examples/3d/skybox.rs) | Load a cubemap texture onto a cube like a skybox and cycle through different compressed texture formats. | +| [Spherical Area Lights](../examples/3d/spherical_area_lights.rs) | Demonstrates how point light radius values affect light behavior | +| [Split Screen](../examples/3d/split_screen.rs) | Demonstrates how to render two cameras to the same window to accomplish "split screen" | +| [Spotlight](../examples/3d/spotlight.rs) | Illustrates spot lights | +| [Texture](../examples/3d/texture.rs) | Shows configuration of texture materials | +| [Tonemapping](../examples/3d/tonemapping.rs) | Compares tonemapping options | +| [Transparency in 3D](../examples/3d/transparency_3d.rs) | Demonstrates transparency in 3d | +| [Two Passes](../examples/3d/two_passes.rs) | Renders two 3d passes to the same window from different perspectives | +| [Update glTF Scene](../examples/3d/update_gltf_scene.rs) | Update a scene from a glTF file, either by spawning the scene as a child of another entity, or by accessing the entities of the scene | +| [Vertex Colors](../examples/3d/vertex_colors.rs) | Shows the use of vertex colors | +| [Wireframe](../examples/3d/wireframe.rs) | Showcases wireframe rendering | ## Animation -Example | Description ---- | --- -[Animated Fox](../examples/animation/animated_fox.rs) | Plays an animation from a skinned glTF -[Animated Transform](../examples/animation/animated_transform.rs) | Create and play an animation defined by code that operates on the `Transform` component -[Cubic Curve](../examples/animation/cubic_curve.rs) | Bezier curve example showing a cube following a cubic curve -[Custom Skinned Mesh](../examples/animation/custom_skinned_mesh.rs) | Skinned mesh example with mesh and joints data defined in code -[glTF Skinned Mesh](../examples/animation/gltf_skinned_mesh.rs) | Skinned mesh example with mesh and joints data loaded from a glTF file +| Example | Description | +| ------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| [Animated Fox](../examples/animation/animated_fox.rs) | Plays an animation from a skinned glTF | +| [Animated Transform](../examples/animation/animated_transform.rs) | Create and play an animation defined by code that operates on the `Transform` component | +| [Cubic Curve](../examples/animation/cubic_curve.rs) | Bezier curve example showing a cube following a cubic curve | +| [Custom Skinned Mesh](../examples/animation/custom_skinned_mesh.rs) | Skinned mesh example with mesh and joints data defined in code | +| [glTF Skinned Mesh](../examples/animation/gltf_skinned_mesh.rs) | Skinned mesh example with mesh and joints data loaded from a glTF file | ## Application -Example | Description ---- | --- -[Custom Loop](../examples/app/custom_loop.rs) | Demonstrates how to create a custom runner (to update an app manually) -[Drag and Drop](../examples/app/drag_and_drop.rs) | An example that shows how to handle drag and drop in an app -[Empty](../examples/app/empty.rs) | An empty application (does nothing) -[Empty with Defaults](../examples/app/empty_defaults.rs) | An empty application with default plugins -[Headless](../examples/app/headless.rs) | An application that runs without default plugins -[Logs](../examples/app/logs.rs) | Illustrate how to use generate log output -[No Renderer](../examples/app/no_renderer.rs) | An application that runs with default plugins and displays an empty window, but without an actual renderer -[Plugin](../examples/app/plugin.rs) | Demonstrates the creation and registration of a custom plugin -[Plugin Group](../examples/app/plugin_group.rs) | Demonstrates the creation and registration of a custom plugin group -[Return after Run](../examples/app/return_after_run.rs) | Show how to return to main after the Bevy app has exited -[Thread Pool Resources](../examples/app/thread_pool_resources.rs) | Creates and customizes the internal thread pool -[Without Winit](../examples/app/without_winit.rs) | Create an application without winit (runs single time, no event loop) +| Example | Description | +| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| [Custom Loop](../examples/app/custom_loop.rs) | Demonstrates how to create a custom runner (to update an app manually) | +| [Drag and Drop](../examples/app/drag_and_drop.rs) | An example that shows how to handle drag and drop in an app | +| [Empty](../examples/app/empty.rs) | An empty application (does nothing) | +| [Empty with Defaults](../examples/app/empty_defaults.rs) | An empty application with default plugins | +| [Headless](../examples/app/headless.rs) | An application that runs without default plugins | +| [Logs](../examples/app/logs.rs) | Illustrate how to use generate log output | +| [No Renderer](../examples/app/no_renderer.rs) | An application that runs with default plugins and displays an empty window, but without an actual renderer | +| [Plugin](../examples/app/plugin.rs) | Demonstrates the creation and registration of a custom plugin | +| [Plugin Group](../examples/app/plugin_group.rs) | Demonstrates the creation and registration of a custom plugin group | +| [Return after Run](../examples/app/return_after_run.rs) | Show how to return to main after the Bevy app has exited | +| [Thread Pool Resources](../examples/app/thread_pool_resources.rs) | Creates and customizes the internal thread pool | +| [Without Winit](../examples/app/without_winit.rs) | Create an application without winit (runs single time, no event loop) | ## Assets -Example | Description ---- | --- -[Asset Loading](../examples/asset/asset_loading.rs) | Demonstrates various methods to load assets -[Custom Asset](../examples/asset/custom_asset.rs) | Implements a custom asset loader -[Custom Asset IO](../examples/asset/custom_asset_io.rs) | Implements a custom asset io loader -[Hot Reloading of Assets](../examples/asset/hot_asset_reloading.rs) | Demonstrates automatic reloading of assets when modified on disk +| Example | Description | +| ------------------------------------------------------------------- | ---------------------------------------------------------------- | +| [Asset Loading](../examples/asset/asset_loading.rs) | Demonstrates various methods to load assets | +| [Custom Asset](../examples/asset/custom_asset.rs) | Implements a custom asset loader | +| [Custom Asset IO](../examples/asset/custom_asset_io.rs) | Implements a custom asset io loader | +| [Hot Reloading of Assets](../examples/asset/hot_asset_reloading.rs) | Demonstrates automatic reloading of assets when modified on disk | ## Async Tasks -Example | Description ---- | --- -[Async Compute](../examples/async_tasks/async_compute.rs) | How to use `AsyncComputeTaskPool` to complete longer running tasks -[External Source of Data on an External Thread](../examples/async_tasks/external_source_external_thread.rs) | How to use an external thread to run an infinite task and communicate with a channel +| Example | Description | +| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | +| [Async Compute](../examples/async_tasks/async_compute.rs) | How to use `AsyncComputeTaskPool` to complete longer running tasks | +| [External Source of Data on an External Thread](../examples/async_tasks/external_source_external_thread.rs) | How to use an external thread to run an infinite task and communicate with a channel | ## Audio -Example | Description ---- | --- -[Audio](../examples/audio/audio.rs) | Shows how to load and play an audio file -[Audio Control](../examples/audio/audio_control.rs) | Shows how to load and play an audio file, and control how it's played -[Decodable](../examples/audio/decodable.rs) | Shows how to create and register a custom audio source by implementing the `Decodable` type. -[Spatial Audio 2D](../examples/audio/spatial_audio_2d.rs) | Shows how to play spatial audio, and moving the emitter in 2D -[Spatial Audio 3D](../examples/audio/spatial_audio_3d.rs) | Shows how to play spatial audio, and moving the emitter in 3D +| Example | Description | +| --------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| [Audio](../examples/audio/audio.rs) | Shows how to load and play an audio file | +| [Audio Control](../examples/audio/audio_control.rs) | Shows how to load and play an audio file, and control how it's played | +| [Decodable](../examples/audio/decodable.rs) | Shows how to create and register a custom audio source by implementing the `Decodable` type. | +| [Spatial Audio 2D](../examples/audio/spatial_audio_2d.rs) | Shows how to play spatial audio, and moving the emitter in 2D | +| [Spatial Audio 3D](../examples/audio/spatial_audio_3d.rs) | Shows how to play spatial audio, and moving the emitter in 3D | ## Diagnostics -Example | Description ---- | --- -[Custom Diagnostic](../examples/diagnostics/custom_diagnostic.rs) | Shows how to create a custom diagnostic -[Log Diagnostics](../examples/diagnostics/log_diagnostics.rs) | Add a plugin that logs diagnostics, like frames per second (FPS), to the console +| Example | Description | +| ----------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| [Custom Diagnostic](../examples/diagnostics/custom_diagnostic.rs) | Shows how to create a custom diagnostic | +| [Log Diagnostics](../examples/diagnostics/log_diagnostics.rs) | Add a plugin that logs diagnostics, like frames per second (FPS), to the console | ## ECS (Entity Component System) -Example | Description ---- | --- -[Apply System Buffers](../examples/ecs/apply_system_buffers.rs) | Show how to use `apply_system_buffers` system -[Component Change Detection](../examples/ecs/component_change_detection.rs) | Change detection on components -[Custom Query Parameters](../examples/ecs/custom_query_param.rs) | Groups commonly used compound queries and query filters into a single type -[ECS Guide](../examples/ecs/ecs_guide.rs) | Full guide to Bevy's ECS -[Event](../examples/ecs/event.rs) | Illustrates event creation, activation, and reception -[Fixed Timestep](../examples/ecs/fixed_timestep.rs) | Shows how to create systems that run every fixed timestep, rather than every tick -[Generic System](../examples/ecs/generic_system.rs) | Shows how to create systems that can be reused with different types -[Hierarchy](../examples/ecs/hierarchy.rs) | Creates a hierarchy of parents and children entities -[Iter Combinations](../examples/ecs/iter_combinations.rs) | Shows how to iterate over combinations of query results -[Nondeterministic System Order](../examples/ecs/nondeterministic_system_order.rs) | Systems run in parallel, but their order isn't always deterministic. Here's how to detect and fix this. -[Parallel Query](../examples/ecs/parallel_query.rs) | Illustrates parallel queries with `ParallelIterator` -[Removal Detection](../examples/ecs/removal_detection.rs) | Query for entities that had a specific component removed earlier in the current frame -[Run Conditions](../examples/ecs/run_conditions.rs) | Run systems only when one or multiple conditions are met -[Startup System](../examples/ecs/startup_system.rs) | Demonstrates a startup system (one that runs once when the app starts up) -[State](../examples/ecs/state.rs) | Illustrates how to use States to control transitioning from a Menu state to an InGame state -[System Closure](../examples/ecs/system_closure.rs) | Show how to use closures as systems, and how to configure `Local` variables by capturing external state -[System Parameter](../examples/ecs/system_param.rs) | Illustrates creating custom system parameters with `SystemParam` -[System Piping](../examples/ecs/system_piping.rs) | Pipe the output of one system into a second, allowing you to handle any errors gracefully -[Timers](../examples/ecs/timers.rs) | Illustrates ticking `Timer` resources inside systems and handling their state +| Example | Description | +| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| [Apply System Buffers](../examples/ecs/apply_deferred.rs) | Show how to use `apply_deferred` system | +| [Component Change Detection](../examples/ecs/component_change_detection.rs) | Change detection on components | +| [Custom Query Parameters](../examples/ecs/custom_query_param.rs) | Groups commonly used compound queries and query filters into a single type | +| [ECS Guide](../examples/ecs/ecs_guide.rs) | Full guide to Bevy's ECS | +| [Event](../examples/ecs/event.rs) | Illustrates event creation, activation, and reception | +| [Fixed Timestep](../examples/ecs/fixed_timestep.rs) | Shows how to create systems that run every fixed timestep, rather than every tick | +| [Generic System](../examples/ecs/generic_system.rs) | Shows how to create systems that can be reused with different types | +| [Hierarchy](../examples/ecs/hierarchy.rs) | Creates a hierarchy of parents and children entities | +| [Iter Combinations](../examples/ecs/iter_combinations.rs) | Shows how to iterate over combinations of query results | +| [Nondeterministic System Order](../examples/ecs/nondeterministic_system_order.rs) | Systems run in parallel, but their order isn't always deterministic. Here's how to detect and fix this. | +| [Parallel Query](../examples/ecs/parallel_query.rs) | Illustrates parallel queries with `ParallelIterator` | +| [Removal Detection](../examples/ecs/removal_detection.rs) | Query for entities that had a specific component removed earlier in the current frame | +| [Run Conditions](../examples/ecs/run_conditions.rs) | Run systems only when one or multiple conditions are met | +| [Startup System](../examples/ecs/startup_system.rs) | Demonstrates a startup system (one that runs once when the app starts up) | +| [State](../examples/ecs/state.rs) | Illustrates how to use States to control transitioning from a Menu state to an InGame state | +| [System Closure](../examples/ecs/system_closure.rs) | Show how to use closures as systems, and how to configure `Local` variables by capturing external state | +| [System Parameter](../examples/ecs/system_param.rs) | Illustrates creating custom system parameters with `SystemParam` | +| [System Piping](../examples/ecs/system_piping.rs) | Pipe the output of one system into a second, allowing you to handle any errors gracefully | +| [Timers](../examples/ecs/timers.rs) | Illustrates ticking `Timer` resources inside systems and handling their state | ## Games -Example | Description ---- | --- -[Alien Cake Addict](../examples/games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game -[Breakout](../examples/games/breakout.rs) | An implementation of the classic game "Breakout" -[Contributors](../examples/games/contributors.rs) | Displays each contributor as a bouncy bevy-ball! -[Game Menu](../examples/games/game_menu.rs) | A simple game menu +| Example | Description | +| ----------------------------------------------------------- | ------------------------------------------------ | +| [Alien Cake Addict](../examples/games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game | +| [Breakout](../examples/games/breakout.rs) | An implementation of the classic game "Breakout" | +| [Contributors](../examples/games/contributors.rs) | Displays each contributor as a bouncy bevy-ball! | +| [Game Menu](../examples/games/game_menu.rs) | A simple game menu | ## Input -Example | Description ---- | --- -[Char Input Events](../examples/input/char_input_events.rs) | Prints out all chars as they are inputted -[Gamepad Input](../examples/input/gamepad_input.rs) | Shows handling of gamepad input, connections, and disconnections -[Gamepad Input Events](../examples/input/gamepad_input_events.rs) | Iterates and prints gamepad input and connection events -[Gamepad Rumble](../examples/input/gamepad_rumble.rs) | Shows how to rumble a gamepad using force feedback -[Keyboard Input](../examples/input/keyboard_input.rs) | Demonstrates handling a key press/release -[Keyboard Input Events](../examples/input/keyboard_input_events.rs) | Prints out all keyboard events -[Keyboard Modifiers](../examples/input/keyboard_modifiers.rs) | Demonstrates using key modifiers (ctrl, shift) -[Mouse Grab](../examples/input/mouse_grab.rs) | Demonstrates how to grab the mouse, locking the cursor to the app's screen -[Mouse Input](../examples/input/mouse_input.rs) | Demonstrates handling a mouse button press/release -[Mouse Input Events](../examples/input/mouse_input_events.rs) | Prints out all mouse events (buttons, movement, etc.) -[Text Input](../examples/input/text_input.rs) | Simple text input with IME support -[Touch Input](../examples/input/touch_input.rs) | Displays touch presses, releases, and cancels -[Touch Input Events](../examples/input/touch_input_events.rs) | Prints out all touch inputs +| Example | Description | +| ------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| [Char Input Events](../examples/input/char_input_events.rs) | Prints out all chars as they are inputted | +| [Gamepad Input](../examples/input/gamepad_input.rs) | Shows handling of gamepad input, connections, and disconnections | +| [Gamepad Input Events](../examples/input/gamepad_input_events.rs) | Iterates and prints gamepad input and connection events | +| [Gamepad Rumble](../examples/input/gamepad_rumble.rs) | Shows how to rumble a gamepad using force feedback | +| [Keyboard Input](../examples/input/keyboard_input.rs) | Demonstrates handling a key press/release | +| [Keyboard Input Events](../examples/input/keyboard_input_events.rs) | Prints out all keyboard events | +| [Keyboard Modifiers](../examples/input/keyboard_modifiers.rs) | Demonstrates using key modifiers (ctrl, shift) | +| [Mouse Grab](../examples/input/mouse_grab.rs) | Demonstrates how to grab the mouse, locking the cursor to the app's screen | +| [Mouse Input](../examples/input/mouse_input.rs) | Demonstrates handling a mouse button press/release | +| [Mouse Input Events](../examples/input/mouse_input_events.rs) | Prints out all mouse events (buttons, movement, etc.) | +| [Text Input](../examples/input/text_input.rs) | Simple text input with IME support | +| [Touch Input](../examples/input/touch_input.rs) | Displays touch presses, releases, and cancels | +| [Touch Input Events](../examples/input/touch_input_events.rs) | Prints out all touch inputs | ## Reflection -Example | Description ---- | --- -[Generic Reflection](../examples/reflection/generic_reflection.rs) | Registers concrete instances of generic types that may be used with reflection -[Reflection](../examples/reflection/reflection.rs) | Demonstrates how reflection in Bevy provides a way to dynamically interact with Rust types -[Reflection Types](../examples/reflection/reflection_types.rs) | Illustrates the various reflection types available -[Trait Reflection](../examples/reflection/trait_reflection.rs) | Allows reflection with trait objects +| Example | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| [Generic Reflection](../examples/reflection/generic_reflection.rs) | Registers concrete instances of generic types that may be used with reflection | +| [Reflection](../examples/reflection/reflection.rs) | Demonstrates how reflection in Bevy provides a way to dynamically interact with Rust types | +| [Reflection Types](../examples/reflection/reflection_types.rs) | Illustrates the various reflection types available | +| [Trait Reflection](../examples/reflection/trait_reflection.rs) | Allows reflection with trait objects | ## Scene -Example | Description ---- | --- -[Scene](../examples/scene/scene.rs) | Demonstrates loading from and saving scenes to files +| Example | Description | +| ----------------------------------- | ---------------------------------------------------- | +| [Scene](../examples/scene/scene.rs) | Demonstrates loading from and saving scenes to files | ## Shaders @@ -276,20 +276,20 @@ A shader in its most common usage is a small program that is run by the GPU per- There are also compute shaders which are used for more general processing leveraging the GPU's parallelism. -Example | Description ---- | --- -[Animated](../examples/shader/animate_shader.rs) | A shader that uses dynamic data like the time since startup -[Array Texture](../examples/shader/array_texture.rs) | A shader that shows how to reuse the core bevy PBR shading functionality in a custom material that obtains the base color from an array texture. -[Compute - Game of Life](../examples/shader/compute_shader_game_of_life.rs) | A compute shader that simulates Conway's Game of Life -[Custom Vertex Attribute](../examples/shader/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute -[Instancing](../examples/shader/shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call -[Material](../examples/shader/shader_material.rs) | A shader and a material that uses it -[Material - GLSL](../examples/shader/shader_material_glsl.rs) | A shader that uses the GLSL shading language -[Material - Screenspace Texture](../examples/shader/shader_material_screenspace_texture.rs) | A shader that samples a texture with view-independent UV coordinates -[Material Prepass](../examples/shader/shader_prepass.rs) | A shader that uses the various textures generated by the prepass -[Post Processing - Custom Render Pass](../examples/shader/post_processing.rs) | A custom post processing effect, using a custom render pass that runs after the main pass -[Shader Defs](../examples/shader/shader_defs.rs) | A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader) -[Texture Binding Array (Bindless Textures)](../examples/shader/texture_binding_array.rs) | A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures). +| Example | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| [Animated](../examples/shader/animate_shader.rs) | A shader that uses dynamic data like the time since startup | +| [Array Texture](../examples/shader/array_texture.rs) | A shader that shows how to reuse the core bevy PBR shading functionality in a custom material that obtains the base color from an array texture. | +| [Compute - Game of Life](../examples/shader/compute_shader_game_of_life.rs) | A compute shader that simulates Conway's Game of Life | +| [Custom Vertex Attribute](../examples/shader/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute | +| [Instancing](../examples/shader/shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call | +| [Material](../examples/shader/shader_material.rs) | A shader and a material that uses it | +| [Material - GLSL](../examples/shader/shader_material_glsl.rs) | A shader that uses the GLSL shading language | +| [Material - Screenspace Texture](../examples/shader/shader_material_screenspace_texture.rs) | A shader that samples a texture with view-independent UV coordinates | +| [Material Prepass](../examples/shader/shader_prepass.rs) | A shader that uses the various textures generated by the prepass | +| [Post Processing - Custom Render Pass](../examples/shader/post_processing.rs) | A custom post processing effect, using a custom render pass that runs after the main pass | +| [Shader Defs](../examples/shader/shader_defs.rs) | A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader) | +| [Texture Binding Array (Bindless Textures)](../examples/shader/texture_binding_array.rs) | A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures). | ## Stress Tests @@ -301,75 +301,75 @@ Due to the focus on performance it's recommended to run the stress tests in rele cargo run --release --example ``` -Example | Description ---- | --- -[Bevymark](../examples/stress_tests/bevymark.rs) | A heavy sprite rendering workload to benchmark your system with Bevy -[Many Animated Sprites](../examples/stress_tests/many_animated_sprites.rs) | Displays many animated sprites in a grid arrangement with slight offsets to their animation timers. Used for performance testing. -[Many Buttons](../examples/stress_tests/many_buttons.rs) | Test rendering of many UI elements -[Many Cubes](../examples/stress_tests/many_cubes.rs) | Simple benchmark to test per-entity draw overhead. Run with the `sphere` argument to test frustum culling -[Many Foxes](../examples/stress_tests/many_foxes.rs) | Loads an animated fox model and spawns lots of them. Good for testing skinned mesh performance. Takes an unsigned integer argument for the number of foxes to spawn. Defaults to 1000 -[Many Gizmos](../examples/stress_tests/many_gizmos.rs) | Test rendering of many gizmos -[Many Glyphs](../examples/stress_tests/many_glyphs.rs) | Simple benchmark to test text rendering. -[Many Lights](../examples/stress_tests/many_lights.rs) | Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights -[Many Sprites](../examples/stress_tests/many_sprites.rs) | Displays many sprites in a grid arrangement! Used for performance testing. Use `--colored` to enable color tinted sprites. -[Text Pipeline](../examples/stress_tests/text_pipeline.rs) | Text Pipeline benchmark -[Transform Hierarchy](../examples/stress_tests/transform_hierarchy.rs) | Various test cases for hierarchy and transform propagation performance +| Example | Description | +| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Bevymark](../examples/stress_tests/bevymark.rs) | A heavy sprite rendering workload to benchmark your system with Bevy | +| [Many Animated Sprites](../examples/stress_tests/many_animated_sprites.rs) | Displays many animated sprites in a grid arrangement with slight offsets to their animation timers. Used for performance testing. | +| [Many Buttons](../examples/stress_tests/many_buttons.rs) | Test rendering of many UI elements | +| [Many Cubes](../examples/stress_tests/many_cubes.rs) | Simple benchmark to test per-entity draw overhead. Run with the `sphere` argument to test frustum culling | +| [Many Foxes](../examples/stress_tests/many_foxes.rs) | Loads an animated fox model and spawns lots of them. Good for testing skinned mesh performance. Takes an unsigned integer argument for the number of foxes to spawn. Defaults to 1000 | +| [Many Gizmos](../examples/stress_tests/many_gizmos.rs) | Test rendering of many gizmos | +| [Many Glyphs](../examples/stress_tests/many_glyphs.rs) | Simple benchmark to test text rendering. | +| [Many Lights](../examples/stress_tests/many_lights.rs) | Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights | +| [Many Sprites](../examples/stress_tests/many_sprites.rs) | Displays many sprites in a grid arrangement! Used for performance testing. Use `--colored` to enable color tinted sprites. | +| [Text Pipeline](../examples/stress_tests/text_pipeline.rs) | Text Pipeline benchmark | +| [Transform Hierarchy](../examples/stress_tests/transform_hierarchy.rs) | Various test cases for hierarchy and transform propagation performance | ## Tools -Example | Description ---- | --- -[Gamepad Viewer](../examples/tools/gamepad_viewer.rs) | Shows a visualization of gamepad buttons, sticks, and triggers -[Scene Viewer](../examples/tools/scene_viewer/main.rs) | A simple way to view glTF models with Bevy. Just run `cargo run --release --example scene_viewer /path/to/model.gltf#Scene0`, replacing the path as appropriate. With no arguments it will load the FieldHelmet glTF model from the repository assets subdirectory +| Example | Description | +| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [Gamepad Viewer](../examples/tools/gamepad_viewer.rs) | Shows a visualization of gamepad buttons, sticks, and triggers | +| [Scene Viewer](../examples/tools/scene_viewer/main.rs) | A simple way to view glTF models with Bevy. Just run `cargo run --release --example scene_viewer /path/to/model.gltf#Scene0`, replacing the path as appropriate. With no arguments it will load the FieldHelmet glTF model from the repository assets subdirectory | ## Transforms -Example | Description ---- | --- -[3D Rotation](../examples/transforms/3d_rotation.rs) | Illustrates how to (constantly) rotate an object around an axis -[Scale](../examples/transforms/scale.rs) | Illustrates how to scale an object in each direction -[Transform](../examples/transforms/transform.rs) | Shows multiple transformations of objects -[Translation](../examples/transforms/translation.rs) | Illustrates how to move an object along an axis +| Example | Description | +| ---------------------------------------------------- | --------------------------------------------------------------- | +| [3D Rotation](../examples/transforms/3d_rotation.rs) | Illustrates how to (constantly) rotate an object around an axis | +| [Scale](../examples/transforms/scale.rs) | Illustrates how to scale an object in each direction | +| [Transform](../examples/transforms/transform.rs) | Shows multiple transformations of objects | +| [Translation](../examples/transforms/translation.rs) | Illustrates how to move an object along an axis | ## UI (User Interface) -Example | Description ---- | --- -[Button](../examples/ui/button.rs) | Illustrates creating and updating a button -[CSS Grid](../examples/ui/grid.rs) | An example for CSS Grid layout -[Flex Layout](../examples/ui/flex_layout.rs) | Demonstrates how the AlignItems and JustifyContent properties can be composed to layout nodes and position text -[Font Atlas Debug](../examples/ui/font_atlas_debug.rs) | Illustrates how FontAtlases are populated (used to optimize text rendering internally) -[Overflow](../examples/ui/overflow.rs) | Simple example demonstrating overflow behavior -[Overflow and Clipping Debug](../examples/ui/overflow_debug.rs) | An example to debug overflow and clipping behavior -[Relative Cursor Position](../examples/ui/relative_cursor_position.rs) | Showcases the RelativeCursorPosition component -[Size Constraints](../examples/ui/size_constraints.rs) | Demonstrates how the to use the size constraints to control the size of a UI node. -[Text](../examples/ui/text.rs) | Illustrates creating and updating text -[Text Debug](../examples/ui/text_debug.rs) | An example for debugging text layout -[Text Wrap Debug](../examples/ui/text_wrap_debug.rs) | Demonstrates text wrapping -[Transparency UI](../examples/ui/transparency_ui.rs) | Demonstrates transparency for UI -[UI](../examples/ui/ui.rs) | Illustrates various features of Bevy UI -[UI Scaling](../examples/ui/ui_scaling.rs) | Illustrates how to scale the UI -[UI Z-Index](../examples/ui/z_index.rs) | Demonstrates how to control the relative depth (z-position) of UI elements -[Window Fallthrough](../examples/ui/window_fallthrough.rs) | Illustrates how to access `winit::window::Window`'s `hittest` functionality. +| Example | Description | +| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| [Button](../examples/ui/button.rs) | Illustrates creating and updating a button | +| [CSS Grid](../examples/ui/grid.rs) | An example for CSS Grid layout | +| [Flex Layout](../examples/ui/flex_layout.rs) | Demonstrates how the AlignItems and JustifyContent properties can be composed to layout nodes and position text | +| [Font Atlas Debug](../examples/ui/font_atlas_debug.rs) | Illustrates how FontAtlases are populated (used to optimize text rendering internally) | +| [Overflow](../examples/ui/overflow.rs) | Simple example demonstrating overflow behavior | +| [Overflow and Clipping Debug](../examples/ui/overflow_debug.rs) | An example to debug overflow and clipping behavior | +| [Relative Cursor Position](../examples/ui/relative_cursor_position.rs) | Showcases the RelativeCursorPosition component | +| [Size Constraints](../examples/ui/size_constraints.rs) | Demonstrates how the to use the size constraints to control the size of a UI node. | +| [Text](../examples/ui/text.rs) | Illustrates creating and updating text | +| [Text Debug](../examples/ui/text_debug.rs) | An example for debugging text layout | +| [Text Wrap Debug](../examples/ui/text_wrap_debug.rs) | Demonstrates text wrapping | +| [Transparency UI](../examples/ui/transparency_ui.rs) | Demonstrates transparency for UI | +| [UI](../examples/ui/ui.rs) | Illustrates various features of Bevy UI | +| [UI Scaling](../examples/ui/ui_scaling.rs) | Illustrates how to scale the UI | +| [UI Z-Index](../examples/ui/z_index.rs) | Demonstrates how to control the relative depth (z-position) of UI elements | +| [Window Fallthrough](../examples/ui/window_fallthrough.rs) | Illustrates how to access `winit::window::Window`'s `hittest` functionality. | ## Window -Example | Description ---- | --- -[Clear Color](../examples/window/clear_color.rs) | Creates a solid color window -[Low Power](../examples/window/low_power.rs) | Demonstrates settings to reduce power use for bevy applications -[Multiple Windows](../examples/window/multiple_windows.rs) | Demonstrates creating multiple windows, and rendering to them -[Scale Factor Override](../examples/window/scale_factor_override.rs) | Illustrates how to customize the default window settings -[Screenshot](../examples/window/screenshot.rs) | Shows how to save screenshots to disk -[Transparent Window](../examples/window/transparent_window.rs) | Illustrates making the window transparent and hiding the window decoration -[Window Resizing](../examples/window/window_resizing.rs) | Demonstrates resizing and responding to resizing a window -[Window Settings](../examples/window/window_settings.rs) | Demonstrates customizing default window settings +| Example | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| [Clear Color](../examples/window/clear_color.rs) | Creates a solid color window | +| [Low Power](../examples/window/low_power.rs) | Demonstrates settings to reduce power use for bevy applications | +| [Multiple Windows](../examples/window/multiple_windows.rs) | Demonstrates creating multiple windows, and rendering to them | +| [Scale Factor Override](../examples/window/scale_factor_override.rs) | Illustrates how to customize the default window settings | +| [Screenshot](../examples/window/screenshot.rs) | Shows how to save screenshots to disk | +| [Transparent Window](../examples/window/transparent_window.rs) | Illustrates making the window transparent and hiding the window decoration | +| [Window Resizing](../examples/window/window_resizing.rs) | Demonstrates resizing and responding to resizing a window | +| [Window Settings](../examples/window/window_settings.rs) | Demonstrates customizing default window settings | # Tests -Example | Description ---- | --- -[How to Test Systems](../tests/how_to_test_systems.rs) | How to test systems with commands, queries or resources +| Example | Description | +| ------------------------------------------------------ | ------------------------------------------------------- | +| [How to Test Systems](../tests/how_to_test_systems.rs) | How to test systems with commands, queries or resources | # Platform-Specific Examples @@ -436,9 +436,9 @@ target_sdk_version = >>API<< min_sdk_version = >>API or less<< ``` -Example | File | Description ---- | --- | --- -`android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound +| Example | File | Description | +| --------- | ------------------------------------------ | ------------------------------------------ | +| `android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound | ## iOS @@ -480,9 +480,9 @@ open bevy_mobile_example.xcodeproj/ which will open xcode. You then must push the zoom zoom play button and wait for the magic. -Example | File | Description ---- | --- | --- -`ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound +| Example | File | Description | +| ------- | ------------------------------------------ | ------------------------------------------ | +| `ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound | ## WASM @@ -603,14 +603,14 @@ mv optimized.wasm examples/wasm/target/lighting_bg.wasm For a small project with a basic 3d model and two lights, the generated file sizes are, as of Jully 2022 as following: -|profile | wasm-opt | no wasm-opt | -|----------------------------------|----------|-------------| -|Default | 8.5M | 13.0M | -|opt-level = "z" | 6.1M | 12.7M | -|"z" + lto = "thin" | 5.9M | 12M | -|"z" + lto = "fat" | 5.1M | 9.4M | -|"z" + "thin" + codegen-units = 1 | 5.3M | 11M | -|"z" + "fat" + codegen-units = 1 | 4.8M | 8.5M | +| profile | wasm-opt | no wasm-opt | +| -------------------------------- | -------- | ----------- | +| Default | 8.5M | 13.0M | +| opt-level = "z" | 6.1M | 12.7M | +| "z" + lto = "thin" | 5.9M | 12M | +| "z" + lto = "fat" | 5.1M | 9.4M | +| "z" + "thin" + codegen-units = 1 | 5.3M | 11M | +| "z" + "fat" + codegen-units = 1 | 4.8M | 8.5M | There are more advanced optimization options available, check the following pages for more info: diff --git a/examples/ecs/apply_system_buffers.rs b/examples/ecs/apply_system_buffers.rs index a9ab0d3e50d8f..2a64b90565ca4 100644 --- a/examples/ecs/apply_system_buffers.rs +++ b/examples/ecs/apply_system_buffers.rs @@ -1,4 +1,4 @@ -//! This example illustrates how to use the `apply_system_buffers` system +//! This example illustrates how to use the `apply_deferred` system //! to flush commands added by systems that have already run, //! but have not had their buffers applied yet. //! @@ -7,7 +7,7 @@ //! added to `CoreSet::Update`) but want to flush commands immediately. //! //! It is important that systems are ordered correctly with respect to -//! `apply_system_buffers`, to avoid surprising non-deterministic system execution order. +//! `apply_deferred`, to avoid surprising non-deterministic system execution order. use bevy::prelude::*; @@ -21,9 +21,9 @@ fn main() { ( ( despawn_old_and_spawn_new_fruits, - // We encourage adding apply_system_buffers to a custom set + // We encourage adding apply_deferred to a custom set // to improve diagnostics. This is optional, but useful when debugging! - apply_system_buffers.in_set(CustomFlush), + apply_deferred.in_set(CustomFlush), count_apple, ) .chain(), diff --git a/examples/ecs/removal_detection.rs b/examples/ecs/removal_detection.rs index 9312c699e97e5..2a5d641ea031c 100644 --- a/examples/ecs/removal_detection.rs +++ b/examples/ecs/removal_detection.rs @@ -7,7 +7,7 @@ fn main() { // to react to the removal before the frame is over. // // Also, `Components` are removed via a `Command`, which are not applied immediately. - // So you need to react to the removal at some stage after `apply_system_buffers` has run, + // So you need to react to the removal at some stage after `apply_deferred` has run, // and the Component` is removed. // // With these constraints in mind we make sure to place the system that removes a `Component` in From 30b8460b271b539759e4b21e6df4621698bbf7d7 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 31 May 2023 11:49:02 -0400 Subject: [PATCH 02/10] Update internal `set_apply_final_deferred` --- crates/bevy_ecs/src/schedule/executor/mod.rs | 2 +- .../src/schedule/executor/multi_threaded.rs | 16 +++++++--------- crates/bevy_ecs/src/schedule/executor/simple.rs | 2 +- .../src/schedule/executor/single_threaded.rs | 12 ++++++------ crates/bevy_ecs/src/schedule/schedule.rs | 6 +++--- crates/bevy_render/src/lib.rs | 2 +- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index e7150473ae092..6707101a4a564 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -19,7 +19,7 @@ pub(super) trait SystemExecutor: Send + Sync { fn kind(&self) -> ExecutorKind; fn init(&mut self, schedule: &SystemSchedule); fn run(&mut self, schedule: &mut SystemSchedule, world: &mut World); - fn set_apply_final_buffers(&mut self, value: bool); + fn set_apply_final_deferred(&mut self, value: bool); } /// Specifies how a [`Schedule`](super::Schedule) will be run. diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 06707706801c7..09b168d71e63d 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -17,9 +17,7 @@ use crate::{ archetype::ArchetypeComponentId, prelude::Resource, query::Access, - schedule::{ - is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, - }, + schedule::{is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, system::BoxedSystem, world::{unsafe_world_cell::UnsafeWorldCell, World}, }; @@ -108,8 +106,8 @@ pub struct MultiThreadedExecutor { completed_systems: FixedBitSet, /// Systems that have run but have not had their buffers applied. unapplied_systems: FixedBitSet, - /// Setting when true applies system buffers after all systems have run - apply_final_buffers: bool, + /// Setting when true applies deferred system buffers after all systems have run + apply_final_deferred: bool, /// When set, tells the executor that a thread has panicked. panic_payload: Arc>>>, /// When set, stops the executor from running any more systems. @@ -127,8 +125,8 @@ impl SystemExecutor for MultiThreadedExecutor { ExecutorKind::MultiThreaded } - fn set_apply_final_buffers(&mut self, value: bool) { - self.apply_final_buffers = value; + fn set_apply_final_deferred(&mut self, value: bool) { + self.apply_final_deferred = value; } fn init(&mut self, schedule: &SystemSchedule) { @@ -230,7 +228,7 @@ impl SystemExecutor for MultiThreadedExecutor { }, ); - if self.apply_final_buffers { + if self.apply_final_deferred { // Do one final apply buffers after all systems have completed // Commands should be applied while on the scope's thread, not the executor's thread let res = apply_deferred(&self.unapplied_systems, systems, world); @@ -278,7 +276,7 @@ impl MultiThreadedExecutor { skipped_systems: FixedBitSet::new(), completed_systems: FixedBitSet::new(), unapplied_systems: FixedBitSet::new(), - apply_final_buffers: true, + apply_final_deferred: true, panic_payload: Arc::new(Mutex::new(None)), stop_spawning: false, } diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index b72f2dbdd694c..72e2c34cd777b 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -23,7 +23,7 @@ impl SystemExecutor for SimpleExecutor { ExecutorKind::Simple } - fn set_apply_final_buffers(&mut self, _: bool) { + fn set_apply_final_deferred(&mut self, _: bool) { // do nothing. simple executor does not do a final sync } diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index 222afd48e3b6d..05c3d579d800f 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -20,8 +20,8 @@ pub struct SingleThreadedExecutor { completed_systems: FixedBitSet, /// Systems that have run but have not had their buffers applied. unapplied_systems: FixedBitSet, - /// Setting when true applies system buffers after all systems have run - apply_final_buffers: bool, + /// Setting when true applies deferred system buffers after all systems have run + apply_final_deferred: bool, } impl SystemExecutor for SingleThreadedExecutor { @@ -29,8 +29,8 @@ impl SystemExecutor for SingleThreadedExecutor { ExecutorKind::SingleThreaded } - fn set_apply_final_buffers(&mut self, apply_final_buffers: bool) { - self.apply_final_buffers = apply_final_buffers; + fn set_apply_final_deferred(&mut self, apply_final_deferred: bool) { + self.apply_final_deferred = apply_final_deferred; } fn init(&mut self, schedule: &SystemSchedule) { @@ -107,7 +107,7 @@ impl SystemExecutor for SingleThreadedExecutor { } } - if self.apply_final_buffers { + if self.apply_final_deferred { self.apply_deferred(schedule, world); } self.evaluated_sets.clear(); @@ -121,7 +121,7 @@ impl SingleThreadedExecutor { evaluated_sets: FixedBitSet::new(), completed_systems: FixedBitSet::new(), unapplied_systems: FixedBitSet::new(), - apply_final_buffers: true, + apply_final_deferred: true, } } diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 03c6fe2174317..eba89335defaf 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -219,12 +219,12 @@ impl Schedule { self } - /// Set whether the schedule applies buffers on final time or not. This is a catchall + /// Set whether the schedule applies deferred system buffers on final time or not. This is a catchall /// incase a system uses commands but was not explicitly ordered after a /// [`apply_deferred`](crate::prelude::apply_deferred). By default this /// setting is true, but may be disabled if needed. - pub fn set_apply_final_buffers(&mut self, apply_final_buffers: bool) -> &mut Self { - self.executor.set_apply_final_buffers(apply_final_buffers); + pub fn set_apply_final_deferred(&mut self, apply_final_deferred: bool) -> &mut Self { + self.executor.set_apply_final_deferred(apply_final_deferred); self } diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 2a6947f0b8e87..3df8d2295436b 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -269,7 +269,7 @@ impl Plugin for RenderPlugin { render_app.main_schedule_label = Box::new(Render); let mut extract_schedule = Schedule::new(); - extract_schedule.set_apply_final_buffers(false); + extract_schedule.set_apply_final_deferred(false); render_app .add_schedule(ExtractSchedule, extract_schedule) From 35874f12bdec050562ebc91e169b1b27d5ca0bbe Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 31 May 2023 11:51:57 -0400 Subject: [PATCH 03/10] apply_buffers -> apply_deferred --- crates/bevy_ecs/src/schedule/condition.rs | 4 ++-- crates/bevy_ecs/src/schedule/executor/mod.rs | 4 ++-- crates/bevy_ecs/src/schedule/executor/multi_threaded.rs | 2 +- crates/bevy_ecs/src/schedule/executor/simple.rs | 4 ++-- crates/bevy_ecs/src/schedule/executor/single_threaded.rs | 2 +- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- crates/bevy_ecs/src/system/combinator.rs | 6 +++--- crates/bevy_ecs/src/system/commands/mod.rs | 4 ++-- crates/bevy_ecs/src/system/exclusive_function_system.rs | 2 +- crates/bevy_ecs/src/system/function_system.rs | 2 +- crates/bevy_ecs/src/system/system.rs | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 52630acc2b37b..5de1f6b5cde4a 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -1000,8 +1000,8 @@ where !self.condition.run(input, world) } - fn apply_buffers(&mut self, world: &mut World) { - self.condition.apply_buffers(world); + fn apply_deferred(&mut self, world: &mut World) { + self.condition.apply_deferred(world); } fn initialize(&mut self, world: &mut World) { diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index 6707101a4a564..fce59c0807e50 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -35,7 +35,7 @@ pub enum ExecutorKind { /// other things, or just trying minimize overhead. #[cfg_attr(target_arch = "wasm32", default)] SingleThreaded, - /// Like [`SingleThreaded`](ExecutorKind::SingleThreaded) but calls [`apply_buffers`](crate::system::System::apply_buffers) + /// Like [`SingleThreaded`](ExecutorKind::SingleThreaded) but calls [`apply_deferred`](crate::system::System::apply_deferred) /// immediately after running each system. Simple, /// Runs the schedule using a thread pool. Non-conflicting systems can run in parallel. @@ -77,7 +77,7 @@ impl SystemSchedule { } } -/// Instructs the executor to call [`apply_buffers`](crate::system::System::apply_buffers) +/// Instructs the executor to call [`apply_deferred`](crate::system::System::apply_deferred) /// on the systems that have run but not applied their buffers. /// /// **Notes** diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 09b168d71e63d..9824393c4f5a7 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -688,7 +688,7 @@ fn apply_deferred( // SAFETY: none of these systems are running, no other references exist let system = unsafe { &mut *systems[system_index].get() }; let res = std::panic::catch_unwind(AssertUnwindSafe(|| { - system.apply_buffers(world); + system.apply_deferred(world); })); if let Err(payload) = res { eprintln!( diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index 72e2c34cd777b..47f4eb7ff53b7 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -9,7 +9,7 @@ use crate::{ }; /// A variant of [`SingleThreadedExecutor`](crate::schedule::SingleThreadedExecutor) that calls -/// [`apply_buffers`](crate::system::System::apply_buffers) immediately after running each system. +/// [`apply_deferred`](crate::system::System::apply_deferred) immediately after running each system. #[derive(Default)] pub struct SimpleExecutor { /// Systems sets whose conditions have been evaluated. @@ -89,7 +89,7 @@ impl SystemExecutor for SimpleExecutor { std::panic::resume_unwind(payload); } - system.apply_buffers(world); + system.apply_deferred(world); } self.evaluated_sets.clear(); diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index 05c3d579d800f..9f3d7a2bb39d8 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -128,7 +128,7 @@ impl SingleThreadedExecutor { fn apply_deferred(&mut self, schedule: &mut SystemSchedule, world: &mut World) { for system_index in self.unapplied_systems.ones() { let system = &mut schedule.systems[system_index]; - system.apply_buffers(world); + system.apply_deferred(world); } self.unapplied_systems.clear(); diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index eba89335defaf..06fd0aced22ca 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -297,7 +297,7 @@ impl Schedule { /// before applying their buffers in a different world. pub fn apply_deferred(&mut self, world: &mut World) { for system in &mut self.executable.systems { - system.apply_buffers(world); + system.apply_deferred(world); } } } diff --git a/crates/bevy_ecs/src/system/combinator.rs b/crates/bevy_ecs/src/system/combinator.rs index c058a78f35b9d..3461de257d0d4 100644 --- a/crates/bevy_ecs/src/system/combinator.rs +++ b/crates/bevy_ecs/src/system/combinator.rs @@ -187,9 +187,9 @@ where ) } - fn apply_buffers(&mut self, world: &mut World) { - self.a.apply_buffers(world); - self.b.apply_buffers(world); + fn apply_deferred(&mut self, world: &mut World) { + self.a.apply_deferred(world); + self.b.apply_deferred(world); } fn initialize(&mut self, world: &mut World) { diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index bf1374ac01871..849870b77821d 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -53,7 +53,7 @@ pub trait Command: Send + 'static { /// when the [`apply_deferred`] system runs. /// /// The command queue of an individual system can also be manually applied -/// by calling [`System::apply_buffers`]. +/// by calling [`System::apply_deferred`]. /// Similarly, the command queue of a schedule can be manually applied via [`Schedule::apply_deferred`]. /// /// Each command can be used to modify the [`World`] in arbitrary ways: @@ -100,7 +100,7 @@ pub trait Command: Send + 'static { /// # } /// ``` /// -/// [`System::apply_buffers`]: crate::system::System::apply_buffers +/// [`System::apply_deferred`]: crate::system::System::apply_deferred /// [`apply_deferred`]: crate::schedule::apply_deferred /// [`Schedule::apply_deferred`]: crate::schedule::Schedule::apply_deferred #[derive(SystemParam)] diff --git a/crates/bevy_ecs/src/system/exclusive_function_system.rs b/crates/bevy_ecs/src/system/exclusive_function_system.rs index 9ba43b4015fec..66d95084d2df4 100644 --- a/crates/bevy_ecs/src/system/exclusive_function_system.rs +++ b/crates/bevy_ecs/src/system/exclusive_function_system.rs @@ -122,7 +122,7 @@ where } #[inline] - fn apply_buffers(&mut self, _world: &mut World) { + fn apply_deferred(&mut self, _world: &mut World) { // "pure" exclusive systems do not have any buffers to apply. // Systems made by piping a normal system with an exclusive system // might have buffers to apply, but this is handled by `PipeSystem`. diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index ed73d75b8f60d..391ba99699584 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -445,7 +445,7 @@ where } #[inline] - fn apply_buffers(&mut self, world: &mut World) { + fn apply_deferred(&mut self, world: &mut World) { let param_state = self.param_state.as_mut().expect(Self::PARAM_MESSAGE); F::Param::apply(param_state, &self.system_meta, world); } diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index 4a578ec6797ec..65d7e7c5ded95 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -61,7 +61,7 @@ pub trait System: Send + Sync + 'static { // - `update_archetype_component_access` has been called. unsafe { self.run_unsafe(input, world) } } - fn apply_buffers(&mut self, world: &mut World); + fn apply_deferred(&mut self, world: &mut World); /// Initialize the system. fn initialize(&mut self, _world: &mut World); /// Update the system's archetype component [`Access`]. From d1d057cf42fab75369d8f85ad152577c811db443 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 31 May 2023 11:56:11 -0400 Subject: [PATCH 04/10] Update docs --- crates/bevy_ecs/src/schedule/schedule.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 06fd0aced22ca..08f3dbbf92d3a 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -287,9 +287,9 @@ impl Schedule { } } - /// Directly applies any accumulated system buffers (like [`Commands`](crate::prelude::Commands)) to the `world`. + /// Directly applies any accumulated [`Deferred`](crate::system::Deferred) system parameters (like [`Commands`](crate::prelude::Commands)) to the `world`. /// - /// Like always, system buffers are applied in the "topological sort order" of the schedule graph. + /// Like always, deferred system parameters are applied in the "topological sort order" of the schedule graph. /// As a result, buffers from one system are only guaranteed to be applied before those of other systems /// if there is an explicit system ordering between the two systems. /// From 8df799057b3073fdd2bee0ac566c7cb3e2595406 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 31 May 2023 11:57:05 -0400 Subject: [PATCH 05/10] Add missing docs on System::apply_deferred --- crates/bevy_ecs/src/schedule/executor/mod.rs | 2 +- crates/bevy_ecs/src/system/system.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index fce59c0807e50..a9666dfbb7c8a 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -78,7 +78,7 @@ impl SystemSchedule { } /// Instructs the executor to call [`apply_deferred`](crate::system::System::apply_deferred) -/// on the systems that have run but not applied their buffers. +/// on the systems that have run but not applied their [`Deferred`](crate::system::Deferred) system parameters (like [`Commands`](crate::prelude::Commands)) or other system buffers. /// /// **Notes** /// - This function (currently) does nothing if it's called manually or wrapped inside a [`PipeSystem`](crate::system::PipeSystem). diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index 65d7e7c5ded95..b9e246842fd1a 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -61,6 +61,7 @@ pub trait System: Send + Sync + 'static { // - `update_archetype_component_access` has been called. unsafe { self.run_unsafe(input, world) } } + /// Applies any [`Deferred`](crate::system::Deferred) system parameters (or other system buffers) of this system to the world. fn apply_deferred(&mut self, world: &mut World); /// Initialize the system. fn initialize(&mut self, _world: &mut World); From c63b0ff08f77120b44ca887dcab1d933e9b2717f Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 1 Jun 2023 20:40:34 -0400 Subject: [PATCH 06/10] Doc suggestions from code review Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com> --- crates/bevy_ecs/src/schedule/executor/mod.rs | 2 +- crates/bevy_ecs/src/schedule/schedule.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index a9666dfbb7c8a..f92031aa3311b 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -77,7 +77,7 @@ impl SystemSchedule { } } -/// Instructs the executor to call [`apply_deferred`](crate::system::System::apply_deferred) +/// Instructs the executor to call [`System::apply_deferred`](crate::system::System::apply_deferred) /// on the systems that have run but not applied their [`Deferred`](crate::system::Deferred) system parameters (like [`Commands`](crate::prelude::Commands)) or other system buffers. /// /// **Notes** diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 08f3dbbf92d3a..c448093431aad 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -219,8 +219,8 @@ impl Schedule { self } - /// Set whether the schedule applies deferred system buffers on final time or not. This is a catchall - /// incase a system uses commands but was not explicitly ordered after a + /// Set whether the schedule applies deferred system buffers on final time or not. This is a catch-all + /// in case a system uses commands but was not explicitly ordered before an instance of /// [`apply_deferred`](crate::prelude::apply_deferred). By default this /// setting is true, but may be disabled if needed. pub fn set_apply_final_deferred(&mut self, apply_final_deferred: bool) -> &mut Self { From 681d4bd00fcb3345e0723cc3e707ace14cd4adf6 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 1 Jun 2023 20:41:28 -0400 Subject: [PATCH 07/10] Update example file name --- examples/ecs/{apply_system_buffers.rs => apply_deferred.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/ecs/{apply_system_buffers.rs => apply_deferred.rs} (100%) diff --git a/examples/ecs/apply_system_buffers.rs b/examples/ecs/apply_deferred.rs similarity index 100% rename from examples/ecs/apply_system_buffers.rs rename to examples/ecs/apply_deferred.rs From bb35f44e4ba891c9f62165ec15ffdb6c8812a145 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 1 Jun 2023 22:24:45 -0400 Subject: [PATCH 08/10] Run cargo run -p build-templated-pages -- update examples --- examples/README.md | 454 ++++++++++++++++++++++----------------------- 1 file changed, 227 insertions(+), 227 deletions(-) diff --git a/examples/README.md b/examples/README.md index d8e71908fe355..4751f537cfabf 100644 --- a/examples/README.md +++ b/examples/README.md @@ -81,192 +81,192 @@ git checkout v0.4.0 ## Hello, World! -| Example | Description | -| ------------------------------------ | ------------------------------------------------- | -| [`hello_world.rs`](./hello_world.rs) | Runs a minimal example that outputs "hello world" | +Example | Description +--- | --- +[`hello_world.rs`](./hello_world.rs) | Runs a minimal example that outputs "hello world" # Cross-Platform Examples ## 2D Rendering -| Example | Description | -| --------------------------------------------------------------------------------- | ---------------------------------------------------------------- | -| [2D Bloom](../examples/2d/bloom_2d.rs) | Illustrates bloom post-processing in 2d | -| [2D Gizmos](../examples/2d/2d_gizmos.rs) | A scene showcasing 2D gizmos | -| [2D Rotation](../examples/2d/rotation.rs) | Demonstrates rotating entities in 2D with quaternions | -| [2D Shapes](../examples/2d/2d_shapes.rs) | Renders a rectangle, circle, and hexagon | -| [Custom glTF vertex attribute 2D](../examples/2d/custom_gltf_vertex_attribute.rs) | Renders a glTF mesh in 2D with a custom vertex attribute | -| [Manual Mesh 2D](../examples/2d/mesh2d_manual.rs) | Renders a custom mesh "manually" with "mid-level" renderer apis | -| [Mesh 2D](../examples/2d/mesh2d.rs) | Renders a 2d mesh | -| [Mesh 2D With Vertex Colors](../examples/2d/mesh2d_vertex_color_texture.rs) | Renders a 2d mesh with vertex color attributes | -| [Move Sprite](../examples/2d/move_sprite.rs) | Changes the transform of a sprite | -| [Pixel Perfect](../examples/2d/pixel_perfect.rs) | Demonstrates pixel perfect in 2d | -| [Sprite](../examples/2d/sprite.rs) | Renders a sprite | -| [Sprite Flipping](../examples/2d/sprite_flipping.rs) | Renders a sprite flipped along an axis | -| [Sprite Sheet](../examples/2d/sprite_sheet.rs) | Renders an animated sprite | -| [Text 2D](../examples/2d/text2d.rs) | Generates text in 2D | -| [Texture Atlas](../examples/2d/texture_atlas.rs) | Generates a texture atlas (sprite sheet) from individual sprites | -| [Transparency in 2D](../examples/2d/transparency_2d.rs) | Demonstrates transparency in 2d | +Example | Description +--- | --- +[2D Bloom](../examples/2d/bloom_2d.rs) | Illustrates bloom post-processing in 2d +[2D Gizmos](../examples/2d/2d_gizmos.rs) | A scene showcasing 2D gizmos +[2D Rotation](../examples/2d/rotation.rs) | Demonstrates rotating entities in 2D with quaternions +[2D Shapes](../examples/2d/2d_shapes.rs) | Renders a rectangle, circle, and hexagon +[Custom glTF vertex attribute 2D](../examples/2d/custom_gltf_vertex_attribute.rs) | Renders a glTF mesh in 2D with a custom vertex attribute +[Manual Mesh 2D](../examples/2d/mesh2d_manual.rs) | Renders a custom mesh "manually" with "mid-level" renderer apis +[Mesh 2D](../examples/2d/mesh2d.rs) | Renders a 2d mesh +[Mesh 2D With Vertex Colors](../examples/2d/mesh2d_vertex_color_texture.rs) | Renders a 2d mesh with vertex color attributes +[Move Sprite](../examples/2d/move_sprite.rs) | Changes the transform of a sprite +[Pixel Perfect](../examples/2d/pixel_perfect.rs) | Demonstrates pixel perfect in 2d +[Sprite](../examples/2d/sprite.rs) | Renders a sprite +[Sprite Flipping](../examples/2d/sprite_flipping.rs) | Renders a sprite flipped along an axis +[Sprite Sheet](../examples/2d/sprite_sheet.rs) | Renders an animated sprite +[Text 2D](../examples/2d/text2d.rs) | Generates text in 2D +[Texture Atlas](../examples/2d/texture_atlas.rs) | Generates a texture atlas (sprite sheet) from individual sprites +[Transparency in 2D](../examples/2d/transparency_2d.rs) | Demonstrates transparency in 2d ## 3D Rendering -| Example | Description | -| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| [3D Bloom](../examples/3d/bloom_3d.rs) | Illustrates bloom configuration using HDR and emissive materials | -| [3D Gizmos](../examples/3d/3d_gizmos.rs) | A scene showcasing 3D gizmos | -| [3D Scene](../examples/3d/3d_scene.rs) | Simple 3D scene with basic shapes and lighting | -| [3D Shapes](../examples/3d/3d_shapes.rs) | A scene showcasing the built-in 3D shapes | -| [Anti-aliasing](../examples/3d/anti_aliasing.rs) | Compares different anti-aliasing methods | -| [Atmospheric Fog](../examples/3d/atmospheric_fog.rs) | A scene showcasing the atmospheric fog effect | -| [Blend Modes](../examples/3d/blend_modes.rs) | Showcases different blend modes | -| [Fog](../examples/3d/fog.rs) | A scene showcasing the distance fog effect | -| [Lighting](../examples/3d/lighting.rs) | Illustrates various lighting options in a simple scene | -| [Lines](../examples/3d/lines.rs) | Create a custom material to draw 3d lines | -| [Load glTF](../examples/3d/load_gltf.rs) | Loads and renders a glTF file as a scene | -| [Orthographic View](../examples/3d/orthographic.rs) | Shows how to create a 3D orthographic view (for isometric-look in games or CAD applications) | -| [Parallax Mapping](../examples/3d/parallax_mapping.rs) | Demonstrates use of a normal map and depth map for parallax mapping | -| [Parenting](../examples/3d/parenting.rs) | Demonstrates parent->child relationships and relative transformations | -| [Physically Based Rendering](../examples/3d/pbr.rs) | Demonstrates use of Physically Based Rendering (PBR) properties | -| [Render to Texture](../examples/3d/render_to_texture.rs) | Shows how to render to a texture, useful for mirrors, UI, or exporting images | -| [Shadow Biases](../examples/3d/shadow_biases.rs) | Demonstrates how shadow biases affect shadows in a 3d scene | -| [Shadow Caster and Receiver](../examples/3d/shadow_caster_receiver.rs) | Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene | -| [Skybox](../examples/3d/skybox.rs) | Load a cubemap texture onto a cube like a skybox and cycle through different compressed texture formats. | -| [Spherical Area Lights](../examples/3d/spherical_area_lights.rs) | Demonstrates how point light radius values affect light behavior | -| [Split Screen](../examples/3d/split_screen.rs) | Demonstrates how to render two cameras to the same window to accomplish "split screen" | -| [Spotlight](../examples/3d/spotlight.rs) | Illustrates spot lights | -| [Texture](../examples/3d/texture.rs) | Shows configuration of texture materials | -| [Tonemapping](../examples/3d/tonemapping.rs) | Compares tonemapping options | -| [Transparency in 3D](../examples/3d/transparency_3d.rs) | Demonstrates transparency in 3d | -| [Two Passes](../examples/3d/two_passes.rs) | Renders two 3d passes to the same window from different perspectives | -| [Update glTF Scene](../examples/3d/update_gltf_scene.rs) | Update a scene from a glTF file, either by spawning the scene as a child of another entity, or by accessing the entities of the scene | -| [Vertex Colors](../examples/3d/vertex_colors.rs) | Shows the use of vertex colors | -| [Wireframe](../examples/3d/wireframe.rs) | Showcases wireframe rendering | +Example | Description +--- | --- +[3D Bloom](../examples/3d/bloom_3d.rs) | Illustrates bloom configuration using HDR and emissive materials +[3D Gizmos](../examples/3d/3d_gizmos.rs) | A scene showcasing 3D gizmos +[3D Scene](../examples/3d/3d_scene.rs) | Simple 3D scene with basic shapes and lighting +[3D Shapes](../examples/3d/3d_shapes.rs) | A scene showcasing the built-in 3D shapes +[Anti-aliasing](../examples/3d/anti_aliasing.rs) | Compares different anti-aliasing methods +[Atmospheric Fog](../examples/3d/atmospheric_fog.rs) | A scene showcasing the atmospheric fog effect +[Blend Modes](../examples/3d/blend_modes.rs) | Showcases different blend modes +[Fog](../examples/3d/fog.rs) | A scene showcasing the distance fog effect +[Lighting](../examples/3d/lighting.rs) | Illustrates various lighting options in a simple scene +[Lines](../examples/3d/lines.rs) | Create a custom material to draw 3d lines +[Load glTF](../examples/3d/load_gltf.rs) | Loads and renders a glTF file as a scene +[Orthographic View](../examples/3d/orthographic.rs) | Shows how to create a 3D orthographic view (for isometric-look in games or CAD applications) +[Parallax Mapping](../examples/3d/parallax_mapping.rs) | Demonstrates use of a normal map and depth map for parallax mapping +[Parenting](../examples/3d/parenting.rs) | Demonstrates parent->child relationships and relative transformations +[Physically Based Rendering](../examples/3d/pbr.rs) | Demonstrates use of Physically Based Rendering (PBR) properties +[Render to Texture](../examples/3d/render_to_texture.rs) | Shows how to render to a texture, useful for mirrors, UI, or exporting images +[Shadow Biases](../examples/3d/shadow_biases.rs) | Demonstrates how shadow biases affect shadows in a 3d scene +[Shadow Caster and Receiver](../examples/3d/shadow_caster_receiver.rs) | Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene +[Skybox](../examples/3d/skybox.rs) | Load a cubemap texture onto a cube like a skybox and cycle through different compressed texture formats. +[Spherical Area Lights](../examples/3d/spherical_area_lights.rs) | Demonstrates how point light radius values affect light behavior +[Split Screen](../examples/3d/split_screen.rs) | Demonstrates how to render two cameras to the same window to accomplish "split screen" +[Spotlight](../examples/3d/spotlight.rs) | Illustrates spot lights +[Texture](../examples/3d/texture.rs) | Shows configuration of texture materials +[Tonemapping](../examples/3d/tonemapping.rs) | Compares tonemapping options +[Transparency in 3D](../examples/3d/transparency_3d.rs) | Demonstrates transparency in 3d +[Two Passes](../examples/3d/two_passes.rs) | Renders two 3d passes to the same window from different perspectives +[Update glTF Scene](../examples/3d/update_gltf_scene.rs) | Update a scene from a glTF file, either by spawning the scene as a child of another entity, or by accessing the entities of the scene +[Vertex Colors](../examples/3d/vertex_colors.rs) | Shows the use of vertex colors +[Wireframe](../examples/3d/wireframe.rs) | Showcases wireframe rendering ## Animation -| Example | Description | -| ------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | -| [Animated Fox](../examples/animation/animated_fox.rs) | Plays an animation from a skinned glTF | -| [Animated Transform](../examples/animation/animated_transform.rs) | Create and play an animation defined by code that operates on the `Transform` component | -| [Cubic Curve](../examples/animation/cubic_curve.rs) | Bezier curve example showing a cube following a cubic curve | -| [Custom Skinned Mesh](../examples/animation/custom_skinned_mesh.rs) | Skinned mesh example with mesh and joints data defined in code | -| [glTF Skinned Mesh](../examples/animation/gltf_skinned_mesh.rs) | Skinned mesh example with mesh and joints data loaded from a glTF file | +Example | Description +--- | --- +[Animated Fox](../examples/animation/animated_fox.rs) | Plays an animation from a skinned glTF +[Animated Transform](../examples/animation/animated_transform.rs) | Create and play an animation defined by code that operates on the `Transform` component +[Cubic Curve](../examples/animation/cubic_curve.rs) | Bezier curve example showing a cube following a cubic curve +[Custom Skinned Mesh](../examples/animation/custom_skinned_mesh.rs) | Skinned mesh example with mesh and joints data defined in code +[glTF Skinned Mesh](../examples/animation/gltf_skinned_mesh.rs) | Skinned mesh example with mesh and joints data loaded from a glTF file ## Application -| Example | Description | -| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -| [Custom Loop](../examples/app/custom_loop.rs) | Demonstrates how to create a custom runner (to update an app manually) | -| [Drag and Drop](../examples/app/drag_and_drop.rs) | An example that shows how to handle drag and drop in an app | -| [Empty](../examples/app/empty.rs) | An empty application (does nothing) | -| [Empty with Defaults](../examples/app/empty_defaults.rs) | An empty application with default plugins | -| [Headless](../examples/app/headless.rs) | An application that runs without default plugins | -| [Logs](../examples/app/logs.rs) | Illustrate how to use generate log output | -| [No Renderer](../examples/app/no_renderer.rs) | An application that runs with default plugins and displays an empty window, but without an actual renderer | -| [Plugin](../examples/app/plugin.rs) | Demonstrates the creation and registration of a custom plugin | -| [Plugin Group](../examples/app/plugin_group.rs) | Demonstrates the creation and registration of a custom plugin group | -| [Return after Run](../examples/app/return_after_run.rs) | Show how to return to main after the Bevy app has exited | -| [Thread Pool Resources](../examples/app/thread_pool_resources.rs) | Creates and customizes the internal thread pool | -| [Without Winit](../examples/app/without_winit.rs) | Create an application without winit (runs single time, no event loop) | +Example | Description +--- | --- +[Custom Loop](../examples/app/custom_loop.rs) | Demonstrates how to create a custom runner (to update an app manually) +[Drag and Drop](../examples/app/drag_and_drop.rs) | An example that shows how to handle drag and drop in an app +[Empty](../examples/app/empty.rs) | An empty application (does nothing) +[Empty with Defaults](../examples/app/empty_defaults.rs) | An empty application with default plugins +[Headless](../examples/app/headless.rs) | An application that runs without default plugins +[Logs](../examples/app/logs.rs) | Illustrate how to use generate log output +[No Renderer](../examples/app/no_renderer.rs) | An application that runs with default plugins and displays an empty window, but without an actual renderer +[Plugin](../examples/app/plugin.rs) | Demonstrates the creation and registration of a custom plugin +[Plugin Group](../examples/app/plugin_group.rs) | Demonstrates the creation and registration of a custom plugin group +[Return after Run](../examples/app/return_after_run.rs) | Show how to return to main after the Bevy app has exited +[Thread Pool Resources](../examples/app/thread_pool_resources.rs) | Creates and customizes the internal thread pool +[Without Winit](../examples/app/without_winit.rs) | Create an application without winit (runs single time, no event loop) ## Assets -| Example | Description | -| ------------------------------------------------------------------- | ---------------------------------------------------------------- | -| [Asset Loading](../examples/asset/asset_loading.rs) | Demonstrates various methods to load assets | -| [Custom Asset](../examples/asset/custom_asset.rs) | Implements a custom asset loader | -| [Custom Asset IO](../examples/asset/custom_asset_io.rs) | Implements a custom asset io loader | -| [Hot Reloading of Assets](../examples/asset/hot_asset_reloading.rs) | Demonstrates automatic reloading of assets when modified on disk | +Example | Description +--- | --- +[Asset Loading](../examples/asset/asset_loading.rs) | Demonstrates various methods to load assets +[Custom Asset](../examples/asset/custom_asset.rs) | Implements a custom asset loader +[Custom Asset IO](../examples/asset/custom_asset_io.rs) | Implements a custom asset io loader +[Hot Reloading of Assets](../examples/asset/hot_asset_reloading.rs) | Demonstrates automatic reloading of assets when modified on disk ## Async Tasks -| Example | Description | -| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | -| [Async Compute](../examples/async_tasks/async_compute.rs) | How to use `AsyncComputeTaskPool` to complete longer running tasks | -| [External Source of Data on an External Thread](../examples/async_tasks/external_source_external_thread.rs) | How to use an external thread to run an infinite task and communicate with a channel | +Example | Description +--- | --- +[Async Compute](../examples/async_tasks/async_compute.rs) | How to use `AsyncComputeTaskPool` to complete longer running tasks +[External Source of Data on an External Thread](../examples/async_tasks/external_source_external_thread.rs) | How to use an external thread to run an infinite task and communicate with a channel ## Audio -| Example | Description | -| --------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -| [Audio](../examples/audio/audio.rs) | Shows how to load and play an audio file | -| [Audio Control](../examples/audio/audio_control.rs) | Shows how to load and play an audio file, and control how it's played | -| [Decodable](../examples/audio/decodable.rs) | Shows how to create and register a custom audio source by implementing the `Decodable` type. | -| [Spatial Audio 2D](../examples/audio/spatial_audio_2d.rs) | Shows how to play spatial audio, and moving the emitter in 2D | -| [Spatial Audio 3D](../examples/audio/spatial_audio_3d.rs) | Shows how to play spatial audio, and moving the emitter in 3D | +Example | Description +--- | --- +[Audio](../examples/audio/audio.rs) | Shows how to load and play an audio file +[Audio Control](../examples/audio/audio_control.rs) | Shows how to load and play an audio file, and control how it's played +[Decodable](../examples/audio/decodable.rs) | Shows how to create and register a custom audio source by implementing the `Decodable` type. +[Spatial Audio 2D](../examples/audio/spatial_audio_2d.rs) | Shows how to play spatial audio, and moving the emitter in 2D +[Spatial Audio 3D](../examples/audio/spatial_audio_3d.rs) | Shows how to play spatial audio, and moving the emitter in 3D ## Diagnostics -| Example | Description | -| ----------------------------------------------------------------- | -------------------------------------------------------------------------------- | -| [Custom Diagnostic](../examples/diagnostics/custom_diagnostic.rs) | Shows how to create a custom diagnostic | -| [Log Diagnostics](../examples/diagnostics/log_diagnostics.rs) | Add a plugin that logs diagnostics, like frames per second (FPS), to the console | +Example | Description +--- | --- +[Custom Diagnostic](../examples/diagnostics/custom_diagnostic.rs) | Shows how to create a custom diagnostic +[Log Diagnostics](../examples/diagnostics/log_diagnostics.rs) | Add a plugin that logs diagnostics, like frames per second (FPS), to the console ## ECS (Entity Component System) -| Example | Description | -| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | -| [Apply System Buffers](../examples/ecs/apply_deferred.rs) | Show how to use `apply_deferred` system | -| [Component Change Detection](../examples/ecs/component_change_detection.rs) | Change detection on components | -| [Custom Query Parameters](../examples/ecs/custom_query_param.rs) | Groups commonly used compound queries and query filters into a single type | -| [ECS Guide](../examples/ecs/ecs_guide.rs) | Full guide to Bevy's ECS | -| [Event](../examples/ecs/event.rs) | Illustrates event creation, activation, and reception | -| [Fixed Timestep](../examples/ecs/fixed_timestep.rs) | Shows how to create systems that run every fixed timestep, rather than every tick | -| [Generic System](../examples/ecs/generic_system.rs) | Shows how to create systems that can be reused with different types | -| [Hierarchy](../examples/ecs/hierarchy.rs) | Creates a hierarchy of parents and children entities | -| [Iter Combinations](../examples/ecs/iter_combinations.rs) | Shows how to iterate over combinations of query results | -| [Nondeterministic System Order](../examples/ecs/nondeterministic_system_order.rs) | Systems run in parallel, but their order isn't always deterministic. Here's how to detect and fix this. | -| [Parallel Query](../examples/ecs/parallel_query.rs) | Illustrates parallel queries with `ParallelIterator` | -| [Removal Detection](../examples/ecs/removal_detection.rs) | Query for entities that had a specific component removed earlier in the current frame | -| [Run Conditions](../examples/ecs/run_conditions.rs) | Run systems only when one or multiple conditions are met | -| [Startup System](../examples/ecs/startup_system.rs) | Demonstrates a startup system (one that runs once when the app starts up) | -| [State](../examples/ecs/state.rs) | Illustrates how to use States to control transitioning from a Menu state to an InGame state | -| [System Closure](../examples/ecs/system_closure.rs) | Show how to use closures as systems, and how to configure `Local` variables by capturing external state | -| [System Parameter](../examples/ecs/system_param.rs) | Illustrates creating custom system parameters with `SystemParam` | -| [System Piping](../examples/ecs/system_piping.rs) | Pipe the output of one system into a second, allowing you to handle any errors gracefully | -| [Timers](../examples/ecs/timers.rs) | Illustrates ticking `Timer` resources inside systems and handling their state | +Example | Description +--- | --- +[Apply System Buffers](../examples/ecs/apply_deferred.rs) | Show how to use `apply_deferred` system +[Component Change Detection](../examples/ecs/component_change_detection.rs) | Change detection on components +[Custom Query Parameters](../examples/ecs/custom_query_param.rs) | Groups commonly used compound queries and query filters into a single type +[ECS Guide](../examples/ecs/ecs_guide.rs) | Full guide to Bevy's ECS +[Event](../examples/ecs/event.rs) | Illustrates event creation, activation, and reception +[Fixed Timestep](../examples/ecs/fixed_timestep.rs) | Shows how to create systems that run every fixed timestep, rather than every tick +[Generic System](../examples/ecs/generic_system.rs) | Shows how to create systems that can be reused with different types +[Hierarchy](../examples/ecs/hierarchy.rs) | Creates a hierarchy of parents and children entities +[Iter Combinations](../examples/ecs/iter_combinations.rs) | Shows how to iterate over combinations of query results +[Nondeterministic System Order](../examples/ecs/nondeterministic_system_order.rs) | Systems run in parallel, but their order isn't always deterministic. Here's how to detect and fix this. +[Parallel Query](../examples/ecs/parallel_query.rs) | Illustrates parallel queries with `ParallelIterator` +[Removal Detection](../examples/ecs/removal_detection.rs) | Query for entities that had a specific component removed earlier in the current frame +[Run Conditions](../examples/ecs/run_conditions.rs) | Run systems only when one or multiple conditions are met +[Startup System](../examples/ecs/startup_system.rs) | Demonstrates a startup system (one that runs once when the app starts up) +[State](../examples/ecs/state.rs) | Illustrates how to use States to control transitioning from a Menu state to an InGame state +[System Closure](../examples/ecs/system_closure.rs) | Show how to use closures as systems, and how to configure `Local` variables by capturing external state +[System Parameter](../examples/ecs/system_param.rs) | Illustrates creating custom system parameters with `SystemParam` +[System Piping](../examples/ecs/system_piping.rs) | Pipe the output of one system into a second, allowing you to handle any errors gracefully +[Timers](../examples/ecs/timers.rs) | Illustrates ticking `Timer` resources inside systems and handling their state ## Games -| Example | Description | -| ----------------------------------------------------------- | ------------------------------------------------ | -| [Alien Cake Addict](../examples/games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game | -| [Breakout](../examples/games/breakout.rs) | An implementation of the classic game "Breakout" | -| [Contributors](../examples/games/contributors.rs) | Displays each contributor as a bouncy bevy-ball! | -| [Game Menu](../examples/games/game_menu.rs) | A simple game menu | +Example | Description +--- | --- +[Alien Cake Addict](../examples/games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game +[Breakout](../examples/games/breakout.rs) | An implementation of the classic game "Breakout" +[Contributors](../examples/games/contributors.rs) | Displays each contributor as a bouncy bevy-ball! +[Game Menu](../examples/games/game_menu.rs) | A simple game menu ## Input -| Example | Description | -| ------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| [Char Input Events](../examples/input/char_input_events.rs) | Prints out all chars as they are inputted | -| [Gamepad Input](../examples/input/gamepad_input.rs) | Shows handling of gamepad input, connections, and disconnections | -| [Gamepad Input Events](../examples/input/gamepad_input_events.rs) | Iterates and prints gamepad input and connection events | -| [Gamepad Rumble](../examples/input/gamepad_rumble.rs) | Shows how to rumble a gamepad using force feedback | -| [Keyboard Input](../examples/input/keyboard_input.rs) | Demonstrates handling a key press/release | -| [Keyboard Input Events](../examples/input/keyboard_input_events.rs) | Prints out all keyboard events | -| [Keyboard Modifiers](../examples/input/keyboard_modifiers.rs) | Demonstrates using key modifiers (ctrl, shift) | -| [Mouse Grab](../examples/input/mouse_grab.rs) | Demonstrates how to grab the mouse, locking the cursor to the app's screen | -| [Mouse Input](../examples/input/mouse_input.rs) | Demonstrates handling a mouse button press/release | -| [Mouse Input Events](../examples/input/mouse_input_events.rs) | Prints out all mouse events (buttons, movement, etc.) | -| [Text Input](../examples/input/text_input.rs) | Simple text input with IME support | -| [Touch Input](../examples/input/touch_input.rs) | Displays touch presses, releases, and cancels | -| [Touch Input Events](../examples/input/touch_input_events.rs) | Prints out all touch inputs | +Example | Description +--- | --- +[Char Input Events](../examples/input/char_input_events.rs) | Prints out all chars as they are inputted +[Gamepad Input](../examples/input/gamepad_input.rs) | Shows handling of gamepad input, connections, and disconnections +[Gamepad Input Events](../examples/input/gamepad_input_events.rs) | Iterates and prints gamepad input and connection events +[Gamepad Rumble](../examples/input/gamepad_rumble.rs) | Shows how to rumble a gamepad using force feedback +[Keyboard Input](../examples/input/keyboard_input.rs) | Demonstrates handling a key press/release +[Keyboard Input Events](../examples/input/keyboard_input_events.rs) | Prints out all keyboard events +[Keyboard Modifiers](../examples/input/keyboard_modifiers.rs) | Demonstrates using key modifiers (ctrl, shift) +[Mouse Grab](../examples/input/mouse_grab.rs) | Demonstrates how to grab the mouse, locking the cursor to the app's screen +[Mouse Input](../examples/input/mouse_input.rs) | Demonstrates handling a mouse button press/release +[Mouse Input Events](../examples/input/mouse_input_events.rs) | Prints out all mouse events (buttons, movement, etc.) +[Text Input](../examples/input/text_input.rs) | Simple text input with IME support +[Touch Input](../examples/input/touch_input.rs) | Displays touch presses, releases, and cancels +[Touch Input Events](../examples/input/touch_input_events.rs) | Prints out all touch inputs ## Reflection -| Example | Description | -| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | -| [Generic Reflection](../examples/reflection/generic_reflection.rs) | Registers concrete instances of generic types that may be used with reflection | -| [Reflection](../examples/reflection/reflection.rs) | Demonstrates how reflection in Bevy provides a way to dynamically interact with Rust types | -| [Reflection Types](../examples/reflection/reflection_types.rs) | Illustrates the various reflection types available | -| [Trait Reflection](../examples/reflection/trait_reflection.rs) | Allows reflection with trait objects | +Example | Description +--- | --- +[Generic Reflection](../examples/reflection/generic_reflection.rs) | Registers concrete instances of generic types that may be used with reflection +[Reflection](../examples/reflection/reflection.rs) | Demonstrates how reflection in Bevy provides a way to dynamically interact with Rust types +[Reflection Types](../examples/reflection/reflection_types.rs) | Illustrates the various reflection types available +[Trait Reflection](../examples/reflection/trait_reflection.rs) | Allows reflection with trait objects ## Scene -| Example | Description | -| ----------------------------------- | ---------------------------------------------------- | -| [Scene](../examples/scene/scene.rs) | Demonstrates loading from and saving scenes to files | +Example | Description +--- | --- +[Scene](../examples/scene/scene.rs) | Demonstrates loading from and saving scenes to files ## Shaders @@ -276,20 +276,20 @@ A shader in its most common usage is a small program that is run by the GPU per- There are also compute shaders which are used for more general processing leveraging the GPU's parallelism. -| Example | Description | -| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -| [Animated](../examples/shader/animate_shader.rs) | A shader that uses dynamic data like the time since startup | -| [Array Texture](../examples/shader/array_texture.rs) | A shader that shows how to reuse the core bevy PBR shading functionality in a custom material that obtains the base color from an array texture. | -| [Compute - Game of Life](../examples/shader/compute_shader_game_of_life.rs) | A compute shader that simulates Conway's Game of Life | -| [Custom Vertex Attribute](../examples/shader/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute | -| [Instancing](../examples/shader/shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call | -| [Material](../examples/shader/shader_material.rs) | A shader and a material that uses it | -| [Material - GLSL](../examples/shader/shader_material_glsl.rs) | A shader that uses the GLSL shading language | -| [Material - Screenspace Texture](../examples/shader/shader_material_screenspace_texture.rs) | A shader that samples a texture with view-independent UV coordinates | -| [Material Prepass](../examples/shader/shader_prepass.rs) | A shader that uses the various textures generated by the prepass | -| [Post Processing - Custom Render Pass](../examples/shader/post_processing.rs) | A custom post processing effect, using a custom render pass that runs after the main pass | -| [Shader Defs](../examples/shader/shader_defs.rs) | A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader) | -| [Texture Binding Array (Bindless Textures)](../examples/shader/texture_binding_array.rs) | A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures). | +Example | Description +--- | --- +[Animated](../examples/shader/animate_shader.rs) | A shader that uses dynamic data like the time since startup +[Array Texture](../examples/shader/array_texture.rs) | A shader that shows how to reuse the core bevy PBR shading functionality in a custom material that obtains the base color from an array texture. +[Compute - Game of Life](../examples/shader/compute_shader_game_of_life.rs) | A compute shader that simulates Conway's Game of Life +[Custom Vertex Attribute](../examples/shader/custom_vertex_attribute.rs) | A shader that reads a mesh's custom vertex attribute +[Instancing](../examples/shader/shader_instancing.rs) | A shader that renders a mesh multiple times in one draw call +[Material](../examples/shader/shader_material.rs) | A shader and a material that uses it +[Material - GLSL](../examples/shader/shader_material_glsl.rs) | A shader that uses the GLSL shading language +[Material - Screenspace Texture](../examples/shader/shader_material_screenspace_texture.rs) | A shader that samples a texture with view-independent UV coordinates +[Material Prepass](../examples/shader/shader_prepass.rs) | A shader that uses the various textures generated by the prepass +[Post Processing - Custom Render Pass](../examples/shader/post_processing.rs) | A custom post processing effect, using a custom render pass that runs after the main pass +[Shader Defs](../examples/shader/shader_defs.rs) | A shader that uses "shaders defs" (a bevy tool to selectively toggle parts of a shader) +[Texture Binding Array (Bindless Textures)](../examples/shader/texture_binding_array.rs) | A shader that shows how to bind and sample multiple textures as a binding array (a.k.a. bindless textures). ## Stress Tests @@ -301,75 +301,75 @@ Due to the focus on performance it's recommended to run the stress tests in rele cargo run --release --example ``` -| Example | Description | -| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [Bevymark](../examples/stress_tests/bevymark.rs) | A heavy sprite rendering workload to benchmark your system with Bevy | -| [Many Animated Sprites](../examples/stress_tests/many_animated_sprites.rs) | Displays many animated sprites in a grid arrangement with slight offsets to their animation timers. Used for performance testing. | -| [Many Buttons](../examples/stress_tests/many_buttons.rs) | Test rendering of many UI elements | -| [Many Cubes](../examples/stress_tests/many_cubes.rs) | Simple benchmark to test per-entity draw overhead. Run with the `sphere` argument to test frustum culling | -| [Many Foxes](../examples/stress_tests/many_foxes.rs) | Loads an animated fox model and spawns lots of them. Good for testing skinned mesh performance. Takes an unsigned integer argument for the number of foxes to spawn. Defaults to 1000 | -| [Many Gizmos](../examples/stress_tests/many_gizmos.rs) | Test rendering of many gizmos | -| [Many Glyphs](../examples/stress_tests/many_glyphs.rs) | Simple benchmark to test text rendering. | -| [Many Lights](../examples/stress_tests/many_lights.rs) | Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights | -| [Many Sprites](../examples/stress_tests/many_sprites.rs) | Displays many sprites in a grid arrangement! Used for performance testing. Use `--colored` to enable color tinted sprites. | -| [Text Pipeline](../examples/stress_tests/text_pipeline.rs) | Text Pipeline benchmark | -| [Transform Hierarchy](../examples/stress_tests/transform_hierarchy.rs) | Various test cases for hierarchy and transform propagation performance | +Example | Description +--- | --- +[Bevymark](../examples/stress_tests/bevymark.rs) | A heavy sprite rendering workload to benchmark your system with Bevy +[Many Animated Sprites](../examples/stress_tests/many_animated_sprites.rs) | Displays many animated sprites in a grid arrangement with slight offsets to their animation timers. Used for performance testing. +[Many Buttons](../examples/stress_tests/many_buttons.rs) | Test rendering of many UI elements +[Many Cubes](../examples/stress_tests/many_cubes.rs) | Simple benchmark to test per-entity draw overhead. Run with the `sphere` argument to test frustum culling +[Many Foxes](../examples/stress_tests/many_foxes.rs) | Loads an animated fox model and spawns lots of them. Good for testing skinned mesh performance. Takes an unsigned integer argument for the number of foxes to spawn. Defaults to 1000 +[Many Gizmos](../examples/stress_tests/many_gizmos.rs) | Test rendering of many gizmos +[Many Glyphs](../examples/stress_tests/many_glyphs.rs) | Simple benchmark to test text rendering. +[Many Lights](../examples/stress_tests/many_lights.rs) | Simple benchmark to test rendering many point lights. Run with `WGPU_SETTINGS_PRIO=webgl2` to restrict to uniform buffers and max 256 lights +[Many Sprites](../examples/stress_tests/many_sprites.rs) | Displays many sprites in a grid arrangement! Used for performance testing. Use `--colored` to enable color tinted sprites. +[Text Pipeline](../examples/stress_tests/text_pipeline.rs) | Text Pipeline benchmark +[Transform Hierarchy](../examples/stress_tests/transform_hierarchy.rs) | Various test cases for hierarchy and transform propagation performance ## Tools -| Example | Description | -| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [Gamepad Viewer](../examples/tools/gamepad_viewer.rs) | Shows a visualization of gamepad buttons, sticks, and triggers | -| [Scene Viewer](../examples/tools/scene_viewer/main.rs) | A simple way to view glTF models with Bevy. Just run `cargo run --release --example scene_viewer /path/to/model.gltf#Scene0`, replacing the path as appropriate. With no arguments it will load the FieldHelmet glTF model from the repository assets subdirectory | +Example | Description +--- | --- +[Gamepad Viewer](../examples/tools/gamepad_viewer.rs) | Shows a visualization of gamepad buttons, sticks, and triggers +[Scene Viewer](../examples/tools/scene_viewer/main.rs) | A simple way to view glTF models with Bevy. Just run `cargo run --release --example scene_viewer /path/to/model.gltf#Scene0`, replacing the path as appropriate. With no arguments it will load the FieldHelmet glTF model from the repository assets subdirectory ## Transforms -| Example | Description | -| ---------------------------------------------------- | --------------------------------------------------------------- | -| [3D Rotation](../examples/transforms/3d_rotation.rs) | Illustrates how to (constantly) rotate an object around an axis | -| [Scale](../examples/transforms/scale.rs) | Illustrates how to scale an object in each direction | -| [Transform](../examples/transforms/transform.rs) | Shows multiple transformations of objects | -| [Translation](../examples/transforms/translation.rs) | Illustrates how to move an object along an axis | +Example | Description +--- | --- +[3D Rotation](../examples/transforms/3d_rotation.rs) | Illustrates how to (constantly) rotate an object around an axis +[Scale](../examples/transforms/scale.rs) | Illustrates how to scale an object in each direction +[Transform](../examples/transforms/transform.rs) | Shows multiple transformations of objects +[Translation](../examples/transforms/translation.rs) | Illustrates how to move an object along an axis ## UI (User Interface) -| Example | Description | -| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | -| [Button](../examples/ui/button.rs) | Illustrates creating and updating a button | -| [CSS Grid](../examples/ui/grid.rs) | An example for CSS Grid layout | -| [Flex Layout](../examples/ui/flex_layout.rs) | Demonstrates how the AlignItems and JustifyContent properties can be composed to layout nodes and position text | -| [Font Atlas Debug](../examples/ui/font_atlas_debug.rs) | Illustrates how FontAtlases are populated (used to optimize text rendering internally) | -| [Overflow](../examples/ui/overflow.rs) | Simple example demonstrating overflow behavior | -| [Overflow and Clipping Debug](../examples/ui/overflow_debug.rs) | An example to debug overflow and clipping behavior | -| [Relative Cursor Position](../examples/ui/relative_cursor_position.rs) | Showcases the RelativeCursorPosition component | -| [Size Constraints](../examples/ui/size_constraints.rs) | Demonstrates how the to use the size constraints to control the size of a UI node. | -| [Text](../examples/ui/text.rs) | Illustrates creating and updating text | -| [Text Debug](../examples/ui/text_debug.rs) | An example for debugging text layout | -| [Text Wrap Debug](../examples/ui/text_wrap_debug.rs) | Demonstrates text wrapping | -| [Transparency UI](../examples/ui/transparency_ui.rs) | Demonstrates transparency for UI | -| [UI](../examples/ui/ui.rs) | Illustrates various features of Bevy UI | -| [UI Scaling](../examples/ui/ui_scaling.rs) | Illustrates how to scale the UI | -| [UI Z-Index](../examples/ui/z_index.rs) | Demonstrates how to control the relative depth (z-position) of UI elements | -| [Window Fallthrough](../examples/ui/window_fallthrough.rs) | Illustrates how to access `winit::window::Window`'s `hittest` functionality. | +Example | Description +--- | --- +[Button](../examples/ui/button.rs) | Illustrates creating and updating a button +[CSS Grid](../examples/ui/grid.rs) | An example for CSS Grid layout +[Flex Layout](../examples/ui/flex_layout.rs) | Demonstrates how the AlignItems and JustifyContent properties can be composed to layout nodes and position text +[Font Atlas Debug](../examples/ui/font_atlas_debug.rs) | Illustrates how FontAtlases are populated (used to optimize text rendering internally) +[Overflow](../examples/ui/overflow.rs) | Simple example demonstrating overflow behavior +[Overflow and Clipping Debug](../examples/ui/overflow_debug.rs) | An example to debug overflow and clipping behavior +[Relative Cursor Position](../examples/ui/relative_cursor_position.rs) | Showcases the RelativeCursorPosition component +[Size Constraints](../examples/ui/size_constraints.rs) | Demonstrates how the to use the size constraints to control the size of a UI node. +[Text](../examples/ui/text.rs) | Illustrates creating and updating text +[Text Debug](../examples/ui/text_debug.rs) | An example for debugging text layout +[Text Wrap Debug](../examples/ui/text_wrap_debug.rs) | Demonstrates text wrapping +[Transparency UI](../examples/ui/transparency_ui.rs) | Demonstrates transparency for UI +[UI](../examples/ui/ui.rs) | Illustrates various features of Bevy UI +[UI Scaling](../examples/ui/ui_scaling.rs) | Illustrates how to scale the UI +[UI Z-Index](../examples/ui/z_index.rs) | Demonstrates how to control the relative depth (z-position) of UI elements +[Window Fallthrough](../examples/ui/window_fallthrough.rs) | Illustrates how to access `winit::window::Window`'s `hittest` functionality. ## Window -| Example | Description | -| -------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| [Clear Color](../examples/window/clear_color.rs) | Creates a solid color window | -| [Low Power](../examples/window/low_power.rs) | Demonstrates settings to reduce power use for bevy applications | -| [Multiple Windows](../examples/window/multiple_windows.rs) | Demonstrates creating multiple windows, and rendering to them | -| [Scale Factor Override](../examples/window/scale_factor_override.rs) | Illustrates how to customize the default window settings | -| [Screenshot](../examples/window/screenshot.rs) | Shows how to save screenshots to disk | -| [Transparent Window](../examples/window/transparent_window.rs) | Illustrates making the window transparent and hiding the window decoration | -| [Window Resizing](../examples/window/window_resizing.rs) | Demonstrates resizing and responding to resizing a window | -| [Window Settings](../examples/window/window_settings.rs) | Demonstrates customizing default window settings | +Example | Description +--- | --- +[Clear Color](../examples/window/clear_color.rs) | Creates a solid color window +[Low Power](../examples/window/low_power.rs) | Demonstrates settings to reduce power use for bevy applications +[Multiple Windows](../examples/window/multiple_windows.rs) | Demonstrates creating multiple windows, and rendering to them +[Scale Factor Override](../examples/window/scale_factor_override.rs) | Illustrates how to customize the default window settings +[Screenshot](../examples/window/screenshot.rs) | Shows how to save screenshots to disk +[Transparent Window](../examples/window/transparent_window.rs) | Illustrates making the window transparent and hiding the window decoration +[Window Resizing](../examples/window/window_resizing.rs) | Demonstrates resizing and responding to resizing a window +[Window Settings](../examples/window/window_settings.rs) | Demonstrates customizing default window settings # Tests -| Example | Description | -| ------------------------------------------------------ | ------------------------------------------------------- | -| [How to Test Systems](../tests/how_to_test_systems.rs) | How to test systems with commands, queries or resources | +Example | Description +--- | --- +[How to Test Systems](../tests/how_to_test_systems.rs) | How to test systems with commands, queries or resources # Platform-Specific Examples @@ -436,9 +436,9 @@ target_sdk_version = >>API<< min_sdk_version = >>API or less<< ``` -| Example | File | Description | -| --------- | ------------------------------------------ | ------------------------------------------ | -| `android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound | +Example | File | Description +--- | --- | --- +`android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound ## iOS @@ -480,9 +480,9 @@ open bevy_mobile_example.xcodeproj/ which will open xcode. You then must push the zoom zoom play button and wait for the magic. -| Example | File | Description | -| ------- | ------------------------------------------ | ------------------------------------------ | -| `ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound | +Example | File | Description +--- | --- | --- +`ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound ## WASM @@ -603,14 +603,14 @@ mv optimized.wasm examples/wasm/target/lighting_bg.wasm For a small project with a basic 3d model and two lights, the generated file sizes are, as of Jully 2022 as following: -| profile | wasm-opt | no wasm-opt | -| -------------------------------- | -------- | ----------- | -| Default | 8.5M | 13.0M | -| opt-level = "z" | 6.1M | 12.7M | -| "z" + lto = "thin" | 5.9M | 12M | -| "z" + lto = "fat" | 5.1M | 9.4M | -| "z" + "thin" + codegen-units = 1 | 5.3M | 11M | -| "z" + "fat" + codegen-units = 1 | 4.8M | 8.5M | +|profile | wasm-opt | no wasm-opt | +|----------------------------------|----------|-------------| +|Default | 8.5M | 13.0M | +|opt-level = "z" | 6.1M | 12.7M | +|"z" + lto = "thin" | 5.9M | 12M | +|"z" + lto = "fat" | 5.1M | 9.4M | +|"z" + "thin" + codegen-units = 1 | 5.3M | 11M | +|"z" + "fat" + codegen-units = 1 | 4.8M | 8.5M | There are more advanced optimization options available, check the following pages for more info: From 44b8df9814e4e883699e85bb1b0458ed9104811b Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Fri, 2 Jun 2023 09:48:40 -0400 Subject: [PATCH 09/10] Add doc alias Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com> --- crates/bevy_ecs/src/schedule/executor/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index f92031aa3311b..2e14d41500f1a 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -83,6 +83,7 @@ impl SystemSchedule { /// **Notes** /// - This function (currently) does nothing if it's called manually or wrapped inside a [`PipeSystem`](crate::system::PipeSystem). /// - Modifying a [`Schedule`](super::Schedule) may change the order buffers are applied. +#[doc(alias = "apply_system_buffers")] #[allow(unused_variables)] pub fn apply_deferred(world: &mut World) {} From 18fc50d958faf4f0ec0c6233666e0edcef35586a Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Fri, 2 Jun 2023 09:49:23 -0400 Subject: [PATCH 10/10] Revert accidental change to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 958ee68c62abf..ade264b8a6473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ current changes on git with [previous release tags][git_tag_comparison]. - [ECS: Add a missing impl of `ReadOnlySystemParam` for `Option>`][7245] - [ECS: add a spawn_on_external method to allow spawning on the scope’s thread or an external thread][7415] - [ECS: Add const `Entity::PLACEHOLDER`][6761] -- [ECS: Add example to show how to use `apply_deferred`][7793] +- [ECS: Add example to show how to use `apply_system_buffers`][7793] - [ECS: Add logging variants of system piping][6751] - [ECS: Add safe constructors for untyped pointers `Ptr` and `PtrMut`][6539] - [ECS: Add unit test with system that panics][7491]