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
impl CommandBuffer
Sourcepub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>
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.
Sourcepub fn commit(&self)
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()
Sourcepub fn wait_until_completed(&self)
pub fn wait_until_completed(&self)
Block until the command buffer completes execution.
C++ equivalent: void waitUntilCompleted()
Sourcepub fn wait_until_scheduled(&self)
pub fn wait_until_scheduled(&self)
Block until the command buffer is scheduled for execution.
C++ equivalent: void waitUntilScheduled()
Sourcepub fn status(&self) -> CommandBufferStatus
pub fn status(&self) -> CommandBufferStatus
Get the current status of the command buffer.
C++ equivalent: CommandBufferStatus status() const
Sourcepub fn error(&self) -> Option<Error>
pub fn error(&self) -> Option<Error>
Get the error if the command buffer failed.
C++ equivalent: NS::Error* error() const
Sourcepub fn gpu_start_time(&self) -> TimeInterval
pub fn gpu_start_time(&self) -> TimeInterval
Get the time when the GPU started executing the command buffer.
C++ equivalent: CFTimeInterval GPUStartTime() const
Sourcepub fn gpu_end_time(&self) -> TimeInterval
pub fn gpu_end_time(&self) -> TimeInterval
Get the time when the GPU finished executing the command buffer.
C++ equivalent: CFTimeInterval GPUEndTime() const
Sourcepub fn kernel_start_time(&self) -> TimeInterval
pub fn kernel_start_time(&self) -> TimeInterval
Get the time when the kernel started executing the command buffer.
C++ equivalent: CFTimeInterval kernelStartTime() const
Sourcepub fn kernel_end_time(&self) -> TimeInterval
pub fn kernel_end_time(&self) -> TimeInterval
Get the time when the kernel finished executing the command buffer.
C++ equivalent: CFTimeInterval kernelEndTime() const
Sourcepub fn retained_references(&self) -> bool
pub fn retained_references(&self) -> bool
Check if the command buffer retains resources.
C++ equivalent: bool retainedReferences() const
Sourcepub fn add_completed_handler<F>(&self, handler: F)
pub fn add_completed_handler<F>(&self, handler: F)
Add a handler to be called when the command buffer completes.
C++ equivalent: void addCompletedHandler(void (^)(CommandBuffer*))
Sourcepub fn add_scheduled_handler<F>(&self, handler: F)
pub fn add_scheduled_handler<F>(&self, handler: F)
Add a handler to be called when the command buffer is scheduled.
C++ equivalent: void addScheduledHandler(void (^)(CommandBuffer*))
Sourcepub unsafe fn present_drawable(&self, drawable: *const c_void)
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.
Sourcepub unsafe fn present_drawable_at_time(
&self,
drawable: *const c_void,
time: TimeInterval,
)
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.
Sourcepub unsafe fn present_drawable_after_minimum_duration(
&self,
drawable: *const c_void,
duration: TimeInterval,
)
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.
Sourcepub fn encode_signal_event(&self, event: &Event, value: u64)
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)
Sourcepub fn encode_wait_for_event(&self, event: &Event, value: u64)
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)
Sourcepub unsafe fn use_residency_set(&self, residency_set: *const c_void)
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.
Sourcepub unsafe fn use_residency_sets(
&self,
residency_sets: *const *const c_void,
count: UInteger,
)
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.
Sourcepub fn error_options(&self) -> CommandBufferErrorOption
pub fn error_options(&self) -> CommandBufferErrorOption
Get the error options for this command buffer.
C++ equivalent: CommandBufferErrorOption errorOptions() const
Sourcepub fn blit_command_encoder(&self) -> *mut c_void
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.
Sourcepub unsafe fn blit_command_encoder_with_descriptor(
&self,
descriptor: *const c_void,
) -> *mut c_void
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.
Sourcepub fn compute_command_encoder(&self) -> *mut c_void
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.
Sourcepub fn compute_command_encoder_with_dispatch_type(
&self,
dispatch_type: DispatchType,
) -> *mut c_void
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.
Sourcepub unsafe fn compute_command_encoder_with_descriptor(
&self,
descriptor: *const c_void,
) -> *mut c_void
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.
Sourcepub unsafe fn render_command_encoder_with_descriptor(
&self,
descriptor: *const c_void,
) -> *mut c_void
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.
Sourcepub unsafe fn parallel_render_command_encoder_with_descriptor(
&self,
descriptor: *const c_void,
) -> *mut c_void
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.
Sourcepub fn resource_state_command_encoder(&self) -> *mut c_void
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.
Sourcepub unsafe fn resource_state_command_encoder_with_descriptor(
&self,
descriptor: *const c_void,
) -> *mut c_void
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.
Sourcepub fn acceleration_structure_command_encoder(&self) -> *mut c_void
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.
Sourcepub unsafe fn acceleration_structure_command_encoder_with_descriptor(
&self,
descriptor: *const c_void,
) -> *mut c_void
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.
Sourcepub fn render_command_encoder(
&self,
descriptor: &RenderPassDescriptor,
) -> *mut c_void
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.
Sourcepub fn parallel_render_command_encoder(
&self,
descriptor: &RenderPassDescriptor,
) -> *mut c_void
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.
Sourcepub fn compute_command_encoder_with_pass_descriptor(
&self,
descriptor: &ComputePassDescriptor,
) -> *mut c_void
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.
Sourcepub fn blit_command_encoder_with_pass_descriptor(
&self,
descriptor: &BlitPassDescriptor,
) -> *mut c_void
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.
Sourcepub fn label(&self) -> Option<String>
pub fn label(&self) -> Option<String>
Get the label for this command buffer.
C++ equivalent: NS::String* label() const
Sourcepub fn set_label(&self, label: &str)
pub fn set_label(&self, label: &str)
Set the label for this command buffer.
C++ equivalent: void setLabel(const NS::String*)
Sourcepub fn device(&self) -> Device
pub fn device(&self) -> Device
Get the device that created this command buffer.
C++ equivalent: Device* device() const
Sourcepub fn command_queue(&self) -> CommandQueue
pub fn command_queue(&self) -> CommandQueue
Get the command queue that created this command buffer.
C++ equivalent: CommandQueue* commandQueue() const
Sourcepub fn push_debug_group(&self, name: &str)
pub fn push_debug_group(&self, name: &str)
Push a debug group.
C++ equivalent: void pushDebugGroup(const NS::String*)
Sourcepub fn pop_debug_group(&self)
pub fn pop_debug_group(&self)
Pop a debug group.
C++ equivalent: void popDebugGroup()
Sourcepub fn logs(&self) -> Option<LogContainer>
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.