MTL4CommandBuffer

Trait MTL4CommandBuffer 

Source
pub unsafe trait MTL4CommandBuffer: NSObjectProtocol {
Show 16 methods // Provided methods fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>> where Self: Sized + Message { ... } fn label(&self) -> Option<Retained<NSString>> where Self: Sized + Message { ... } fn setLabel(&self, label: Option<&NSString>) where Self: Sized + Message { ... } fn beginCommandBufferWithAllocator( &self, allocator: &ProtocolObject<dyn MTL4CommandAllocator>, ) where Self: Sized + Message { ... } fn beginCommandBufferWithAllocator_options( &self, allocator: &ProtocolObject<dyn MTL4CommandAllocator>, options: &MTL4CommandBufferOptions, ) where Self: Sized + Message { ... } fn endCommandBuffer(&self) where Self: Sized + Message { ... } fn renderCommandEncoderWithDescriptor( &self, descriptor: &MTL4RenderPassDescriptor, ) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>> where Self: Sized + Message { ... } fn renderCommandEncoderWithDescriptor_options( &self, descriptor: &MTL4RenderPassDescriptor, options: MTL4RenderEncoderOptions, ) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>> where Self: Sized + Message { ... } fn computeCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTL4ComputeCommandEncoder>>> where Self: Sized + Message { ... } fn machineLearningCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTL4MachineLearningCommandEncoder>>> where Self: Sized + Message { ... } fn useResidencySet( &self, residency_set: &ProtocolObject<dyn MTLResidencySet>, ) where Self: Sized + Message { ... } unsafe fn useResidencySets_count( &self, residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>, count: NSUInteger, ) where Self: Sized + Message { ... } fn pushDebugGroup(&self, string: &NSString) where Self: Sized + Message { ... } fn popDebugGroup(&self) where Self: Sized + Message { ... } unsafe fn writeTimestampIntoHeap_atIndex( &self, counter_heap: &ProtocolObject<dyn MTL4CounterHeap>, index: NSUInteger, ) where Self: Sized + Message { ... } unsafe fn resolveCounterHeap_withRange_intoBuffer_waitFence_updateFence( &self, counter_heap: &ProtocolObject<dyn MTL4CounterHeap>, range: NSRange, buffer_range: MTL4BufferRange, fence_to_wait: Option<&ProtocolObject<dyn MTLFence>>, fence_to_update: Option<&ProtocolObject<dyn MTLFence>>, ) where Self: Sized + Message { ... }
}
Available on crate feature MTL4CommandBuffer only.
Expand description

Records a sequence of GPU commands.

See also Apple’s documentation

Provided Methods§

Source

fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
where Self: Sized + Message,

Available on crate feature MTLDevice only.

Returns the GPU device that this command buffer belongs to.

Source

fn label(&self) -> Option<Retained<NSString>>
where Self: Sized + Message,

Assigns an optional label with this command buffer.

Source

fn setLabel(&self, label: Option<&NSString>)
where Self: Sized + Message,

Setter for label.

This is copied when set.

Source

fn beginCommandBufferWithAllocator( &self, allocator: &ProtocolObject<dyn MTL4CommandAllocator>, )
where Self: Sized + Message,

Available on crate feature MTL4CommandAllocator only.

Prepares a command buffer for encoding.

Attaches the command buffer to the specified MTL4CommandAllocator and declares that the application is ready to encode commands into the command buffer.

Command allocators only service a single command buffer at a time. If you need to issue multiple calls to this method simultaneously, for example, in a multi-threaded command encoding scenario, create multiple instances of MTLCommandAllocator and use one for each call.

You can safely reuse command allocators after ending the command buffer using it by calling endCommandBuffer.

After calling this method, any prior calls to useResidencySet: and useResidencySets:count: on this command buffer instance no longer apply. Make sure to call these methods again to signal your residency requirements to Metal.

  • Parameter allocator: MTL4CommandAllocator to attach to.
Source

fn beginCommandBufferWithAllocator_options( &self, allocator: &ProtocolObject<dyn MTL4CommandAllocator>, options: &MTL4CommandBufferOptions, )
where Self: Sized + Message,

Available on crate feature MTL4CommandAllocator only.

Prepares a command buffer for encoding with additional options.

Attaches the command buffer to the specified MTL4CommandAllocator and declares that the application is ready to encode commands into the command buffer.

Command allocators only service a single command buffer at a time. If you need to issue multiple calls to this method simultaneously, for example, in a multi-threaded command encoding scenario, create multiple instances of MTLCommandAllocator and use one for each call.

You can safely reuse command allocators after ending the command buffer using it by calling endCommandBuffer.

After calling this method, any prior calls to useResidencySet: and useResidencySets:count: on this command buffer instance no longer apply. Make sure to call these methods again to signal your residency requirements to Metal.

The options you provide configure the command buffer only until the command buffer ends, in the next call to endCommandBuffer.

  • Parameters:
  • allocator: MTL4CommandAllocator to attach to.
  • options: MTL4CommandBufferOptions to configure the command buffer.
Source

fn endCommandBuffer(&self)
where Self: Sized + Message,

Closes a command buffer to prepare it for submission to a command queue.

Explicitly ending the command buffer allows you to reuse the MTL4CommandAllocator to start servicing other command buffers. It is an error to call commit on a command buffer previously recording before calling this method.

Source

fn renderCommandEncoderWithDescriptor( &self, descriptor: &MTL4RenderPassDescriptor, ) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>>
where Self: Sized + Message,

Available on crate features MTL4CommandEncoder and MTL4RenderCommandEncoder and MTL4RenderPass only.

Creates a render command encoder from a render pass descriptor.

  • Parameters:
  • descriptor: Descriptor for the render pass.
  • Returns: The created MTL4RenderCommandEncoder instance, or nil if the function failed.
