Renderer · class

GpuDrivenPass

Explained in Hello world.

class GpuDrivenPass implements PassDefinition
import { GpuDrivenPass } from '@driftengine/core';

Constructor

new

constructor(scene: StreamingScene, materials: readonly GpuDrivenMaterial[], shadow?: GpuDrivenShadowOptions)
ParameterTypeDescription
sceneStreamingScene
materialsreadonly GpuDrivenMaterial[]
shadow?GpuDrivenShadowOptions

Properties

NameTypeDescription
occlusionbooleanWhether phase two and the blended run test clusters against the depth pyramid — the occlusion cull — and the light's second half against its own. On by default and off only to measure it: the instance cull is the frustum alone and phase one never reads a pyramid, so with this off each view draws every cluster its frustum and cones keep, and the drawn count's difference is the occlusion cull's own share. The pyramids are still built; a frame that measures does not also save their cost.
countDrawnbooleanWhether the pass reads back how many clusters each list drew. Off, it encodes nothing for it and makes no buffer, which is why it is asked for rather than always on: the figure is a demo's readout and a measurement's, and a consumer who reads neither pays nothing.

Accessors

NameTypeDescription
clusterCountgetnumberHow many clusters the scene holds, which every per-cluster dispatch is sized by.
totalMsgetnumber | nullEvery stage added up, which is what the pipeline costs the device.

Methods

setView

setView(view: GpuDrivenView): void

What this frame is looking at. Called before beginFrame, once, by the caller.

ParameterTypeDescription
viewGpuDrivenView
More

Held by reference rather than copied: the caller owns a GpuDrivenView it fills each frame, and copying it here would allocate on a per-frame path for no gain.

resize

resize(width: number, height: number): void

Size the targets. Called on mount and whenever the frame's own size changes.

ParameterTypeDescription
widthnumber
heightnumber
More

Dispose and recreate rather than resize, which is passTarget.ts's rule and is right for the same reason: a resize is not a per-frame path and a mutable target is one more thing to keep consistent.

init

init(device: PassDevice): void
ParameterTypeDescription
devicePassDevice

refusedBecause

refusedBecause(): string | null

Why this pass is drawing nothing, in the words the device used, or null where it is not.

More

Exposed because a black frame that says nothing is the bug this was reported as, twice. A pipeline refusal arrives asynchronously, long after createRenderer has decided the backend can run this at all, so there is no earlier place to throw — and a scene that can read this can tell somebody what happened instead of presenting an empty picture.

shadowExtent

shadowExtent(): number

The radius of the sphere the shadow camera is fitted to. Diagnostic, and a test reads it.

prepare

prepare(ctx: PrepareContext): void
ParameterTypeDescription
ctxPrepareContext

stageTime

stageTime(stage: GpuDrivenStage): number | null

The device milliseconds each stage took, or null where nothing measured them.

ParameterTypeDescription
stageGpuDrivenStage
More

One frame behind, because a timestamp is read back and a readback that blocked would be the measurement changing what it measures. null until a frame has completed a map.

drawnClusters

drawnClusters(list: GpuDrivenList): number | null

How many clusters list drew, one frame behind as the stage times are, or null until a frame has been read — and null always where countDrawn was not asked for.

ParameterTypeDescription
listGpuDrivenList

draw

draw(ctx: PassContext): void
ParameterTypeDescription
ctxPassContext

dispose

dispose(device: PassDevice): void
ParameterTypeDescription
devicePassDevice

Signatures

label = "driftengine.gpu-driven"readonly

readonly label = "driftengine.gpu-driven"