Skip to content

Commit b3c8346

Browse files
authored
Fix and improve tracy rendering spans (#18588)
* `submit_graph_commands` was incorrectly timing the command buffer generation tasks as well, and not only the queue submission. Moved the span to fix that. * Added a new `command_buffer_generation_tasks` span as a parent for all the individual command buffer generation tasks that don't run as part of the Core3d span. ![image](https://github.com/user-attachments/assets/5a20c2f5-f1df-4c03-afbb-4865327aea33)
1 parent f4a5e8b commit b3c8346

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/bevy_render/src/renderer/graph_runner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ impl RenderGraphRunner {
8787
finalizer(render_context.command_encoder());
8888

8989
let (render_device, mut diagnostics_recorder) = {
90+
let (commands, render_device, diagnostics_recorder) = render_context.finish();
91+
9092
#[cfg(feature = "trace")]
9193
let _span = info_span!("submit_graph_commands").entered();
92-
93-
let (commands, render_device, diagnostics_recorder) = render_context.finish();
9494
queue.submit(commands);
9595

9696
(render_device, diagnostics_recorder)

crates/bevy_render/src/renderer/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ impl<'w> RenderContext<'w> {
498498

499499
let mut command_buffers = Vec::with_capacity(self.command_buffer_queue.len());
500500

501+
#[cfg(feature = "trace")]
502+
let _command_buffer_generation_tasks_span =
503+
info_span!("command_buffer_generation_tasks").entered();
504+
501505
#[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))]
502506
{
503507
let mut task_based_command_buffers = ComputeTaskPool::get().scope(|task_pool| {
@@ -537,6 +541,9 @@ impl<'w> RenderContext<'w> {
537541
}
538542
}
539543

544+
#[cfg(feature = "trace")]
545+
drop(_command_buffer_generation_tasks_span);
546+
540547
command_buffers.sort_unstable_by_key(|(i, _)| *i);
541548

542549
let mut command_buffers = command_buffers

0 commit comments

Comments
 (0)