Interface DepthPyramid
height: number;
mipCount: number;
source: Texture2D | null;
texture: Texture2D;
width: number;
build(depthTexture: Texture2D, encoder?: GPUCommandEncoder): void;
dispose(): void;
resize(width: number, height: number): void;
}
Properties
Readonlyheight
Source depth height the pyramid is built for (resize).
Readonlymip Count
Number of mip levels in the current pyramid.
Readonlysource
The depth texture the last build read, null before the first one.
Readonlytexture
r32float, full mip chain at the source size, nearest sampler. nearestFarthest: rg32float from half the
source size (level k reduces 2^(k+1)×2^(k+1) source texels; source is the full-resolution level). Bind to a
material; read textureLoad(tex, coord, mip).
A resize() replaces this wrapper (new identity) — re-read it and re-bind after a resize.
Readonlywidth
Source depth width the pyramid is built for (resize).
Methods
build
-
Re-derive the pyramid from
depthTexture(atexture_depth_2dof the pyramid's source size). Pass the frameencoderto record the COPY/REDUCE passes in-frame (e.g. after a depth prepass, before the consumer that samples the pyramid); omit it to run on a private encoder + submit immediately.Parameters
- depthTexture: Texture2D
Optionalencoder: GPUCommandEncoder
Returns void
dispose
-
Release the pyramid's base texture ref (frees the GPU texture once no consumer holds it).
Returns void
resize
-
Reallocate the pyramid texture for a new source size (call when the source depth target resizes). No-op if unchanged. Mint a new
texturewrapper on a real change; safe to call any time (does not destroy the old texture while a consumer still references it).Parameters
- width: number
- height: number
Returns void
A rebuildable hierarchical depth pyramid. Create with
createDepthPyramid; drive its per-frame build withcreateDepthPyramidTask(in-frame) or by callingbuild()yourself.