Skip to main content

CommandBuffer

Struct CommandBuffer 

Source
pub struct CommandBuffer(/* private fields */);
Expand description

A buffer that stores encoded commands for the GPU to execute.

C++ equivalent: MTL::CommandBuffer

Command buffers are transient objects - you create them, encode commands, commit them for execution, and then discard them.

Implementations§

Source§

impl CommandBuffer

Source

pub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>

Create a CommandBuffer from a raw pointer.

§Safety

The pointer must be a valid Metal command buffer object.

Source

pub fn as_raw(&self) -> *mut c_void

Get the raw pointer to the command buffer.

Source

pub fn commit(&self)

Commit the command buffer for execution.

After calling this, you cannot encode any more commands into the buffer.

C++ equivalent: void commit()

Source

pub fn wait_until_completed(&self)

Block until the command buffer completes execution.

C++ equivalent: void waitUntilCompleted()

Source

pub fn wait_until_scheduled(&self)

Block until the command buffer is scheduled for execution.

C++ equivalent: void waitUntilScheduled()

Source

pub fn enqueue(&self)

Enqueue the command buffer for execution.

C++ equivalent: void enqueue()

Source

pub fn status(&self) -> CommandBufferStatus

Get the current status of the command buffer.

C++ equivalent: CommandBufferStatus status() const

Source

pub fn error(&self) -> Option<Error>

Get the error if the command buffer failed.

C++ equivalent: NS::Error* error() const

Source

pub fn gpu_start_time(&self) -> TimeInterval

Get the time when the GPU started executing the command buffer.

C++ equivalent: CFTimeInterval GPUStartTime() const

Source

pub fn gpu_end_time(&self) -> TimeInterval

Get the time when the GPU finished executing the command buffer.

C++ equivalent: CFTimeInterval GPUEndTime() const

Source

pub fn kernel_start_time(&self) -> TimeInterval

Get the time when the kernel started executing the command buffer.

C++ equivalent: CFTimeInterval kernelStartTime() const

Source

pub fn kernel_end_time(&self) -> TimeInterval

Get the time when the kernel finished executing the command buffer.

C++ equivalent: CFTimeInterval kernelEndTime() const

Source

pub fn retained_references(&self) -> bool

Check if the command buffer retains resources.

C++ equivalent: bool retainedReferences() const

Source

pub fn add_completed_handler<F>(&self, handler: F)
where F: Fn(&CommandBuffer) + Send + 'static,

Add a handler to be called when the command buffer completes.

C++ equivalent: void addCompletedHandler(void (^)(CommandBuffer*))

Source

pub fn add_scheduled_handler<F>(&self, handler: F)
where F: Fn(&CommandBuffer) + Send + 'static,

Add a handler to be called when the command buffer is scheduled.

C++ equivalent: void addScheduledHandler(void (^)(CommandBuffer*))

Source

pub unsafe fn present_drawable(&self, drawable: *const c_void)

Schedule a drawable for presentation at the earliest opportunity.

C++ equivalent: void presentDrawable(Drawable*)

§Safety

The drawable pointer must be valid.

Source

pub unsafe fn present_drawable_at_time( &self, drawable: *const c_void, time: TimeInterval, )

Schedule a drawable for presentation at a specific time.

C++ equivalent: void presentDrawable(Drawable*, CFTimeInterval)

§Safety

The drawable pointer must be valid.

Source

pub unsafe fn present_drawable_after_minimum_duration( &self, drawable: *const c_void, duration: TimeInterval, )

Schedule a drawable for presentation after a minimum duration.

C++ equivalent: void presentDrawableAfterMinimumDuration(Drawable*, CFTimeInterval)

§Safety

The drawable pointer must be valid.

Source

pub fn encode_signal_event(&self, event: &Event, value: u64)

Encode a signal for an event.

C++ equivalent: void encodeSignalEvent(const Event*, uint64_t value)

Source

pub fn encode_wait_for_event(&self, event: &Event, value: u64)

Encode a wait for an event.

C++ equivalent: void encodeWait(const Event*, uint64_t value)

Source

pub unsafe fn use_residency_set(&self, residency_set: *const c_void)

Use a residency set for this command buffer.

C++ equivalent: void useResidencySet(const ResidencySet*)

§Safety

The residency_set pointer must be valid.

Source

pub unsafe fn use_residency_sets( &self, residency_sets: *const *const c_void, count: UInteger, )

Use multiple residency sets for this command buffer.

C++ equivalent: void useResidencySets(const ResidencySet* const*, NS::UInteger count)

§Safety

The residency_sets pointer must be valid and point to count valid pointers.

Source

pub fn error_options(&self) -> CommandBufferErrorOption

Get the error options for this command buffer.

C++ equivalent: CommandBufferErrorOption errorOptions() const

Source

pub fn blit_command_encoder(&self) -> *mut c_void

Create a blit command encoder.

C++ equivalent: BlitCommandEncoder* blitCommandEncoder()

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub unsafe fn blit_command_encoder_with_descriptor( &self, descriptor: *const c_void, ) -> *mut c_void

Create a blit command encoder with a descriptor.

