Skip to main content

Module stream

Module stream 

Source
Expand description

Reusable command streams.

A CommandStream is a prepared graph-like command sequence that can be inserted into a per-frame Graph with typed arguments.

Streams are useful when part of a frame is structurally the same across many frames but still needs per-frame resources such as the current swapchain image. Declare those resources as stream arguments, record reusable commands once, and bind concrete graph nodes when inserting the stream.

let stream = CommandStream::prepare(&mut pool, |stream| {
    let output = stream.arg(ImageInfo::image_2d(
        1280,
        720,
        vk::Format::R8G8B8A8_UNORM,
        vk::ImageUsageFlags::COLOR_ATTACHMENT,
    ));
    let vertices = stream.arg(BufferInfo::device_mem(
        4096,
        vk::BufferUsageFlags::VERTEX_BUFFER,
    ));

    stream
        .begin_cmd()
        .debug_name("reusable overlay")
        .bind_pipeline(&pipeline)
        .color_attachment_image(0, output, LoadOp::Load, StoreOp::Store)
        .resource_access(vertices, AccessType::VertexBuffer)
        .record_cmd(move |cmd| {
            cmd.bind_vertex_buffer(0, vertices, 0).draw(3, 1, 0, 0);
        });

    (output, vertices)
})?;

let mut graph = Graph::new();
graph
    .insert_cmd_stream(&stream)
    .with_arg(stream.args.0, swapchain_image)
    .with_arg(stream.args.1, vertex_buffer)
    .finish();

Structs§

CommandStream
A reusable command stream.
CommandStreamDraft
A finalized command stream definition that can be prepared later.
CommandStreamMut
A mutable graph-like command stream being prepared.
CommandStreamRun
An in-progress invocation of a CommandStream into a Graph.
StreamArg
A typed external argument for a CommandStream.
StreamCommand
A command being recorded into a CommandStreamMut.
StreamPipelineCommand
A stream command with a bound pipeline.

Type Aliases§

AccelerationStructureArg
A stream argument for an acceleration structure.
BufferArg
A stream argument for a buffer.
ImageArg
A stream argument for an image.