Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Add trace_tracy feature for Tracy profiling #2832

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ bevy_wgpu = ["bevy_internal/bevy_wgpu"]
bevy_winit = ["bevy_internal/bevy_winit"]

trace_chrome = ["bevy_internal/trace_chrome"]
trace_tracy = ["bevy_internal/trace_tracy"]
trace = ["bevy_internal/trace"]
wgpu_trace = ["bevy_internal/wgpu_trace"]

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ categories = ["game-engines", "graphics", "gui", "rendering"]
wgpu_trace = ["bevy_wgpu/trace"]
trace = [ "bevy_app/trace", "bevy_ecs/trace" ]
trace_chrome = [ "bevy_log/tracing-chrome" ]
trace_tracy = [ "bevy_log/tracing-tracy" ]

# Image format support for texture loading (PNG and HDR are enabled by default)
hdr = ["bevy_render/hdr"]
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_utils = { path = "../bevy_utils", version = "0.5.0" }

tracing-subscriber = {version = "0.2.15", features = ["registry"]}
tracing-chrome = { version = "0.3.0", optional = true }
tracing-subscriber = {version = "0.2.22", features = ["registry"]}
tracing-chrome = { version = "0.3.1", optional = true }
tracing-tracy = { version = "0.7.0", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
android_log-sys = "0.2.0"
Expand Down
12 changes: 10 additions & 2 deletions crates/bevy_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Plugin for LogPlugin {
{
let fmt_layer = tracing_subscriber::fmt::Layer::default();
let subscriber = subscriber.with(fmt_layer);
#[cfg(feature = "tracing-chrome")]
#[cfg(all(feature = "tracing-chrome", not(feature = "tracing-tracy")))]
superdump marked this conversation as resolved.
Show resolved Hide resolved
{
let (chrome_layer, guard) = tracing_chrome::ChromeLayerBuilder::new()
.name_fn(Box::new(|event_or_span| match event_or_span {
Expand All @@ -118,7 +118,15 @@ impl Plugin for LogPlugin {
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
}

#[cfg(not(feature = "tracing-chrome"))]
#[cfg(all(feature = "tracing-tracy", not(feature = "tracing-chrome")))]
{
let tracy_layer = tracing_tracy::TracyLayer::new();
let subscriber = subscriber.with(tracy_layer);
bevy_utils::tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
}

#[cfg(all(not(feature = "tracing-chrome"), not(feature = "tracing-tracy")))]
{
bevy_utils::tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
Expand Down