Skip to main content

Module pass_timing

Module pass_timing 

Source
Expand description

Per-pass GPU timing slot arithmetic, shared by every backend that times passes with a timestamp query pool.

The pool holds one block of SLOTS_PER_FRAME u64 slots per in-flight frame. Within a block the whole-frame timer owns slots [0, 1] and one (start, end) pair per PassId follows, so pass occupies 2 + 2 * pass and 3 + 2 * pass. Keeping the whole-frame pair at the front lets a whole-frame readback stay the first pair of the block, independent of how many passes exist.

This is index arithmetic with no device type in it, so it lives here rather than in a backend and its layout tests run on every platform’s CI. The DirectX and Vulkan backends re-export it under their own pass_timing.

Constants§

FRAME_BLOCK_BYTES
Bytes one frame’s block occupies in a readback buffer of u64 timestamps.
SLOTS_PER_FRAME
Per-frame block: [whole_frame_start, whole_frame_end, pass0_start, pass0_end, ..., pass(PASS_COUNT-1)_end].

Functions§

frame_block_base
First slot of frame’s block. Also the start of the range a per-frame resolve should walk, paired with SLOTS_PER_FRAME as the count.
frame_readback_byte_offset
Byte offset into the readback buffer where frame’s block begins.
pass_pair
(start, end) slots for pass within frame’s block.
whole_frame_pair
(start, end) slots for frame’s whole-frame pair.