Skip to content

Commit

Permalink
fix(mmserver): add overall encode timing to tracy
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed Jan 26, 2025
1 parent 4a9af4f commit 334d5b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
19 changes: 15 additions & 4 deletions mm-server/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ impl EncoderInner {
}
};

#[cfg(feature = "tracy")]
{
frame.tracy_frame = Some(tracy_client::non_continuous_frame!("encode"));
}

begin_command_buffer(&self.vk.device, frame.encode_cb)?;

// Acquire the image from the graphics queue.
Expand Down Expand Up @@ -700,6 +705,10 @@ struct EncoderOutputFrame {
timeline: VkTimelineSemaphore,
tp_encoded: VkTimelinePoint,
tp_copied: VkTimelinePoint,

#[cfg(feature = "tracy")]
tracy_frame: Option<tracy_client::Frame>,

vk: Arc<VkContext>,
}

Expand Down Expand Up @@ -784,6 +793,9 @@ impl EncoderOutputFrame {
tp_copied: timeline.new_point(0),
timeline,

#[cfg(feature = "tracy")]
tracy_frame: None,

vk,
})
}
Expand Down Expand Up @@ -839,7 +851,7 @@ fn writer_thread(
let mut capture_ts = time::Instant::now();

for frame in input {
let frame = match frame {
let mut frame = match frame {
WriterInput::InsertBytes(header) => {
sink.write_frame(time::Instant::now(), header, 0);
continue;
Expand All @@ -855,9 +867,8 @@ fn writer_thread(
frame.tp_encoded.wait()?;
}

// Wake the compositor, so it can release buffers and send presentation
// feedback.
// compositor.wake()?;
#[cfg(feature = "tracy")]
frame.tracy_frame.take();

// Get the buffer offsets for the encoded data.
let mut results = [QueryResults::default()];
Expand Down
2 changes: 1 addition & 1 deletion mm-server/src/server/handlers/attachment/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl AttachmentStats {

#[cfg(feature = "tracy")]
if _seq % 10 == 0 {
tracy_client::plot!("video bitrate (KB/s)", avg);
tracy_client::plot!("video bitrate (mbps)", avg);
}
}
}
3 changes: 2 additions & 1 deletion mm-server/src/session/reactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ impl Reactor {
}

fn frame(&mut self) -> anyhow::Result<()> {
let _tracy_frame = tracy_client::non_continuous_frame!("composite");
#[cfg(feature = "tracy")]
tracy_client::frame_mark();

if self.session_handle.num_attachments() == 0 {
return Ok(());
Expand Down

0 comments on commit 334d5b3

Please sign in to comment.