Expand description
Per-pass GPU timing on Vulkan via TIMESTAMP queries. The query pool holds one
per-frame block of SLOTS_PER_FRAME slots; the whole-frame timer lives in
slots [0, 1] of each block and one (start, end) pair per PassId follows
(start at slot 2 + 2i, end at slot 3 + 2i). Mirrors directx/pass_timing.rs.
The start buffer resets the whole block and writes the whole-frame start; each
per-pass command buffer writes its own (start, end) pair around its encode;
the end buffer writes the whole-frame end. The CPU reads the previous trip’s
block at the top of draw_frame (after the matching fence wait gates the GPU
writes) and publishes the per-pass microseconds into RenderStats.pass_times_us.
Vulkan note. Unlike D3D12 (which can pre-write every slot so a pass that did
not run still reads a value), Vulkan forbids writing a timestamp to a query
that is already written without an intervening reset. So a pass absent from
this frame’s graph leaves its (reset-but-unwritten) slots unavailable; the
readback uses WITH_AVAILABILITY and reports 0 for any slot whose pair is not
both available. The shared StatHud.passes_text then filters the zero slots.
Layout reasoning. Keeping the whole-frame pair at the front of each block lets
the existing gpu_frame_us readback stay the first pair of the frame’s block;
only the per-frame stride changes (from 2 to SLOTS_PER_FRAME).
This is GPU-free slot-index arithmetic (no ash/vk types), so it lives in
concinnity-render and its layout tests count toward coverage; the Vulkan
backend re-exports it under crate::vulkan::pass_timing.
Constants§
- SLOTS_
PER_ FRAME - Per-frame block: [whole_frame_start, whole_frame_end, pass0_start, pass0_end, …, pass(PASS_COUNT-1)_start, pass(PASS_COUNT-1)_end]. 2 * (PASS_COUNT + 1) u64 query slots.
Functions§
- frame_
block_ base - First query slot of frame
frame’s block. - pass_
pair - (start, end) query slots for
passwithinframe’s block. - whole_
frame_ pair - (start, end) query slots for the whole-frame pair of
frame. Matches the legacy layout (whole-frame at the first pair of each block).