Renderer · class
GpuTimer
Explained in Hello world.
class GpuTimer implements FrameTimerimport { GpuTimer } from '@driftengine/core';Constructor
new
constructor(gl: WebGL2RenderingContext, sampleEvery?: number)| Parameter | Type | Description |
|---|---|---|
gl | WebGL2RenderingContext | |
sampleEvery? | number |
Properties
| Name | Type | Description |
|---|---|---|
availablereadonly | boolean | False where the extension is missing or disabled, which is a normal state. |
disjointDrops | number | Samples the driver said were untrustworthy. Reported, never silently dropped. |
Accessors
| Name | Type | Description |
|---|---|---|
samplingget | boolean | Whether beginFrame said yes for the frame being drawn. |
Methods
beginFrame
beginFrame(): booleanWhether this frame is measured. Call once per frame, before any begin.
More
begin and end do nothing on an unmeasured frame, so the skipped frames really
are free rather than merely cheap.
endFrame
endFrame(): voidClose the frame and queue it for reading.
More
Explicit rather than counting to three, because the shadow pass runs several
times a frame — static, the depth peel, then dynamic — and the reflection pass
may not run at all when water is off. A frame is over when the caller says so,
and poll sums the brackets per slot, so three shadow passes are one shadow
number rather than three partial ones.
begin
begin(slot: GpuSlot): voidOpen a bracket. Never two at once — TIME_ELAPSED_EXT cannot nest, and the
partition is what guarantees end runs before the next begin.
| Parameter | Type | Description |
|---|---|---|
slot | GpuSlot |
end
end(): voidpoll
poll(): GpuSample | nullThe oldest finished sample, or null. Never blocks and never waits for a result: a diagnostic that stalls the pipeline to measure it is measuring itself.
lastFrameMs
lastFrameMs(): number | nullThe whole of the last resolved frame, in milliseconds, or null where nothing measured.
More
The three brackets are summed because they partition the frame rather than overlapping:
shadows and reflection are the passes drawn before the scene, rest is everything
after. A caller wanting the breakdown reads poll, which is what the frame meter does.
dispose
dispose(): void