IFClite TypeScript API
    Preparing search index...

    Class GpuFrameTimingRecorder

    Records GPU timestamp queries for the passes of one frame and resolves them into PassTimingSample[] (nanosecond pairs; see frame-timing.ts for aggregation). One fixed query set and two buffers are reused only after the previous map settles. beginFrame() returns false while they are leased. Destroying cancels pending mapping; callers must handle readback rejection.

    Index
    • False while a prior frame owns the buffers; callers skip sampling that frame.

      Returns boolean

    • Returns the timestampWrites object for the next pass, labelled label. Pass it straight into beginRenderPass's descriptor. Returns null once maxPasses passes have been begun this frame — a caller that hits this should raise maxPasses at construction, not retry.

      Parameters

      • label: string

      Returns GPURenderPassTimestampWrites | null

    • Releases the GPU query set and buffers. Call when timing is turned off.

      Returns void

    • Resolves every query written this frame into the readback buffer. Call once, after every pass has been .end()-ed, before queue.submit.

      Parameters

      • encoder: GPUCommandEncoder

      Returns void

    • Maps the readback buffer and returns this frame's PassTimingSample[], or null if endFrame was never called (nothing was recorded, or the caller forgot). Async because mapAsync is: the caller's queue submit must have completed first for the buffer to contain real data — WebGPU enforces this by making mapAsync wait for pending GPU work that touches the buffer.

      Returns Promise<PassTimingSample[] | null>

    • Returns a recorder, or null if the device's adapter did not advertise 'timestamp-query' — callers must treat null as "cannot measure this way" and either fall back to CPU-side timing (decideTimingMode in frame-timing.ts) or skip measurement, never throw.

      Parameters

      • device: GPUDevice
      • OptionalmaxPasses: number

      Returns GpuFrameTimingRecorder | null