pub struct LightGrid { /* private fields */ }Expand description
The light list, the froxel grid, and the compute pass between them.
Implementations§
Source§impl LightGrid
impl LightGrid
Sourcepub const MAX_PASSES: u32 = 1
pub const MAX_PASSES: u32 = 1
How many passes add_pass adds to a frame.
Exact, for DrawGen::MAX_PASSES’s
reason: the dispatch is one invocation per froxel and a frame always has
froxels, so the pass is never the one that drops out.
Sourcepub const fn froxel_capacity(&self) -> u32
pub const fn froxel_capacity(&self) -> u32
Froxels the grid holds.
Sourcepub fn lights(&self, frame: usize) -> BufferHandle
pub fn lights(&self, frame: usize) -> BufferHandle
frame’s light list, for a caller binding it into a drawing pipeline.
§Panics
If frame is not a slot this was built with.
Sourcepub fn grid(&self, frame: usize) -> BufferHandle
pub fn grid(&self, frame: usize) -> BufferHandle
frame’s froxel grid, likewise — and the buffer a test copies out to see
which lights the pass assigned where.
§Panics
If frame is not a slot this was built with.
Sourcepub fn begin_frame(
&self,
device: &dyn Device,
frame: usize,
rows: &[GpuLight],
grid: Grid,
view: FrameView,
) -> Result<(), HalError>
pub fn begin_frame( &self, device: &dyn Device, frame: usize, rows: &[GpuLight], grid: Grid, view: FrameView, ) -> Result<(), HalError>
Writes frame’s light rows and the parameters the clustering pass reads.
rows are written in order and the sun is expected to be among them;
nothing here treats any row specially, which is the point. Rows past
capacity are refused rather than truncated: a light
silently missing from every froxel is the seam this whole module exists
to prevent, and it would not show up in the overflow counter — that
counts what the froxel budget refused, which is a different number.
Call once per frame, before LightGrid::add_pass, against the frame
slot the instance pool rotated to.
§Errors
HalError if a write failed, or if rows is longer than the list.
§Panics
If frame is not a slot this was built with.
Sourcepub fn add_pass(
&self,
graph: &mut RenderGraph<'_>,
frame: usize,
stats: BufferId,
grid: Grid,
) -> BufferId
pub fn add_pass( &self, graph: &mut RenderGraph<'_>, frame: usize, stats: BufferId, grid: Grid, ) -> BufferId
Adds the clustering pass to graph and returns the grid’s id, for a
caller that has to declare its own read of it.
stats is the id GeneratedDraws::visible_count_id handed back, not a
fresh import: the clearing dispatch zeroes
CLUSTER_OVERFLOW_WORD and this pass adds to it, and the barrier
between the two is the graph’s — computed from the accesses both declare
on one id. Importing the same buffer twice would be two resources the
graph cannot order against each other.
Must therefore be called after
DrawGen::add_passes.
§Panics
If frame is not a slot this was built with.