From 1ec718349472c6c33e24e45d183ac88608d0156e Mon Sep 17 00:00:00 2001 From: "Victor \"multun\" Collod" Date: Sun, 16 Aug 2020 02:05:05 -0700 Subject: [PATCH 1/2] profiling: fix build --- crates/bevy_diagnostic/src/lib.rs | 2 +- crates/bevy_diagnostic/src/system_profiler.rs | 2 +- crates/bevy_ecs/Cargo.toml | 3 ++- crates/bevy_ecs/src/schedule/schedule.rs | 6 +++--- crates/bevy_ecs/src/system/profiler.rs | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/bevy_diagnostic/src/lib.rs b/crates/bevy_diagnostic/src/lib.rs index 98f647a37c..c5f9b4c394 100644 --- a/crates/bevy_diagnostic/src/lib.rs +++ b/crates/bevy_diagnostic/src/lib.rs @@ -19,7 +19,7 @@ impl Plugin for DiagnosticsPlugin { #[cfg(feature = "profiler")] { use bevy_ecs::IntoQuerySystem; - app.add_resource::>(Box::new( + app.add_resource::>(Box::new( system_profiler::SystemProfiler::default(), )) .add_system_to_stage( diff --git a/crates/bevy_diagnostic/src/system_profiler.rs b/crates/bevy_diagnostic/src/system_profiler.rs index 7a6577ac93..f10d72a5a1 100644 --- a/crates/bevy_diagnostic/src/system_profiler.rs +++ b/crates/bevy_diagnostic/src/system_profiler.rs @@ -1,5 +1,5 @@ use crate::{Diagnostic, DiagnosticId, Diagnostics}; -use bevy_ecs::{profiler::Profiler, Res, ResMut}; +use bevy_ecs::{Profiler, Res, ResMut}; use std::{ borrow::Cow, collections::HashMap, diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index 7222f282c6..28de4c835c 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -18,4 +18,5 @@ bevy_hecs = { path = "hecs", features = ["macros", "serialize"], version = "0.1" rand = "0.7.2" rayon = "1.3" crossbeam-channel = "0.4.2" -fixedbitset = "0.3.0" \ No newline at end of file +fixedbitset = "0.3.0" +downcast-rs = "1.1.1" diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 0918240074..77a72237dc 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -131,9 +131,9 @@ impl Schedule { for stage_name in self.stage_order.iter() { if let Some(stage_systems) = self.stages.get_mut(stage_name) { for system in stage_systems.iter_mut() { - #[cfg(feature = "profiler")] - crate::profiler::profiler_start(resources, system.name().clone()); let mut system = system.lock().unwrap(); + #[cfg(feature = "profiler")] + crate::profiler_start(resources, system.name().clone()); system.update_archetype_access(world); match system.thread_local_execution() { ThreadLocalExecution::NextFlush => system.run(world, resources), @@ -144,7 +144,7 @@ impl Schedule { } } #[cfg(feature = "profiler")] - crate::profiler::profiler_stop(resources, system.name().clone()); + crate::profiler_stop(resources, system.name().clone()); } // "flush" diff --git a/crates/bevy_ecs/src/system/profiler.rs b/crates/bevy_ecs/src/system/profiler.rs index 553dd6f8f2..04914bde37 100644 --- a/crates/bevy_ecs/src/system/profiler.rs +++ b/crates/bevy_ecs/src/system/profiler.rs @@ -11,13 +11,13 @@ pub trait Profiler: Downcast + Send + Sync + 'static { } pub fn profiler_start(resources: &Resources, scope: Cow<'static, str>) { - if let Ok(profiler) = resources.get::>() { + if let Some(profiler) = resources.get::>() { profiler.start(scope); } } pub fn profiler_stop(resources: &Resources, scope: Cow<'static, str>) { - if let Ok(profiler) = resources.get::>() { + if let Some(profiler) = resources.get::>() { profiler.stop(scope); } } From ece54e963ea0d800057e031846e7afd871d69a86 Mon Sep 17 00:00:00 2001 From: "Victor \"multun\" Collod" Date: Sun, 16 Aug 2020 04:17:19 -0700 Subject: [PATCH 2/2] diagnostics: add missing feature dependency --- crates/bevy_diagnostic/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml index af8279c3bb..4d704dabe8 100644 --- a/crates/bevy_diagnostic/Cargo.toml +++ b/crates/bevy_diagnostic/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" keywords = ["bevy"] [features] -profiler = [] +profiler = ["bevy_ecs/profiler"] [dependencies] # bevy