import type { GpuContext } from "./types.js"; export interface CreateTimestampQueryOptions { /** Timestamp slots: two per pass timed (begin/end). Defaults to 2. */ count?: number; /** * Readback buffers. One (the default) reads a frame only when the previous * read has landed, skipping the others; three is what it takes to read every * frame with two frames in flight. */ buffering?: number; label?: string; } export interface TimestampQuery extends Disposable { readonly querySet: GPUQuerySet; /** Number of timestamp slots (2 = begin/end of pass). */ readonly count: number; /** Pass to a render/compute pass descriptor to time the whole pass. */ readonly timestampWrites: GPURenderPassTimestampWrites; /** * Encode resolution of the first `count` queries into a free readback buffer, * and arm it for the next {@link TimestampQuery.read}. Call once per frame, * after the passes being timed. False when every buffer is still mapping — * that frame goes unread rather than stalling on one. Resolving twice without * reading in between overwrites the armed buffer. */ resolve(encoder: GPUCommandEncoder, count?: number): boolean; /** * Read the armed buffer's timestamps, in nanoseconds. Null when nothing is * armed or the device went away, so it can be polled every frame. Only call * after the encoder passed to `resolve()` has actually been submitted (eg. * after `endFrame()`, or fire-and-forget from inside a `frame()` callback) — * awaiting it before that submit stalls the very submit it depends on and * silently returns stale data instead of the intended timestamps. */ read(): Promise; /** * Release the query set and readback buffers. Identical to * `[Symbol.dispose]`, for call sites without `using`. Safe to call with a * read in flight: the GPU objects go once it settles. */ dispose(): void; } /** * GPU timestamp measurement. Requires creating the context with * `requiredFeatures: ["timestamp-query"]`. * * One query set plus a ring of readback buffers; `debug(ctx, { timing: true })` * builds on the same object to time every pass automatically. * * ```js * const query = gpu.createTimestampQuery(ctx); * // pass descriptor: { ..., timestampWrites: query.timestampWrites } * query.resolve(encoder); * const timestamps = await query.read(); * if (timestamps) * console.log(`${Number(timestamps[1] - timestamps[0]) / 1e6} ms`); * ``` */ export declare function createTimestampQuery(ctx: GpuContext, options?: CreateTimestampQueryOptions): TimestampQuery; //# sourceMappingURL=query.d.ts.map