/** * Base class of a simple GPU profiler. * * @ignore */ export class GpuProfiler { /** * Profiling slots allocated for the current frame, storing the names of the slots. * * @type {string[]} * @ignore */ frameAllocations: string[]; /** * Map of past frame allocations, indexed by renderVersion * * @type {Map} * @ignore */ pastFrameAllocations: Map; /** * True if enabled in the current frame. * * @private */ private _enabled; /** * The enable request for the next frame. * * @private */ private _enableRequest; /** * The time it took to render the last frame on GPU, or 0 if the profiler is not enabled. * * @private */ private _frameTime; /** * Whether a valid frame timing has arrived since profiling was enabled or reset. * * @private */ private _frameTimeValid; /** * Per-pass timing data, with accumulated timings for passes with the same name. * * @type {Map} * @private */ private _passTimings; /** * The timed passes of the frame the latest timings describe, in the order they ran: their * names, as {@link passTimings} names them, and their timings, passes sharing a name kept * apart. Rewritten in place as timings arrive, so a frame makes no garbage. * * @type {{ names: string[], times: number[] }} * @private */ private _passTimingsInOrder; /** * The {@link GraphicsDevice#renderVersion} of the frame the latest timings describe, or -1. * * @private */ private _renderVersion; /** * Cache for parsed pass names to avoid repeated string operations. * * @type {Map} * @private */ private _nameCache; /** * The maximum number of slots that can be allocated during the frame. */ maxCount: number; loseContext(): void; /** * Invalidate timings and discard pending reports so asynchronous results from an earlier * profiling session cannot become the latest sample after a reset. * * @ignore */ invalidateTimings(): void; /** * True to enable the profiler. * * @type {boolean} */ set enabled(value: boolean); get enabled(): boolean; /** * The latest valid GPU frame duration, or undefined when no timing is available. * * @type {number|undefined} * @ignore */ get frameTime(): number | undefined; /** * Get the per-pass timing data. * * @type {Map} * @ignore */ get passTimings(): Map; /** * The timed passes of the frame {@link renderVersion} names, in the order they ran: the name * of each, as {@link passTimings} names it, and its GPU time in milliseconds. Unlike * {@link passTimings}, passes sharing a name, such as the steps of a blur, stay apart. Both * lists are empty while no timings have arrived, and are reused as timings arrive. * * @type {{ names: readonly string[], times: readonly number[] }} * @ignore */ get passTimingsInOrder(): { names: readonly string[]; times: readonly number[]; }; /** * The {@link GraphicsDevice#renderVersion} of the frame that {@link frameTime} and * {@link passTimings} describe, or -1 when no timings have arrived. Timings resolve * asynchronously, so this is usually a few frames behind the device, and not every frame * reports. * * @type {number} * @ignore */ get renderVersion(): number; processEnableRequest(): void; request(renderVersion: any): void; /** * Parse a render pass name to a simplified form for stats. * Uses a cache to avoid repeated string operations. * * @param {string} name - The original pass name (e.g., "RenderPassCompose"). * @returns {string} The parsed name (e.g., "compose"). * @private */ private _parsePassName; report(renderVersion: any, timings: any, frameTime: any): void; /** * Allocate a slot for GPU timing during the frame. This slot is valid only for the current * frame. This allows multiple timers to be used during the frame, each with a unique name. * * @param {string} name - The name of the slot. * @returns {number} The assigned slot index, or -1 if the slot count exceeds the maximum number * of slots. * * @ignore */ getSlot(name: string): number; /** * Number of slots allocated during the frame. * * @ignore */ get slotCount(): number; }