pub struct DepthPyramid { /* private fields */ }Expand description
A depth pyramid on the CPU: levels 1..=levels_for(extent) of a reversed-Z
depth image, each reduced from the level above exactly as hiz.slang does.
Implementations§
Source§impl DepthPyramid
impl DepthPyramid
Sourcepub fn reduce(depth: &[f32], extent: (u32, u32), reduction: Reduction) -> Self
pub fn reduce(depth: &[f32], extent: (u32, u32), reduction: Reduction) -> Self
Reduces depth — extent.0 * extent.1 texels, row-major, top row first
— into every level levels_for allows.
hiz.slang’s reduction, tap for tap: the destination texel’s 2×2
block of the level above, clamped to its extent, and a third tap along an
odd axis so the last texel covers the row or column the halving floored
past.
§Panics
If depth is not extent.0 * extent.1 long.
Sourcepub fn from_levels(extent: (u32, u32), levels: Vec<Vec<f32>>) -> Self
pub fn from_levels(extent: (u32, u32), levels: Vec<Vec<f32>>) -> Self
A pyramid out of levels already reduced — a GPU pyramid read back —
over a prepass of extent, level 1 first.
§Panics
If levels is not levels_for(extent) long, or a level is not its
level_extent’s texel count.
Sourcepub fn reduce_level(
source: &[f32],
extent: (u32, u32),
reduction: Reduction,
) -> Vec<f32>
pub fn reduce_level( source: &[f32], extent: (u32, u32), reduction: Reduction, ) -> Vec<f32>
Reduces source — one level of (width, height) texels — into the level
below it, by reduce’s taps: what a test holds each GPU
level against the one above it with.
Sourcepub const fn extent(&self) -> (u32, u32)
pub const fn extent(&self) -> (u32, u32)
The prepass extent this pyramid was reduced from — its level 0.
Sourcepub fn levels(&self) -> u32
pub fn levels(&self) -> u32
How many levels it has, which is levels_for of its extent.