Skip to main content

Command

Struct Command 

Source
pub struct Command<'a> { /* private fields */ }
Expand description

A general-purpose Vulkan command which may contain acceleration structure operations, transfers, or shader pipelines.

There are four main uses of a Command:

  1. Bind resources (Self::bind_resource)
  2. Declare resource accesses (Self::resource_access)
  3. Record general-purpose command buffers or acceleration structure operations (Self::record_cmd)
  4. Bind shader pipelines (Self::bind_pipeline)

When bound, a shader pipeline consumes the Command and returns a PipelineCommand which provides command recording functions specific to each pipeline type.

Implementations§

Source§

impl<'a> Command<'a>

Source

pub fn builder(graph: &'a mut Graph) -> CommandBuilder<'a>

Begins a command builder in graph.

Source

pub fn into_builder(self) -> CommandBuilder<'a>

Converts this command into a builder.

Source

pub fn track_execution(&mut self) -> CommandExecution

Returns a handle that tracks whether this graph command has completed device execution.

This may be called multiple times. Each returned handle independently observes the same command execution.

Source

pub fn write_timestamp(&mut self) -> TimestampQuery

Records a timestamp query point at the current position in this command.

A timestamp written before any command work is recorded at the start of this command. After command work is recorded, timestamps are recorded after the most recently added execution.

See Graph::write_timestamp for graph-boundary timestamps.

Source

pub fn bind_resource<R>(&mut self, resource: R) -> R::Node
where R: Resource,

Binds a Vulkan buffer, image, or acceleration structure resource to the graph associated with this command.

Bound nodes may be used in commands for pipeline and shader operations.

Source

pub fn bind_pipeline<P>(self, pipeline: P) -> P::Command
where P: Pipeline<'a>,

Binds a shader pipeline to the current command, allowing for strongly typed access to the related functions.

Source

pub fn debug_name(self, name: impl Into<String>) -> Self

Sets a debugging name, but only in debug builds.

Source

pub fn end_cmd(self) -> &'a mut Graph

Finalize the recording of this command and return to the Graph where you may record additional commands.

Source

pub fn record_cmd( self, func: impl FnOnce(CommandRef<'_>) + Send + 'static, ) -> Self

Begin recording general-purpose work for this graph command.

This is the entry point for building and updating an AccelerationStructure instance.

The provided closure allows you to run any Vulkan code, or interoperate with other Vulkan code and interfaces.

Source

pub fn record_cmd_mut( &mut self, func: impl FnOnce(CommandRef<'_>) + Send + 'static, )

Mutable-borrow form of Self::record_cmd.

Source

pub fn blit_image( self, src: impl Into<AnyImageNode>, dst: impl Into<AnyImageNode>, filter: Filter, regions: impl AsRef<[ImageBlit]> + 'static + Send, ) -> Self

Blits image regions.

Source

pub fn clear_color_image( self, image: impl Into<AnyImageNode>, color: impl Into<ClearColorValue>, ) -> Self

Clears a color image.

Source

pub fn clear_depth_stencil_image( self, image: impl Into<AnyImageNode>, depth: f32, stencil: u32, ) -> Self

Clears a depth/stencil image.

Source

pub fn copy_buffer( self, src: impl Into<AnyBufferNode>, dst: impl Into<AnyBufferNode>, regions: impl AsRef<[BufferCopy]> + 'static + Send, ) -> Self

Copies data between buffer regions.

Source

pub fn copy_buffer_to_image( self, src: impl Into<AnyBufferNode>, dst: impl Into<AnyImageNode>, regions: impl AsRef<[BufferImageCopy]> + 'static + Send, ) -> Self

Copies data from a buffer into image regions.

Source

pub fn copy_image( self, src: impl Into<AnyImageNode>, dst: impl Into<AnyImageNode>, regions: impl AsRef<[ImageCopy]> + 'static + Send, ) -> Self

Copies data between image regions.

Source

pub fn copy_image_to_buffer( self, src: impl Into<AnyImageNode>, dst: impl Into<AnyBufferNode>, regions: impl AsRef<[BufferImageCopy]> + 'static + Send, ) -> Self

Copies image region data into a buffer.

Source

pub fn fill_buffer( self, buffer: impl Into<AnyBufferNode>, region: Range<DeviceSize>, data: u32, ) -> Self

Fills a region of a buffer with a fixed value.

Source

pub fn resource<N>(&self, resource_node: N) -> &N::Resource
where N: Node,

Returns a borrow of the original Vulkan resource (buffer, image or acceleration structure) which the given bound resource node represents.

Source

pub fn resource_access<N>(self, resource_node: N, access: AccessType) -> Self
where N: Node + Subresource, SubresourceRange: From<N::Range>,

Informs the command that recorded work will read or write resource_node using access.

An access function must be called for resource_node before it is used within a recording function.

Source

pub fn set_debug_name(&mut self, name: impl Into<String>) -> &mut Self

Mutable-borrow form of Self::debug_name.

Source

pub fn set_resource_access<N>(&mut self, resource_node: N, access: AccessType)
where N: Node + Subresource, SubresourceRange: From<N::Range>,

Mutable-borrow form of Self::resource_access.

Source

pub fn set_subresource_access<N>( &mut self, resource_node: N, subresource: impl Into<N::Range>, access: AccessType, )
where N: Node + Subresource, SubresourceRange: From<N::Range>,

Mutable-borrow form of Self::subresource_access.

Source

pub fn subresource_access<N>( self, resource_node: N, subresource: impl Into<N::Range>, access: AccessType, ) -> Self
where N: Node + Subresource, SubresourceRange: From<N::Range>,

Informs the command that recorded work will read or write the subresource of resource_node using access.

An access function must be called for resource_node before it is used within a recording function.

Source

pub fn update_buffer( self, buffer: impl Into<AnyBufferNode>, offset: DeviceSize, data: impl AsRef<[u8]> + 'static + Send, ) -> Self

Records a vkCmdUpdateBuffer command.

Vulkan requires data to be at most 65536 bytes.

These constraints are validated by the Vulkan Validation Layer (VVL) when it is active. When the checked feature is enabled, vk-graph also validates the data size and bounds before recording the command.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Command<'a>

§

impl<'a> !Sync for Command<'a>

§

impl<'a> !UnwindSafe for Command<'a>

§

impl<'a> Freeze for Command<'a>

§

impl<'a> Send for Command<'a>

§

impl<'a> Unpin for Command<'a>

§

impl<'a> UnsafeUnpin for Command<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.