Skip to main content

LightGrid

Struct LightGrid 

Source
pub struct LightGrid { /* private fields */ }
Expand description

The light list, the froxel grid, and the compute pass between them.

Implementations§

Source§

impl LightGrid

Source

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.

Source

pub fn new( device: &dyn Device, desc: &LightGridDesc<'_>, ) -> Result<Self, HalError>

Builds every buffer, the bind groups and the clustering pipeline.

§Errors

HalError if a resource could not be created, or if the descriptor asks for a ring shorter than the statistics ring it was handed.

Source

pub const fn capacity(&self) -> u32

Rows the light list holds.

Source

pub const fn froxel_capacity(&self) -> u32

Froxels the grid holds.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn destroy(self, device: &dyn Device)

Releases everything, in dependency order. The device must be idle.

Trait Implementations§

Source§

impl Debug for LightGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.