Source

fn renderCommandEncoderWithDescriptor_options( &self, descriptor: &MTL4RenderPassDescriptor, options: MTL4RenderEncoderOptions, ) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>>
where Self: Sized + Message,

Available on crate features MTL4CommandEncoder and MTL4RenderCommandEncoder and MTL4RenderPass only.

Creates a render command encoder from a render pass descriptor with additional options.

This method creates a render command encoder to encode a render pass, whilst providing you the option to define some render pass characteristics via an instance of MTL4RenderEncoderOptions.

Use these options to configure suspending/resuming render command encoders, which allow you to encode render passes from multiple threads simultaneously.

  • Parameters:
  • descriptor: Descriptor for the render pass.
  • options: MTL4RenderEncoderOptions instance that provide render pass options.
  • Returns: The created MTL4RenderCommandEncoder instance, or nil if the function fails.
Source

fn computeCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTL4ComputeCommandEncoder>>>
where Self: Sized + Message,

Available on crate features MTL4CommandEncoder and MTL4ComputeCommandEncoder only.

Creates a compute command encoder.

  • Returns: The created MTL4ComputeCommandEncoder instance, or nil if the function fails.
Source

fn machineLearningCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTL4MachineLearningCommandEncoder>>>
where Self: Sized + Message,

Available on crate features MTL4CommandEncoder and MTL4MachineLearningCommandEncoder only.

Creates a machine learning command encoder.

  • Returns: The created MTL4MachineLearningCommandEncoder instance , or nil if the function fails.
Source

fn useResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>)
where Self: Sized + Message,

Available on crate feature MTLResidencySet only.

Marks a residency set as part of the command buffer’s execution.

Ensures that Metal makes resident the resources that residency set contains during execution of this command buffer.

  • Parameter residencySet: MTLResidencySet instance to mark resident.
Source

unsafe fn useResidencySets_count( &self, residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>, count: NSUInteger, )
where Self: Sized + Message,

Available on crate feature MTLResidencySet only.

Marks an array of residency sets as part of the command buffer’s execution.

Ensures that Metal makes resident the resources that residency sets contain during execution of this command buffer.

  • Parameters:
  • residencySets: Array of MTLResidencySet instances to mark resident.
  • count: Number of MTLResidencySet instances in the array.
§Safety
  • residency_sets must be a valid pointer.
  • count might not be bounds-checked.
Source

fn pushDebugGroup(&self, string: &NSString)
where Self: Sized + Message,

Pushes a string onto a stack of debug groups for this command buffer.

  • Parameter string: The string to push.
Source

fn popDebugGroup(&self)
where Self: Sized + Message,

Pops the latest string from the stack of debug groups for this command buffer.

Source

unsafe fn writeTimestampIntoHeap_atIndex( &self, counter_heap: &ProtocolObject<dyn MTL4CounterHeap>, index: NSUInteger, )
where Self: Sized + Message,

Available on crate feature MTL4Counters only.

Writes a GPU timestamp into the given counter heap.

This method captures a timestamp after work prior to this command in the command buffer is complete. Work after this call may or may not have started.

You are responsible for ensuring the counterHeap is of type MTL4CounterHeapType/MTL4CounterHeapTypeTimestamp.

  • Parameters:
  • counterHeap: MTL4CounterHeap to write the timestamp into.
  • index: The index within the MTL4CounterHeap that Metal writes the timestamp to.
§Safety

index might not be bounds-checked.

Source

unsafe fn resolveCounterHeap_withRange_intoBuffer_waitFence_updateFence( &self, counter_heap: &ProtocolObject<dyn MTL4CounterHeap>, range: NSRange, buffer_range: MTL4BufferRange, fence_to_wait: Option<&ProtocolObject<dyn MTLFence>>, fence_to_update: Option<&ProtocolObject<dyn MTLFence>>, )
where Self: Sized + Message,

Available on crate features MTL4BufferRange and MTL4Counters and MTLFence and MTLGPUAddress only.

Encodes a command that resolves an opaque counter heap into a buffer.

The command this method encodes converts the data within counterHeap into a common format and stores it into the bufferRange parameter.

The command places each entry in the counter heap within range sequentially, starting at alignedOffset. Each entry needs to be a fixed size that you can query by calling the MTLDevice/sizeOfCounterHeapEntry: method.

This command runs during the MTLStageBlit stage of the GPU timeline. Barrier against this stage to ensure the data is present in the resolve buffer parameter before you access it.

  • Note: Your app needs ensure the GPU places data in the heap before you resolve it by synchronizing this stage with other GPU operations.

Similarly, your app needs to synchronize any GPU accesses to bufferRange after the command completes with barrier.

If your app needs to access bufferRange from the CPU, signal an MTLSharedEvent to notify the CPU when it’s ready. Alternatively, you can resolve the heap’s data from the CPU by calling the heap’s MTL4CounterHeap/resolveCounterRange: method.

  • Parameters:
  • counterHeap: A heap the command resolves.
  • range: A range of index values within the heap the command resolves.
  • bufferRange: The buffer the command saves the data it resolves into.
  • fenceToWait: A fence the GPU waits for before starting, if applicable; otherwise nil.
  • fenceToUpdate: A fence the system updates after the command finishes resolving the data; otherwise nil.
§Safety
  • range might not be bounds-checked.
  • bufferRange might not be bounds-checked.

Trait Implementations§

Source§

impl ProtocolType for dyn MTL4CommandBuffer

Source§

const NAME: &'static str = "MTL4CommandBuffer"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn MTL4CommandBuffer

Implementations on Foreign Types§

Source§

impl<T> MTL4CommandBuffer for ProtocolObject<T>

Implementors§