WebGPU device
CPU width, default 256
CPU height, default 128
Camera.fillShaderParams of that same camera.
x is 1 / far, y is far, z is near, w is 1 for an orthographic
camera and 0 for perspective. Same lifetime as cpuViewProjection.
View-space Z of the published capture, in metres.
Length is width × height. A publish writes a tightly packed
map of cpuWidth × cpuHeight into the front of the array
and leaves texels past that prefix untouched. Row 0 is the bottom of the screen.
Construct and a packed-size rebuild allocate a new array filled with 1e10.
Height of the published map. See cpuWidth.
When false, capture does not pack or start a readback. frameUpdate still publishes a readback already in flight. Defaults to true.
When false, capture does not pack or start a readback. frameUpdate still publishes a readback already in flight. Defaults to true.
True after frameUpdate has published a capture.
False before the first publish, after resize changes the packed
pixel count (maxWidth * maxHeight), and on WebGL after context loss.
A resize that keeps that count leaves a published map ready.
Bumped when frameUpdate publishes a capture, and when resize
changes the packed pixel count. Changing readbackSlots does not bump it.
The tester recopies cpuDepth when this differs from the copy it
last applied and cpuReady is set.
Device that owns the pack and the readback ring.
When false, capture does nothing. Defaults to true.
Cap on the packed map height, in texels. The published footprint is cpuHeight.
In-flight staging slots. Default 5, clamped to at least 2.
Changing it drops downloads that have not landed yet.
Stored HZB level selected by the last capture that took a readback slot.
Stays 0 until then. Level 0 is also a real mip.
Cap on the packed map width, in texels. The published footprint is cpuWidth.
Select a mip of an already-built pyramid, pack it into the CPU map, and start
an async readback. The selected level is written to sourceMip.
Device Z is linearized in the pack.
No-op when this buffer or the pyramid is disabled, when cpuReadback
is off, or without a pyramid texture. Also no-op when no readback slot is
free, when a readback was already submitted this frame, or on a WebGL tick
that readbackPeriod skips.
Call after hzb.update / hzb.updateSceneDepth, once opaque depth is in the pyramid.
Release GPU resources, readback slots, and device event handlers.
Harvest the newest finished readback whose lag has elapsed into cpuDepth, cpuViewProjection, and cpuCameraParams, then bump cpuVersion. Captures older than that one are dropped unread. Call every frame before tests. Does not start a capture.
Frame delta in seconds. Unused by the harvest itself; kept for the frame callback.
Set the packed-map cap. Omitted sizes keep the current cap.
The readback ring holds maxWidth * maxHeight pixels and is rebuilt only
when that count changes. A same-count change keeps in-flight captures and
the published map. A rebuild drops them: cpuReady becomes false,
cpuVersion increments, and cpuDepth is filled with 1e10.
Screen size belongs to the HZB. A window resize does not call this, so in-flight captures and the published map stay.
WebGPU coverage depth buffer.
Reads the HZB mip nearest to maxWidth × maxHeight and packs its screen footprint to float view-space Z. Pixel
icovers screen UV[i / width, (i + 1) / width]and reads the HZB texels under that slice. GPU→CPU download is a ring of readbackSlots staging reads (CoverageGpuReadback). The next pack starts when a slot is free.