C++ equivalent: BlitCommandEncoder* blitCommandEncoder(const BlitPassDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub fn compute_command_encoder(&self) -> *mut c_void

Create a compute command encoder.

C++ equivalent: ComputeCommandEncoder* computeCommandEncoder()

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub fn compute_command_encoder_with_dispatch_type( &self, dispatch_type: DispatchType, ) -> *mut c_void

Create a compute command encoder with a dispatch type.

C++ equivalent: ComputeCommandEncoder* computeCommandEncoder(DispatchType)

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub unsafe fn compute_command_encoder_with_descriptor( &self, descriptor: *const c_void, ) -> *mut c_void

Create a compute command encoder with a descriptor.

C++ equivalent: ComputeCommandEncoder* computeCommandEncoder(const ComputePassDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub unsafe fn render_command_encoder_with_descriptor( &self, descriptor: *const c_void, ) -> *mut c_void

Create a render command encoder.

C++ equivalent: RenderCommandEncoder* renderCommandEncoder(const RenderPassDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub unsafe fn parallel_render_command_encoder_with_descriptor( &self, descriptor: *const c_void, ) -> *mut c_void

Create a parallel render command encoder.

C++ equivalent: ParallelRenderCommandEncoder* parallelRenderCommandEncoder(const RenderPassDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub fn resource_state_command_encoder(&self) -> *mut c_void

Create a resource state command encoder.

C++ equivalent: ResourceStateCommandEncoder* resourceStateCommandEncoder()

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub unsafe fn resource_state_command_encoder_with_descriptor( &self, descriptor: *const c_void, ) -> *mut c_void

Create a resource state command encoder with a descriptor.

C++ equivalent: ResourceStateCommandEncoder* resourceStateCommandEncoder(const ResourceStatePassDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub fn acceleration_structure_command_encoder(&self) -> *mut c_void

Create an acceleration structure command encoder.

C++ equivalent: AccelerationStructureCommandEncoder* accelerationStructureCommandEncoder()

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub unsafe fn acceleration_structure_command_encoder_with_descriptor( &self, descriptor: *const c_void, ) -> *mut c_void

Create an acceleration structure command encoder with a descriptor.

C++ equivalent: AccelerationStructureCommandEncoder* accelerationStructureCommandEncoder(const AccelerationStructurePassDescriptor*)

§Safety

The descriptor pointer must be valid.

Source

pub fn render_command_encoder( &self, descriptor: &RenderPassDescriptor, ) -> *mut c_void

Create a render command encoder with a typed descriptor.

C++ equivalent: RenderCommandEncoder* renderCommandEncoder(const RenderPassDescriptor*)

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub fn parallel_render_command_encoder( &self, descriptor: &RenderPassDescriptor, ) -> *mut c_void

Create a parallel render command encoder with a typed descriptor.

C++ equivalent: ParallelRenderCommandEncoder* parallelRenderCommandEncoder(const RenderPassDescriptor*)

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub fn compute_command_encoder_with_pass_descriptor( &self, descriptor: &ComputePassDescriptor, ) -> *mut c_void

Create a compute command encoder with a typed descriptor.

C++ equivalent: ComputeCommandEncoder* computeCommandEncoder(const ComputePassDescriptor*)

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub fn blit_command_encoder_with_pass_descriptor( &self, descriptor: &BlitPassDescriptor, ) -> *mut c_void

Create a blit command encoder with a typed descriptor.

C++ equivalent: BlitCommandEncoder* blitCommandEncoder(const BlitPassDescriptor*)

Returns a raw pointer to the encoder. The caller is responsible for ending encoding.

Source

pub fn label(&self) -> Option<String>

Get the label for this command buffer.

C++ equivalent: NS::String* label() const

Source

pub fn set_label(&self, label: &str)

Set the label for this command buffer.

C++ equivalent: void setLabel(const NS::String*)

Source

pub fn device(&self) -> Device

Get the device that created this command buffer.

C++ equivalent: Device* device() const

Source

pub fn command_queue(&self) -> CommandQueue

Get the command queue that created this command buffer.

C++ equivalent: CommandQueue* commandQueue() const

Source

pub fn push_debug_group(&self, name: &str)

Push a debug group.

C++ equivalent: void pushDebugGroup(const NS::String*)

Source

pub fn pop_debug_group(&self)

Pop a debug group.

C++ equivalent: void popDebugGroup()

Source

pub fn logs(&self) -> Option<LogContainer>

Get the log container for this command buffer.

C++ equivalent: LogContainer* logs() const

Returns a container of function logs generated during command buffer execution. The log container conforms to FastEnumeration and can be iterated.

Trait Implementations§

Source§

impl Clone for CommandBuffer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommandBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for CommandBuffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Referencing for CommandBuffer

Source§

fn as_ptr(&self) -> *const c_void

Get the raw pointer to the Objective-C object.
Source§

fn as_mut_ptr(&self) -> *mut c_void

Get the raw mutable pointer to the Objective-C object.
Source§

fn retain(&self) -> Self
where Self: Clone,

Retain the object, incrementing its reference count. Read more
Source§

fn release(&self)

Release the object, decrementing its reference count. Read more
Source§

fn autorelease(&self) -> Self
where Self: Clone,

Autorelease the object. Read more
Source§

fn retain_count(&self) -> usize

Get the retain count of the object. Read more
Source§

impl Send for CommandBuffer

Source§

impl Sync for CommandBuffer

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.