API

Interface DepthPyramid

A rebuildable hierarchical depth pyramid. Create with createDepthPyramid; drive its per-frame build with createDepthPyramidTask (in-frame) or by calling build() yourself.

interface DepthPyramid {
    mipCount: number;
    texture: Texture2D;
    build(depthTexture: Texture2D, encoder?: GPUCommandEncoder): void;
    dispose(): void;
    resize(width: number, height: number): void;
}
Index
mipCount: number

Number of mip levels in the current pyramid.

texture: Texture2D

r32float, full mip chain, nearest sampler. 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.

  • Re-derive the pyramid from depthTexture (a texture_depth_2d of matching mip-0 size). Pass the frame encoder to 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

  • Reallocate the pyramid texture at a new mip-0 size (call when the source depth target resizes). No-op if unchanged. Mint a new texture wrapper 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