Renderer · class
GpuDrivenPass
Explained in Hello world.
class GpuDrivenPass implements PassDefinitionimport { GpuDrivenPass } from '@driftengine/core';Constructor
new
constructor(scene: StreamingScene, materials: readonly GpuDrivenMaterial[], shadow?: GpuDrivenShadowOptions)| Parameter | Type | Description |
|---|---|---|
scene | StreamingScene | |
materials | readonly GpuDrivenMaterial[] | |
shadow? | GpuDrivenShadowOptions |
Properties
| Name | Type | Description |
|---|---|---|
occlusion | boolean | Whether 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. |
countDrawn | boolean | Whether 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
| Name | Type | Description |
|---|---|---|
clusterCountget | number | How many clusters the scene holds, which every per-cluster dispatch is sized by. |
totalMsget | number | null | Every stage added up, which is what the pipeline costs the device. |
Methods
setView
setView(view: GpuDrivenView): voidWhat this frame is looking at. Called before beginFrame, once, by the caller.
| Parameter | Type | Description |
|---|---|---|
view | GpuDrivenView |
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): voidSize the targets. Called on mount and whenever the frame's own size changes.
| Parameter | Type | Description |
|---|---|---|
width | number | |
height | number |
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| Parameter | Type | Description |
|---|---|---|
device | PassDevice |
refusedBecause
refusedBecause(): string | nullWhy 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(): numberThe radius of the sphere the shadow camera is fitted to. Diagnostic, and a test reads it.
prepare
prepare(ctx: PrepareContext): void| Parameter | Type | Description |
|---|---|---|
ctx | PrepareContext |
stageTime
stageTime(stage: GpuDrivenStage): number | nullThe device milliseconds each stage took, or null where nothing measured them.
| Parameter | Type | Description |
|---|---|---|
stage | GpuDrivenStage |
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 | nullHow 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.
| Parameter | Type | Description |
|---|---|---|
list | GpuDrivenList |
draw
draw(ctx: PassContext): void| Parameter | Type | Description |
|---|---|---|
ctx | PassContext |
dispose
dispose(device: PassDevice): void| Parameter | Type | Description |
|---|---|---|
device | PassDevice |
Signatures
label = "driftengine.gpu-driven"readonly
readonly label = "driftengine.gpu-driven"