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§
- Command
Stream - A reusable command stream.
- Command
Stream Draft - A finalized command stream definition that can be prepared later.
- Command
Stream Mut - A mutable graph-like command stream being prepared.
- Command
Stream Run - An in-progress invocation of a
CommandStreaminto aGraph. - Stream
Arg - A typed external argument for a
CommandStream. - Stream
Command - A command being recorded into a
CommandStreamMut. - Stream
Pipeline Command - A stream command with a bound pipeline.
Type Aliases§
- Acceleration
Structure Arg - A stream argument for an acceleration structure.
- Buffer
Arg - A stream argument for a buffer.
- Image
Arg - A stream argument for an image.