Skip to content

UWAL / GPUTiming

Classes

GPUTiming

Utility class levering the "timestamp-query" feature when available to monitor GPU timings. Feel free to consult WebGPU Timing Performance lesson for its usefulness and common pitfalls, and this example for the basic usage.

Constructors

Constructor
ts
new GPUTiming(stage): GPUTiming;
Parameters
ParameterTypeDescription
stageRenderStage | ComputeStageComputation or Renderer instance used for monitoring
Returns

GPUTiming

Throws

ERROR.TIMESTAMP_QUERY_NOT_FOUND when "timestamp-query" feature is not supported.

Methods

ResolveAndSubmit()
ts
ResolveAndSubmit(): Promise<number>;

Copy timestamp results to a GPUBuffer and measure the duration between the current and the previous pass.
NOTE: Must be called after Computation.Compute or Renderer.Render (with the submit flag set to false).

Returns

Promise<number>

GPU duration of the current pass; NaN if the measurement failed for configuration reasons.

Destroy()
ts
Destroy(): void;

Destroy the query set, GPUBuffers and reset internal state.

Returns

void

Accessors

QuerySet
Get Signature
ts
get QuerySet(): Promise<GPUQuerySet | undefined>;
Throws

ERROR.TIMESTAMP_QUERY_NOT_FOUND when "timestamp-query" feature is not supported.

Returns

Promise<GPUQuerySet | undefined>

A query set to use in Computation|Renderer.CreateTimestampWrites method.

Enabled
Get Signature
ts
get Enabled(): boolean;
Returns

boolean

true if "timestamp-query" feature is available after initialization, false otherwise.

Released under the MIT License.