Expand description
Attachment management for the single-pass frame.
A RenderAttachments holds the views a frame renders into — the color
view, the depth-stencil view and an optional multisample view — all of them
caller-owned. The attachment set allocates nothing: textures live wherever
the caller keeps them (often a crate::resources::ResourceGraph), and the
set only borrows the views for the duration of a pass.
Recording is the caller’s: RenderAttachments::begin_pass opens a pass
over the attachments with the caller’s load and store ops, so a depth pass
can keep its results (a shadow map, a preprocessed depth buffer) instead of
discarding them.
Sharing resources more broadly — textures, buffers, bind groups across
scenes — is the job of crate::resources::ResourceGraph, which the
caller keeps separately and registers their own resources in. A
crate::scene::Scene stays the caller’s, assembled per frame from the
handles they hand out.
let attachments = RenderAttachments::from_views(Some(color), Some(depth), None);
let mut encoder = device.create_command_encoder(&Default::default());
let mut pass = attachments.begin_pass(
&mut encoder,
color_clear(),
depth_clear(), // the reverse-z far plane
stencil_clear(),
);
scene.record(&mut pass, None);Re-exports§
use crate::resources::TextureExt;🔒use crate::resources::TextureView;🔒
Structs§
- Frame
Textures - Textures a frame loop allocates for offscreen rendering.
- Render
Attachments - The attachments a frame renders into.
Functions§
- color_
clear - The color load op a frame starts from by default: a clear to black.
- create_
color_ target - Allocate a persistent color texture for a render target.
- create_
depth_ target - Allocate a transient depth-stencil texture in the format
default_depth_stencil_formatpicks fordevice. - create_
msaa_ target - Allocate a transient multisample texture in
format. - create_
render_ target - Allocate a persistent color texture, a transient depth texture, and — when
sample_count > 1— a transient multisample texture, each with a matching view, and assemble them into aRenderAttachments. - default_
depth_ stencil_ format - The depth-stencil format a render target should use on
device:Depth32FloatStencil8when the device supports it, otherwise the universally-availableDepth24PlusStencil8. - depth_
clear - The depth load op of the renderer’s reverse-z convention: a clear to the far plane.
- stencil_
clear - The stencil load op of a frame whose pipelines write no stencil: a clear to zero.