Skip to content

UWAL / GPUTiming

Classes

GPUTiming

Utility class levering the "timestamp-query" feature when available to monitor GPU performance. Check the WebGPU Timing Performance lesson and this example for its usefulness, common pitfalls, and 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 into a GPUBuffer and measure the duration between the current and the previous pass. 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 and internal buffers.

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 the CreateTimestampWrites method.

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

boolean

Whether the "timestamp-query" feature is available after initialization.

Released under the MIT License.