Skip to main content

Module render_attachments

Module render_attachments 

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

FrameTextures
Textures a frame loop allocates for offscreen rendering.
RenderAttachments
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_format picks for device.
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 a RenderAttachments.
default_depth_stencil_format
The depth-stencil format a render target should use on device: Depth32FloatStencil8 when the device supports it, otherwise the universally-available Depth24PlusStencil8.
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.