drop the frame timing probe, keep click highlights in frame

This commit is contained in:
2026-09-21 00:32:08 +03:00
parent 1affbc63ff
commit 95d168d5d8
4 changed files with 90 additions and 54 deletions
+6 -19
View File
@@ -76,9 +76,6 @@ pub struct CaptureHandler {
/// D3D11 device/context from the frame). Recreated on resize.
pipeline: Option<TonemapPipeline>,
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
@@ -111,7 +108,7 @@ impl TonemapPipeline {
// Validated against the VS bytecode by CreateInputLayout.
let input_elements = [
D3D11_INPUT_ELEMENT_DESC {
SemanticName: windows::core::PCSTR(b"POSITION\0".as_ptr()),
SemanticName: windows::core::PCSTR(c"POSITION".as_ptr().cast()),
SemanticIndex: 0,
Format: windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32_FLOAT,
InputSlot: 0,
@@ -120,7 +117,7 @@ impl TonemapPipeline {
InstanceDataStepRate: 0,
},
D3D11_INPUT_ELEMENT_DESC {
SemanticName: windows::core::PCSTR(b"TEXCOORD\0".as_ptr()),
SemanticName: windows::core::PCSTR(c"TEXCOORD".as_ptr().cast()),
SemanticIndex: 0,
Format: windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32_FLOAT,
InputSlot: 0,
@@ -167,7 +164,7 @@ impl TonemapPipeline {
}
let vertex_buffer = vertex_buffer.ok_or_else(|| anyhow!("CreateBuffer vb returned null"))?;
// Pixel shader: ACES tonemap + bt709 OETF.
// Pixel shader: Hable tonemap + bt709 OETF.
let mut ps = None;
unsafe {
device.CreatePixelShader(TONEMAP_PS, None, Some(&mut ps))?;
@@ -235,7 +232,7 @@ impl TonemapPipeline {
}
let render_target = render_target.ok_or_else(|| anyhow!("CreateTexture2D rt returned null"))?;
let rtv_desc = D3D11_RENDER_TARGET_VIEW_DESC {
let view_desc = D3D11_RENDER_TARGET_VIEW_DESC {
Format: DXGI_FORMAT_B8G8R8A8_UNORM,
ViewDimension: D3D11_RTV_DIMENSION_TEXTURE2D,
Anonymous: windows::Win32::Graphics::Direct3D11::D3D11_RENDER_TARGET_VIEW_DESC_0 {
@@ -244,7 +241,7 @@ impl TonemapPipeline {
};
let mut rtv = None;
unsafe {
device.CreateRenderTargetView(&render_target, Some(&rtv_desc), Some(&mut rtv))?;
device.CreateRenderTargetView(&render_target, Some(&view_desc), Some(&mut rtv))?;
}
let rtv = rtv.ok_or_else(|| anyhow!("CreateRenderTargetView returned null"))?;
@@ -367,7 +364,7 @@ impl TonemapPipeline {
(mapped.RowPitch as usize) * (self.height as usize),
);
// RowPitch may exceed width*4 (alignment); copy row by row.
if mapped.RowPitch as u32 == row_bytes {
if mapped.RowPitch == row_bytes {
out.write_all(&src_slice[..(row_bytes as usize) * (self.height as usize)])
.map_err(|e| anyhow!("writing tonemapped frame: {e}"))?;
} else {
@@ -465,8 +462,6 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
height: setup.height,
pipeline: None,
frame_count: setup.frame_counter.clone(),
timing_n: 0,
timing_start: None,
})
}
@@ -475,7 +470,6 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
frame: &mut Frame<'_>,
_capture_control: InternalCaptureControl,
) -> Result<(), Self::Error> {
let start = std::time::Instant::now();
let Some(stdin) = self.stdin.as_mut() else {
return Ok(());
};
@@ -492,13 +486,6 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
let pipeline = self.pipeline.as_mut().expect("just initialized");
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);
Ok(())
}