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
impl Grid
Sourcepub fn new(
device: &dyn Device,
frames: usize,
target_format: Format,
depth_format: Format,
) -> Result<Self, HalError>
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.
Sourcepub const fn set_style(&mut self, style: GridStyle)
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.
Sourcepub fn add_pass<'a>(
&'a self,
graph: &mut RenderGraph<'a>,
frame: usize,
target: ImageId,
depth: ImageId,
view_proj: Mat4,
inv_view_proj: Mat4,
)
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.