add frame timing probe to capture handler

This commit is contained in:
2026-09-21 00:27:28 +03:00
parent d3418c86df
commit 1affbc63ff
+13
View File
@@ -76,6 +76,9 @@ pub struct CaptureHandler {
/// D3D11 device/context from the frame). Recreated on resize. /// D3D11 device/context from the frame). Recreated on resize.
pipeline: Option<TonemapPipeline>, pipeline: Option<TonemapPipeline>,
frame_count: Arc<std::sync::atomic::AtomicU64>, frame_count: Arc<std::sync::atomic::AtomicU64>,
/// TEMP DIAG: log per-frame timing for the first 10 frames.
timing_n: u32,
timing_start: Option<std::time::Instant>,
} }
/// Persistent D3D11 state for the HDR->SDR tonemap pass. Owns the render /// Persistent D3D11 state for the HDR->SDR tonemap pass. Owns the render
@@ -462,6 +465,8 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
height: setup.height, height: setup.height,
pipeline: None, pipeline: None,
frame_count: setup.frame_counter.clone(), frame_count: setup.frame_counter.clone(),
timing_n: 0,
timing_start: None,
}) })
} }
@@ -470,6 +475,7 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
frame: &mut Frame<'_>, frame: &mut Frame<'_>,
_capture_control: InternalCaptureControl, _capture_control: InternalCaptureControl,
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
let start = std::time::Instant::now();
let Some(stdin) = self.stdin.as_mut() else { let Some(stdin) = self.stdin.as_mut() else {
return Ok(()); return Ok(());
}; };
@@ -486,6 +492,13 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
let pipeline = self.pipeline.as_mut().expect("just initialized"); let pipeline = self.pipeline.as_mut().expect("just initialized");
pipeline.process(device, context, src, stdin)?; pipeline.process(device, context, src, stdin)?;
// TEMP DIAG: per-frame timing for the first 10 frames.
if self.timing_n < 10 {
let elapsed = start.elapsed().as_millis();
tracing::warn!("DIAG-TIMING frame {}: {}ms", self.timing_n, elapsed);
self.timing_n += 1;
}
self.frame_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed); self.frame_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
Ok(()) Ok(())
} }