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 { ... }
}MTL4CommandBuffer only.Expand description
Records a sequence of GPU commands.
See also Apple’s documentation
Provided Methods§
Sourcefn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
Available on crate feature MTLDevice only.
fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
MTLDevice only.Returns the GPU device that this command buffer belongs to.
Sourcefn label(&self) -> Option<Retained<NSString>>
fn label(&self) -> Option<Retained<NSString>>
Assigns an optional label with this command buffer.
Sourcefn beginCommandBufferWithAllocator(
&self,
allocator: &ProtocolObject<dyn MTL4CommandAllocator>,
)
Available on crate feature MTL4CommandAllocator only.
fn beginCommandBufferWithAllocator( &self, allocator: &ProtocolObject<dyn MTL4CommandAllocator>, )
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:
MTL4CommandAllocatorto attach to.
Sourcefn beginCommandBufferWithAllocator_options(
&self,
allocator: &ProtocolObject<dyn MTL4CommandAllocator>,
options: &MTL4CommandBufferOptions,
)
Available on crate feature MTL4CommandAllocator only.
fn beginCommandBufferWithAllocator_options( &self, allocator: &ProtocolObject<dyn MTL4CommandAllocator>, options: &MTL4CommandBufferOptions, )
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:
MTL4CommandAllocatorto attach to. - options:
MTL4CommandBufferOptionsto configure the command buffer.
Sourcefn endCommandBuffer(&self)
fn endCommandBuffer(&self)
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.
Sourcefn renderCommandEncoderWithDescriptor(
&self,
descriptor: &MTL4RenderPassDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>>
Available on crate features MTL4CommandEncoder and MTL4RenderCommandEncoder and MTL4RenderPass only.
fn renderCommandEncoderWithDescriptor( &self, descriptor: &MTL4RenderPassDescriptor, ) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>>
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
MTL4RenderCommandEncoderinstance, ornilif the function failed.
Sourcefn renderCommandEncoderWithDescriptor_options(
&self,
descriptor: &MTL4RenderPassDescriptor,
options: MTL4RenderEncoderOptions,
) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>>
Available on crate features MTL4CommandEncoder and MTL4RenderCommandEncoder and MTL4RenderPass only.
fn renderCommandEncoderWithDescriptor_options( &self, descriptor: &MTL4RenderPassDescriptor, options: MTL4RenderEncoderOptions, ) -> Option<Retained<ProtocolObject<dyn MTL4RenderCommandEncoder>>>
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:
MTL4RenderEncoderOptionsinstance that provide render pass options. - Returns: The created
MTL4RenderCommandEncoderinstance, ornilif the function fails.
Sourcefn computeCommandEncoder(
&self,
) -> Option<Retained<ProtocolObject<dyn MTL4ComputeCommandEncoder>>>
Available on crate features MTL4CommandEncoder and MTL4ComputeCommandEncoder only.
fn computeCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTL4ComputeCommandEncoder>>>
MTL4CommandEncoder and MTL4ComputeCommandEncoder only.Creates a compute command encoder.
- Returns: The created
MTL4ComputeCommandEncoderinstance, ornilif the function fails.
Sourcefn machineLearningCommandEncoder(
&self,
) -> Option<Retained<ProtocolObject<dyn MTL4MachineLearningCommandEncoder>>>
Available on crate features MTL4CommandEncoder and MTL4MachineLearningCommandEncoder only.
fn machineLearningCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTL4MachineLearningCommandEncoder>>>
MTL4CommandEncoder and MTL4MachineLearningCommandEncoder only.Creates a machine learning command encoder.
- Returns: The created
MTL4MachineLearningCommandEncoderinstance , ornilif the function fails.
Sourcefn useResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>)
Available on crate feature MTLResidencySet only.
fn useResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>)
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:
MTLResidencySetinstance to mark resident.
Sourceunsafe fn useResidencySets_count(
&self,
residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>,
count: NSUInteger,
)
Available on crate feature MTLResidencySet only.
unsafe fn useResidencySets_count( &self, residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>, count: NSUInteger, )
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
MTLResidencySetinstances to mark resident. - count: Number of
MTLResidencySetinstances in the array.
§Safety
residency_setsmust be a valid pointer.countmight not be bounds-checked.
Sourcefn pushDebugGroup(&self, string: &NSString)
fn pushDebugGroup(&self, string: &NSString)
Pushes a string onto a stack of debug groups for this command buffer.
- Parameter string: The string to push.
Sourcefn popDebugGroup(&self)
fn popDebugGroup(&self)
Pops the latest string from the stack of debug groups for this command buffer.
Sourceunsafe fn writeTimestampIntoHeap_atIndex(
&self,
counter_heap: &ProtocolObject<dyn MTL4CounterHeap>,
index: NSUInteger,
)
Available on crate feature MTL4Counters only.
unsafe fn writeTimestampIntoHeap_atIndex( &self, counter_heap: &ProtocolObject<dyn MTL4CounterHeap>, index: NSUInteger, )
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:
MTL4CounterHeapto write the timestamp into. - index: The index within the
MTL4CounterHeapthat Metal writes the timestamp to.
§Safety
index might not be bounds-checked.
Sourceunsafe 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>>,
)
Available on crate features MTL4BufferRange and MTL4Counters and MTLFence and MTLGPUAddress only.
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>>, )
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
rangemight not be bounds-checked.bufferRangemight not be bounds-checked.