Skip to main content

create_render_target

Function create_render_target 

Source
pub fn create_render_target(
    device: &Device,
    format: TextureFormat,
    width: u32,
    height: u32,
    sample_count: u32,
) -> FrameTextures
Expand description

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.

The color texture is created with TextureUsages::RENDER_ATTACHMENT, TextureUsages::COPY_SRC so the caller can read the frame back, and TextureUsages::TEXTURE_BINDING so a later pass can sample it. The depth and multisample textures use TextureUsages::RENDER_ATTACHMENT | TRANSIENT_ATTACHMENT. The depth format is default_depth_stencil_format’s choice for device.

The returned FrameTextures gives the caller ownership of every texture, so they can register views in a crate::resources::ResourceGraph or otherwise manage lifetimes beyond the attachment set’s borrow.