Automatic System Spans (#2033)

As mentioned in https://github.com/bevyengine/bevy/issues/2025#issuecomment-827867660, systems used to have spans by default.

* add spans by default for every system executed
* create folder if missing for feature `wgpu_trace`
This commit is contained in:
François 2021-04-28 18:41:16 +00:00
parent b1ed28e17e
commit 6f7da027c7
3 changed files with 17 additions and 1 deletions

View File

@ -31,6 +31,10 @@ impl ParallelSystemExecutor for SingleThreadedExecutor {
for system in systems {
if system.should_run() {
#[cfg(feature = "trace")]
let system_span = bevy_utils::tracing::info_span!("system", name = &*system.name());
#[cfg(feature = "trace")]
let _system_guard = system_span.enter();
system.system_mut().run((), world);
}
}

View File

@ -197,7 +197,14 @@ impl ParallelExecutor {
.recv()
.await
.unwrap_or_else(|error| unreachable!(error));
#[cfg(feature = "trace")]
let system_span =
bevy_utils::tracing::info_span!("system", name = &*system.name());
#[cfg(feature = "trace")]
let system_guard = system_span.enter();
unsafe { system.run_unsafe((), world) };
#[cfg(feature = "trace")]
drop(system_guard);
finish_sender
.send(index)
.await

View File

@ -47,7 +47,12 @@ impl WgpuRenderer {
.expect("Unable to find a GPU! Make sure you have installed required drivers!");
#[cfg(feature = "trace")]
let trace_path = Some(std::path::Path::new("wgpu_trace"));
let trace_path = {
let path = std::path::Path::new("wgpu_trace");
// ignore potential error, wgpu will log it
let _ = std::fs::create_dir(path);
Some(path)
};
#[cfg(not(feature = "trace"))]
let trace_path = None;