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 {
    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;
}
Index
height: number

Source depth height the pyramid is built for (resize).

mipCount: number

Number of mip levels in the current pyramid.

source: Texture2D | null

The depth texture the last build read, null before the first one.

texture: Texture2D

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.

width: number

Source depth width the pyramid is built for (resize).

  • Re-derive the pyramid from depthTexture (a texture_depth_2d of the pyramid's source 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 for a new source 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