bevy_app: add tracing event with tracy.frame_mark (#4320)

Currently `tracy` interprets the entire trace as one frame because the marker for frames isn't being recorded.

~~When an event with `tracy.trace_marker=true` is recorded, `tracing-tracy` will mark the frame as finished:
<aa0b96b2ae/tracing-tracy/src/lib.rs (L240)>~~

~~Unfortunately this leads to~~
```rs
INFO bevy_app:frame: bevy_app::app: finished frame tracy.frame_mark=true
```
~~being printed every frame (we can't use DEBUG because bevy_log sets `max_release_level_info`.~~

Instead of emitting an event that gets logged every frame, we can depend on tracy-client itself and call `finish_continuous_frame!();`
This commit is contained in:
Jakob Hellermann 2022-04-08 22:50:23 +00:00
parent 3756181e23
commit c12ee81822
4 changed files with 14 additions and 1 deletions

View file

@ -12,7 +12,7 @@ categories = ["game-engines", "graphics", "gui", "rendering"]
[features]
trace = [ "bevy_app/trace", "bevy_ecs/trace", "bevy_log/trace", "bevy_render/trace", "bevy_core_pipeline/trace" ]
trace_chrome = [ "bevy_log/tracing-chrome" ]
trace_tracy = [ "bevy_log/tracing-tracy" ]
trace_tracy = ["bevy_render/tracing-tracy", "bevy_log/tracing-tracy" ]
wgpu_trace = ["bevy_render/wgpu_trace"]
debug_asset_server = ["bevy_asset/debug_asset_server"]

View file

@ -159,6 +159,11 @@ impl Plugin for LogPlugin {
let tracy_layer = tracing_tracy::TracyLayer::new();
let fmt_layer = tracing_subscriber::fmt::Layer::default();
#[cfg(feature = "tracing-tracy")]
let fmt_layer = fmt_layer.with_filter(
tracing_subscriber::filter::Targets::new().with_target("tracy", Level::ERROR),
);
let subscriber = subscriber.with(fmt_layer);
#[cfg(feature = "tracing-chrome")]

View file

@ -21,6 +21,7 @@ zlib = ["flate2"]
zstd = ["ruzstd"]
trace = []
tracing-tracy = []
wgpu_trace = ["wgpu/trace"]
ci_limits = []
webgl = ["wgpu/webgl"]

View file

@ -63,6 +63,13 @@ pub fn render_system(world: &mut World) {
if let Some(surface_texture) = texture_view.take_surface_texture() {
surface_texture.present();
}
#[cfg(feature = "tracing-tracy")]
bevy_utils::tracing::event!(
bevy_utils::tracing::Level::INFO,
message = "finished frame",
tracy.frame_mark = true
);
}
}
}