From 557408e056be1eca8da47c6b65f88a6b7c77de8c Mon Sep 17 00:00:00 2001 From: B_head Date: Sat, 8 Jul 2023 13:17:35 +0900 Subject: [PATCH] Adjust schedules to add systems --- crates/bevy_asset/src/debug_asset_server.rs | 2 +- .../diagnostic/asset_count_diagnostics_plugin.rs | 2 +- crates/bevy_asset/src/lib.rs | 14 +++++++------- crates/bevy_audio/src/lib.rs | 4 ++-- crates/bevy_core/src/lib.rs | 2 +- .../src/entity_count_diagnostics_plugin.rs | 2 +- .../src/frame_time_diagnostics_plugin.rs | 2 +- .../bevy_diagnostic/src/log_diagnostics_plugin.rs | 4 ++-- .../src/system_information_diagnostics_plugin.rs | 2 +- crates/bevy_gilrs/src/lib.rs | 6 +++--- crates/bevy_gizmos/src/lib.rs | 6 +++--- crates/bevy_input/src/lib.rs | 6 +++--- crates/bevy_render/src/mesh/morph.rs | 4 ++-- crates/bevy_render/src/render_resource/texture.rs | 1 + crates/bevy_render/src/renderer/render_device.rs | 2 +- crates/bevy_render/src/view/visibility/mod.rs | 8 ++++---- crates/bevy_render/src/view/window/screenshot.rs | 1 + crates/bevy_time/src/lib.rs | 2 +- crates/bevy_ui/src/lib.rs | 2 +- crates/bevy_window/src/lib.rs | 6 +++--- crates/bevy_winit/src/accessibility.rs | 14 +++++--------- crates/bevy_winit/src/lib.rs | 4 ++-- crates/bevy_winit/src/web_resize.rs | 4 ++-- crates/bevy_winit/src/winit_handler.rs | 2 +- 24 files changed, 50 insertions(+), 52 deletions(-) diff --git a/crates/bevy_asset/src/debug_asset_server.rs b/crates/bevy_asset/src/debug_asset_server.rs index d858f083e3659..3c4394d7ab945 100644 --- a/crates/bevy_asset/src/debug_asset_server.rs +++ b/crates/bevy_asset/src/debug_asset_server.rs @@ -76,7 +76,7 @@ impl Plugin for DebugAssetServerPlugin { watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)), }); app.insert_non_send_resource(DebugAssetApp(debug_asset_app)); - app.add_systems(Update, run_debug_asset_app); + app.add_systems(FrameReady, run_debug_asset_app); } } diff --git a/crates/bevy_asset/src/diagnostic/asset_count_diagnostics_plugin.rs b/crates/bevy_asset/src/diagnostic/asset_count_diagnostics_plugin.rs index dafd21567347b..137239365c8c3 100644 --- a/crates/bevy_asset/src/diagnostic/asset_count_diagnostics_plugin.rs +++ b/crates/bevy_asset/src/diagnostic/asset_count_diagnostics_plugin.rs @@ -21,7 +21,7 @@ impl Default for AssetCountDiagnosticsPlugin { impl Plugin for AssetCountDiagnosticsPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, Self::setup_system) - .add_systems(Update, Self::diagnostic_system); + .add_systems(FrameReady, Self::diagnostic_system); } } diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 4bf8448f602f6..284050f0fcf9f 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -47,8 +47,8 @@ pub use loader::*; pub use path::*; pub use reflect::*; -use bevy_app::{prelude::*, UpdateFlowOrder}; -use bevy_ecs::schedule::ScheduleLabel; +use bevy_app::prelude::*; +use bevy_ecs::{schedule::ScheduleLabel, world::World}; use bevy_utils::Duration; /// Asset storages are updated. @@ -132,7 +132,6 @@ impl Plugin for AssetPlugin { app.register_type::(); app.register_type::(); - app.add_systems(PreUpdate, asset_server::free_unused_assets_system); app.init_schedule(LoadAssets); app.init_schedule(AssetEvents); @@ -141,9 +140,10 @@ impl Plugin for AssetPlugin { all(not(target_arch = "wasm32"), not(target_os = "android")) ))] app.add_systems(LoadAssets, io::filesystem_watcher_system); - - let mut order = app.world.resource_mut::(); - order.insert_after(First, LoadAssets); - order.insert_after(PostUpdate, AssetEvents); + app.add_systems(LoadAssets, asset_server::free_unused_assets_system); + app.add_systems(FrameReady, |world: &mut World| { + world.run_schedule(LoadAssets); + world.run_schedule(AssetEvents); + }); } } diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index 6544c789698fc..b5e9c3f6887eb 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -64,7 +64,7 @@ impl Plugin for AudioPlugin { .add_asset::() .init_resource::>() .insert_resource(self.global_volume) - .add_systems(PostUpdate, play_queued_audio_system::); + .add_systems(FrameReady, play_queued_audio_system::); #[cfg(any(feature = "mp3", feature = "flac", feature = "wav", feature = "vorbis"))] app.init_asset_loader::(); @@ -80,6 +80,6 @@ impl AddAudioSource for App { self.add_asset::() .init_resource::>() .init_resource::>() - .add_systems(PostUpdate, play_queued_audio_system::) + .add_systems(FrameReady, play_queued_audio_system::) } } diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index d21b40d7a96c2..6e96343d8d3fd 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -114,7 +114,7 @@ impl Plugin for TaskPoolPlugin { self.task_pool_options.create_default_pools(); #[cfg(not(target_arch = "wasm32"))] - _app.add_systems(Last, tick_global_task_pools); + _app.add_systems(FrameReady, tick_global_task_pools); } } /// A dummy type that is [`!Send`](Send), to force systems to run on the main thread. diff --git a/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs index 8999163aa9720..e2989d0134421 100644 --- a/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs @@ -10,7 +10,7 @@ pub struct EntityCountDiagnosticsPlugin; impl Plugin for EntityCountDiagnosticsPlugin { fn build(&self, app: &mut App) { app.register_diagnostic(Diagnostic::new(Self::ENTITY_COUNT, "entity_count", 20)) - .add_systems(Update, Self::diagnostic_system); + .add_systems(FrameReady, Self::diagnostic_system); } } diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index a17a6a19d4c13..703ad54949169 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -17,7 +17,7 @@ impl Plugin for FrameTimeDiagnosticsPlugin { .register_diagnostic( Diagnostic::new(Self::FRAME_COUNT, "frame_count", 1).with_smoothing_factor(0.0), ) - .add_systems(Update, Self::diagnostic_system); + .add_systems(FrameReady, Self::diagnostic_system); } } diff --git a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs index c59d128d890aa..6fc18ee2521bd 100644 --- a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs @@ -37,9 +37,9 @@ impl Plugin for LogDiagnosticsPlugin { }); if self.debug { - app.add_systems(PostUpdate, Self::log_diagnostics_debug_system); + app.add_systems(FrameReady, Self::log_diagnostics_debug_system); } else { - app.add_systems(PostUpdate, Self::log_diagnostics_system); + app.add_systems(FrameReady, Self::log_diagnostics_system); } } } diff --git a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs index 5380bdbda2e4b..e6ce8b79bc517 100644 --- a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs @@ -15,7 +15,7 @@ pub struct SystemInformationDiagnosticsPlugin; impl Plugin for SystemInformationDiagnosticsPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, internal::setup_system) - .add_systems(Update, internal::diagnostic_system); + .add_systems(FrameReady, internal::diagnostic_system); } } diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index 1afcf515f6613..114b46a3357c9 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -4,7 +4,7 @@ mod converter; mod gilrs_system; mod rumble; -use bevy_app::{App, Plugin, PostUpdate, PreStartup, PreUpdate}; +use bevy_app::{App, Control, FrameReady, Plugin, PreStartup}; use bevy_ecs::prelude::*; use bevy_input::InputSystem; use bevy_utils::tracing::error; @@ -30,8 +30,8 @@ impl Plugin for GilrsPlugin { app.insert_non_send_resource(gilrs) .init_non_send_resource::() .add_systems(PreStartup, gilrs_event_startup_system) - .add_systems(PreUpdate, gilrs_event_system.before(InputSystem)) - .add_systems(PostUpdate, play_gilrs_rumble.in_set(RumbleSystem)); + .add_systems(Control, gilrs_event_system.before(InputSystem)) + .add_systems(FrameReady, play_gilrs_rumble.in_set(RumbleSystem)); } Err(err) => error!("Failed to start Gilrs. {}", err), } diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 194341878ea0e..1cab57a530e99 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -18,7 +18,7 @@ use std::mem; -use bevy_app::{Last, Plugin, RenderFlow, Update}; +use bevy_app::{FrameReady, Plugin, RenderFlow}; use bevy_asset::{load_internal_asset, AddAsset, Assets, Handle, HandleUntyped}; use bevy_core::cast_slice; use bevy_ecs::{ @@ -84,12 +84,12 @@ impl Plugin for GizmoPlugin { .init_resource::() .init_resource::() .init_resource::() - .add_systems(Last, update_gizmo_meshes) .add_systems( - Update, + FrameReady, ( draw_aabbs, draw_all_aabbs.run_if(|config: Res| config.aabb.draw_all), + update_gizmo_meshes, ), ); diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs index 4f343ece0dbf2..f6f744e1ff06f 100644 --- a/crates/bevy_input/src/lib.rs +++ b/crates/bevy_input/src/lib.rs @@ -62,13 +62,13 @@ impl Plugin for InputPlugin { .add_event::() .init_resource::>() .init_resource::>() - .add_systems(PreUpdate, keyboard_input_system.in_set(InputSystem)) + .add_systems(Control, keyboard_input_system.in_set(InputSystem)) // mouse .add_event::() .add_event::() .add_event::() .init_resource::>() - .add_systems(PreUpdate, mouse_button_input_system.in_set(InputSystem)) + .add_systems(Control, mouse_button_input_system.in_set(InputSystem)) .add_event::() .add_event::() // gamepad @@ -99,7 +99,7 @@ impl Plugin for InputPlugin { // touch .add_event::() .init_resource::() - .add_systems(PreUpdate, touch_screen_input_system.in_set(InputSystem)); + .add_systems(Control, touch_screen_input_system.in_set(InputSystem)); // Register common types app.register_type::(); diff --git a/crates/bevy_render/src/mesh/morph.rs b/crates/bevy_render/src/mesh/morph.rs index c6eba94b477e1..d385a7b95ac15 100644 --- a/crates/bevy_render/src/mesh/morph.rs +++ b/crates/bevy_render/src/mesh/morph.rs @@ -3,7 +3,7 @@ use crate::{ render_resource::{Extent3d, TextureDimension, TextureFormat}, texture::Image, }; -use bevy_app::{Plugin, PostUpdate}; +use bevy_app::{FrameReady, Plugin}; use bevy_asset::Handle; use bevy_ecs::prelude::*; use bevy_hierarchy::Children; @@ -28,7 +28,7 @@ impl Plugin for MorphPlugin { fn build(&self, app: &mut bevy_app::App) { app.register_type::() .register_type::() - .add_systems(PostUpdate, inherit_weights); + .add_systems(FrameReady, inherit_weights); } } diff --git a/crates/bevy_render/src/render_resource/texture.rs b/crates/bevy_render/src/render_resource/texture.rs index df0df616a6f6c..aa95cf9ca1120 100644 --- a/crates/bevy_render/src/render_resource/texture.rs +++ b/crates/bevy_render/src/render_resource/texture.rs @@ -58,6 +58,7 @@ pub struct TextureView { value: ErasedTextureView, } +#[derive(Debug)] pub struct SurfaceTexture { value: ErasedSurfaceTexture, } diff --git a/crates/bevy_render/src/renderer/render_device.rs b/crates/bevy_render/src/renderer/render_device.rs index eef8b100cb130..9d88a64d98410 100644 --- a/crates/bevy_render/src/renderer/render_device.rs +++ b/crates/bevy_render/src/renderer/render_device.rs @@ -12,7 +12,7 @@ use crate::render_resource::resource_macros::*; render_resource_wrapper!(ErasedRenderDevice, wgpu::Device); /// This GPU device is responsible for the creation of most rendering and compute resources. -#[derive(Resource, Clone)] +#[derive(Debug, Resource, Clone)] pub struct RenderDevice { device: ErasedRenderDevice, } diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index b8d0685e6f39f..35b94d34db776 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -2,7 +2,7 @@ mod render_layers; pub use render_layers::*; -use bevy_app::{Plugin, PostUpdate}; +use bevy_app::{FrameReady, Plugin}; use bevy_asset::{Assets, Handle}; use bevy_ecs::prelude::*; use bevy_hierarchy::{Children, Parent}; @@ -213,10 +213,10 @@ impl Plugin for VisibilityPlugin { app // We add an AABB component in CalculateBounds, which must be ready on the same frame. - .add_systems(PostUpdate, apply_deferred.in_set(CalculateBoundsFlush)) - .configure_set(PostUpdate, CalculateBoundsFlush.after(CalculateBounds)) + .add_systems(FrameReady, apply_deferred.in_set(CalculateBoundsFlush)) + .configure_set(FrameReady, CalculateBoundsFlush.after(CalculateBounds)) .add_systems( - PostUpdate, + FrameReady, ( calculate_bounds.in_set(CalculateBounds), update_frusta:: diff --git a/crates/bevy_render/src/view/window/screenshot.rs b/crates/bevy_render/src/view/window/screenshot.rs index 440634c274e1d..db5f706f9847b 100644 --- a/crates/bevy_render/src/view/window/screenshot.rs +++ b/crates/bevy_render/src/view/window/screenshot.rs @@ -254,6 +254,7 @@ impl SpecializedRenderPipeline for ScreenshotToScreenPipeline { } } +#[derive(Debug)] pub struct ScreenshotPreparedState { pub texture: Texture, pub buffer: Buffer, diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index 704d54d860452..6db2890abece7 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -45,7 +45,7 @@ impl Plugin for TimePlugin { .register_type::