Skip to main content

Grid

Struct Grid 

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

Everything the grid pass owns.

Built once by Grid::new and released by Grid::destroy, which is the shape every other resource group in this crate has — see crate::ui_pass::UiRenderer.

Implementations§

Source§

impl Grid

Source

pub fn new( device: &dyn Device, frames: usize, target_format: Format, depth_format: Format, ) -> Result<Self, HalError>

Builds the pipeline and the uniform ring.

target_format is the colour attachment the grid blends over and depth_format the depth attachment it is tested against; both are pipeline state, so a caller that renders into a different pair needs a different Grid.

§Errors

HalError from any seam call. Everything created before the failure is released, so a failed build leaks nothing.

Source

pub const fn style(&self) -> &GridStyle

How the grid is drawn.

Source

pub const fn set_style(&mut self, style: GridStyle)

Replaces Grid::style. Takes effect on the next Grid::add_pass, which is what writes the block.

Source

pub fn add_pass<'a>( &'a self, graph: &mut RenderGraph<'a>, frame: usize, target: ImageId, depth: ImageId, view_proj: Mat4, inv_view_proj: Mat4, )

Adds the grid pass to graph, blending over target and tested against depth.

depth must be the depth the scene was drawn into and must still hold it — the pass attaches it read-only, so it is neither cleared nor written and a later pass sees exactly what the scene left. target is loaded rather than cleared for the same reason: the grid blends over what is already there.

inv_view_proj is the camera’s inverse view-projection, which is the camera fact the fragment stage builds its ray from: it unprojects two clip-space points per pixel to get that pixel’s view ray. view_proj is the ordinary one, and it travels in the block beside it because the fragment stage has to project its plane hit back to the SV_Depth it is tested at — and no shader can invert a matrix.

Both are taken rather than one derived from the other. Every caller is drawing a frame it already has a view-projection for, and a Mat4::inverse per frame to recover a matrix the caller was holding is arithmetic for nothing.

§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 Grid

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Grid

§

impl Freeze for Grid

§

impl Move for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnsafeUnpin for Grid

§

impl UnwindSafe for Grid

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.