pub struct ComputeCommandEncoder(/* private fields */);Expand description
A command encoder for compute operations.
C++ equivalent: MTL::ComputeCommandEncoder
Compute encoders are used to dispatch compute shaders and manage resources for compute operations.
Implementations§
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub unsafe fn set_acceleration_structure_ptr(
&self,
acceleration_structure: *const c_void,
buffer_index: UInteger,
)
pub unsafe fn set_acceleration_structure_ptr( &self, acceleration_structure: *const c_void, buffer_index: UInteger, )
Set an acceleration structure at a buffer index (raw pointer version).
C++ equivalent: void setAccelerationStructure(const AccelerationStructure*, NS::UInteger)
§Safety
The acceleration structure pointer must be a valid Metal acceleration structure object.
Sourcepub fn set_acceleration_structure(
&self,
acceleration_structure: &AccelerationStructure,
buffer_index: UInteger,
)
pub fn set_acceleration_structure( &self, acceleration_structure: &AccelerationStructure, buffer_index: UInteger, )
Set an acceleration structure at a buffer index.
C++ equivalent: void setAccelerationStructure(const AccelerationStructure*, NS::UInteger)
Sourcepub unsafe fn set_visible_function_table_ptr(
&self,
visible_function_table: *const c_void,
buffer_index: UInteger,
)
pub unsafe fn set_visible_function_table_ptr( &self, visible_function_table: *const c_void, buffer_index: UInteger, )
Set a visible function table at a buffer index (raw pointer version).
C++ equivalent: void setVisibleFunctionTable(const VisibleFunctionTable*, NS::UInteger)
§Safety
The visible function table pointer must be valid.
Sourcepub unsafe fn set_intersection_function_table_ptr(
&self,
intersection_function_table: *const c_void,
buffer_index: UInteger,
)
pub unsafe fn set_intersection_function_table_ptr( &self, intersection_function_table: *const c_void, buffer_index: UInteger, )
Set an intersection function table at a buffer index (raw pointer version).
C++ equivalent: void setIntersectionFunctionTable(const IntersectionFunctionTable*, NS::UInteger)
§Safety
The intersection function table pointer must be valid.
Sourcepub unsafe fn set_visible_function_tables_ptr(
&self,
visible_function_tables: *const *const c_void,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_visible_function_tables_ptr( &self, visible_function_tables: *const *const c_void, range_location: UInteger, range_length: UInteger, )
Set multiple visible function tables at a range of buffer indices (raw pointer version).
C++ equivalent: void setVisibleFunctionTables(const VisibleFunctionTable* const*, NS::Range)
§Safety
The visible function tables pointer must be a valid array with at least range.length elements.
Sourcepub unsafe fn set_intersection_function_tables_ptr(
&self,
intersection_function_tables: *const *const c_void,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_intersection_function_tables_ptr( &self, intersection_function_tables: *const *const c_void, range_location: UInteger, range_length: UInteger, )
Set multiple intersection function tables at a range of buffer indices (raw pointer version).
C++ equivalent: void setIntersectionFunctionTables(const IntersectionFunctionTable* const*, NS::Range)
§Safety
The intersection function tables pointer must be a valid array with at least range.length elements.
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub fn set_buffer(&self, buffer: &Buffer, offset: UInteger, index: UInteger)
pub fn set_buffer(&self, buffer: &Buffer, offset: UInteger, index: UInteger)
Set a buffer at an index.
C++ equivalent: void setBuffer(const Buffer*, NS::UInteger, NS::UInteger)
Sourcepub fn set_buffer_with_stride(
&self,
buffer: &Buffer,
offset: UInteger,
stride: UInteger,
index: UInteger,
)
pub fn set_buffer_with_stride( &self, buffer: &Buffer, offset: UInteger, stride: UInteger, index: UInteger, )
Set a buffer at an index with attribute stride.
C++ equivalent: void setBuffer(const Buffer*, NS::UInteger, NS::UInteger, NS::UInteger)
Sourcepub fn set_buffer_offset(&self, offset: UInteger, index: UInteger)
pub fn set_buffer_offset(&self, offset: UInteger, index: UInteger)
Set the buffer offset at an index.
C++ equivalent: void setBufferOffset(NS::UInteger, NS::UInteger)
Sourcepub fn set_buffer_offset_with_stride(
&self,
offset: UInteger,
stride: UInteger,
index: UInteger,
)
pub fn set_buffer_offset_with_stride( &self, offset: UInteger, stride: UInteger, index: UInteger, )
Set the buffer offset at an index with attribute stride.
C++ equivalent: void setBufferOffset(NS::UInteger, NS::UInteger, NS::UInteger)
Sourcepub fn set_bytes(&self, bytes: &[u8], index: UInteger)
pub fn set_bytes(&self, bytes: &[u8], index: UInteger)
Set inline bytes at an index.
C++ equivalent: void setBytes(const void*, NS::UInteger, NS::UInteger)
Sourcepub fn set_bytes_with_stride(
&self,
bytes: &[u8],
stride: UInteger,
index: UInteger,
)
pub fn set_bytes_with_stride( &self, bytes: &[u8], stride: UInteger, index: UInteger, )
Set inline bytes at an index with attribute stride.
C++ equivalent: void setBytes(const void*, NS::UInteger, NS::UInteger, NS::UInteger)
Sourcepub unsafe fn set_buffers_ptr(
&self,
buffers: *const *const c_void,
offsets: *const UInteger,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_buffers_ptr( &self, buffers: *const *const c_void, offsets: *const UInteger, range_location: UInteger, range_length: UInteger, )
Set multiple buffers at a range of indices (raw pointer version).
C++ equivalent: void setBuffers(const Buffer* const*, const NS::UInteger*, NS::Range)
§Safety
The buffers and offsets pointers must be valid arrays with at least range.length elements.
Sourcepub unsafe fn set_buffers_with_strides_ptr(
&self,
buffers: *const *const c_void,
offsets: *const UInteger,
strides: *const UInteger,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_buffers_with_strides_ptr( &self, buffers: *const *const c_void, offsets: *const UInteger, strides: *const UInteger, range_location: UInteger, range_length: UInteger, )
Set multiple buffers at a range of indices with strides (raw pointer version).
C++ equivalent: void setBuffers(const Buffer* const*, const NS::UInteger*, const NS::UInteger*, NS::Range)
§Safety
The buffers, offsets, and strides pointers must be valid arrays with at least range.length elements.
Sourcepub fn set_texture(&self, texture: &Texture, index: UInteger)
pub fn set_texture(&self, texture: &Texture, index: UInteger)
Set a texture at an index.
C++ equivalent: void setTexture(const Texture*, NS::UInteger)
Sourcepub unsafe fn set_textures_ptr(
&self,
textures: *const *const c_void,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_textures_ptr( &self, textures: *const *const c_void, range_location: UInteger, range_length: UInteger, )
Set multiple textures at a range of indices (raw pointer version).
C++ equivalent: void setTextures(const Texture* const*, NS::Range)
§Safety
The textures pointer must be a valid array with at least range.length elements.
Sourcepub fn set_sampler_state(&self, sampler: &SamplerState, index: UInteger)
pub fn set_sampler_state(&self, sampler: &SamplerState, index: UInteger)
Set a sampler state at an index.
C++ equivalent: void setSamplerState(const SamplerState*, NS::UInteger)
Sourcepub fn set_sampler_state_with_lod_clamps(
&self,
sampler: &SamplerState,
lod_min_clamp: f32,
lod_max_clamp: f32,
index: UInteger,
)
pub fn set_sampler_state_with_lod_clamps( &self, sampler: &SamplerState, lod_min_clamp: f32, lod_max_clamp: f32, index: UInteger, )
Set a sampler state with LOD clamps at an index.
C++ equivalent: void setSamplerState(const SamplerState*, float, float, NS::UInteger)
Sourcepub unsafe fn set_sampler_states_ptr(
&self,
samplers: *const *const c_void,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_sampler_states_ptr( &self, samplers: *const *const c_void, range_location: UInteger, range_length: UInteger, )
Set multiple sampler states at a range of indices (raw pointer version).
C++ equivalent: void setSamplerStates(const SamplerState* const*, NS::Range)
§Safety
The samplers pointer must be a valid array with at least range.length elements.
Sourcepub unsafe fn set_sampler_states_with_lod_clamps_ptr(
&self,
samplers: *const *const c_void,
lod_min_clamps: *const f32,
lod_max_clamps: *const f32,
range_location: UInteger,
range_length: UInteger,
)
pub unsafe fn set_sampler_states_with_lod_clamps_ptr( &self, samplers: *const *const c_void, lod_min_clamps: *const f32, lod_max_clamps: *const f32, range_location: UInteger, range_length: UInteger, )
Set multiple sampler states with LOD clamps at a range of indices (raw pointer version).
C++ equivalent: void setSamplerStates(const SamplerState* const*, const float*, const float*, NS::Range)
§Safety
The samplers, lod_min_clamps, and lod_max_clamps pointers must be valid arrays with at least range.length elements.
Sourcepub fn set_threadgroup_memory_length(&self, length: UInteger, index: UInteger)
pub fn set_threadgroup_memory_length(&self, length: UInteger, index: UInteger)
Set the threadgroup memory length at an index.
C++ equivalent: void setThreadgroupMemoryLength(NS::UInteger, NS::UInteger)
Sourcepub fn set_imageblock_width(&self, width: UInteger, height: UInteger)
pub fn set_imageblock_width(&self, width: UInteger, height: UInteger)
Set the imageblock dimensions.
C++ equivalent: void setImageblockWidth(NS::UInteger, NS::UInteger)
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub fn set_stage_in_region(&self, region: Region)
pub fn set_stage_in_region(&self, region: Region)
Set the stage-in region.
C++ equivalent: void setStageInRegion(MTL::Region)
Sourcepub fn set_stage_in_region_with_indirect_buffer(
&self,
indirect_buffer: &Buffer,
indirect_buffer_offset: UInteger,
)
pub fn set_stage_in_region_with_indirect_buffer( &self, indirect_buffer: &Buffer, indirect_buffer_offset: UInteger, )
Set the stage-in region from an indirect buffer.
C++ equivalent: void setStageInRegion(const Buffer*, NS::UInteger)
Sourcepub fn dispatch_threadgroups(
&self,
threadgroups_per_grid: Size,
threads_per_threadgroup: Size,
)
pub fn dispatch_threadgroups( &self, threadgroups_per_grid: Size, threads_per_threadgroup: Size, )
Dispatch threadgroups.
C++ equivalent: void dispatchThreadgroups(MTL::Size, MTL::Size)
Sourcepub fn dispatch_threadgroups_with_indirect_buffer(
&self,
indirect_buffer: &Buffer,
indirect_buffer_offset: UInteger,
threads_per_threadgroup: Size,
)
pub fn dispatch_threadgroups_with_indirect_buffer( &self, indirect_buffer: &Buffer, indirect_buffer_offset: UInteger, threads_per_threadgroup: Size, )
Dispatch threadgroups with an indirect buffer.
C++ equivalent: void dispatchThreadgroups(const Buffer*, NS::UInteger, MTL::Size)
Sourcepub fn dispatch_threads(
&self,
threads_per_grid: Size,
threads_per_threadgroup: Size,
)
pub fn dispatch_threads( &self, threads_per_grid: Size, threads_per_threadgroup: Size, )
Dispatch threads directly (non-uniform dispatch).
C++ equivalent: void dispatchThreads(MTL::Size, MTL::Size)
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub unsafe fn execute_commands_in_buffer_ptr(
&self,
indirect_command_buffer: *const c_void,
offset: UInteger,
length: UInteger,
)
pub unsafe fn execute_commands_in_buffer_ptr( &self, indirect_command_buffer: *const c_void, offset: UInteger, length: UInteger, )
Execute commands from an indirect command buffer (raw pointer version).
C++ equivalent: void executeCommandsInBuffer(const IndirectCommandBuffer*, NS::Range)
§Safety
The indirect command buffer pointer must be valid.
Sourcepub unsafe fn execute_commands_in_buffer_with_indirect_range_ptr(
&self,
indirect_command_buffer: *const c_void,
indirect_range_buffer: *const c_void,
indirect_buffer_offset: UInteger,
)
pub unsafe fn execute_commands_in_buffer_with_indirect_range_ptr( &self, indirect_command_buffer: *const c_void, indirect_range_buffer: *const c_void, indirect_buffer_offset: UInteger, )
Execute commands from an indirect command buffer with indirect range (raw pointer version).
C++ equivalent: void executeCommandsInBuffer(const IndirectCommandBuffer*, const Buffer*, NS::UInteger)
§Safety
The indirect command buffer and range buffer pointers must be valid.
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub fn memory_barrier_with_scope(&self, scope: BarrierScope)
pub fn memory_barrier_with_scope(&self, scope: BarrierScope)
Insert a memory barrier with scope.
C++ equivalent: void memoryBarrier(MTL::BarrierScope)
Sourcepub unsafe fn memory_barrier_with_resources_ptr(
&self,
resources: *const *const c_void,
count: UInteger,
)
pub unsafe fn memory_barrier_with_resources_ptr( &self, resources: *const *const c_void, count: UInteger, )
Insert a memory barrier for specific resources (raw pointer version).
C++ equivalent: void memoryBarrier(const Resource* const*, NS::UInteger)
§Safety
The resources pointer must point to a valid array of resource pointers with the specified count.
Sourcepub unsafe fn use_resource_ptr(
&self,
resource: *const c_void,
usage: ResourceUsage,
)
pub unsafe fn use_resource_ptr( &self, resource: *const c_void, usage: ResourceUsage, )
Declare that a resource will be used (raw pointer version).
C++ equivalent: void useResource(const Resource*, MTL::ResourceUsage)
§Safety
The resource pointer must be a valid Metal resource object.
Sourcepub fn use_buffer(&self, buffer: &Buffer, usage: ResourceUsage)
pub fn use_buffer(&self, buffer: &Buffer, usage: ResourceUsage)
Declare that a buffer will be used.
C++ equivalent: void useResource(const Resource*, MTL::ResourceUsage)
Sourcepub fn use_texture(&self, texture: &Texture, usage: ResourceUsage)
pub fn use_texture(&self, texture: &Texture, usage: ResourceUsage)
Declare that a texture will be used.
C++ equivalent: void useResource(const Resource*, MTL::ResourceUsage)
Sourcepub unsafe fn use_heap_ptr(&self, heap: *const c_void)
pub unsafe fn use_heap_ptr(&self, heap: *const c_void)
Declare that a heap will be used (raw pointer version).
C++ equivalent: void useHeap(const Heap*)
§Safety
The heap pointer must be a valid Metal heap object.
Sourcepub fn use_heap(&self, heap: &Heap)
pub fn use_heap(&self, heap: &Heap)
Declare that a heap will be used.
C++ equivalent: void useHeap(const Heap*)
Sourcepub unsafe fn use_heaps_ptr(&self, heaps: *const *const c_void, count: UInteger)
pub unsafe fn use_heaps_ptr(&self, heaps: *const *const c_void, count: UInteger)
Declare that multiple heaps will be used (raw pointer version).
C++ equivalent: void useHeaps(const Heap* const*, NS::UInteger)
§Safety
The heaps pointer must be a valid array of heap pointers with the specified count.
Sourcepub unsafe fn use_resources_ptr(
&self,
resources: *const *const c_void,
count: UInteger,
usage: ResourceUsage,
)
pub unsafe fn use_resources_ptr( &self, resources: *const *const c_void, count: UInteger, usage: ResourceUsage, )
Declare that multiple resources will be used (raw pointer version).
C++ equivalent: void useResources(const Resource* const*, NS::UInteger, MTL::ResourceUsage)
§Safety
The resources pointer must be a valid array of resource pointers with the specified count.
Sourcepub unsafe fn update_fence_ptr(&self, fence: *const c_void)
pub unsafe fn update_fence_ptr(&self, fence: *const c_void)
Update a fence (raw pointer version).
C++ equivalent: void updateFence(const Fence*)
§Safety
The fence pointer must be a valid Metal fence object.
Sourcepub fn update_fence(&self, fence: &Fence)
pub fn update_fence(&self, fence: &Fence)
Update a fence.
C++ equivalent: void updateFence(const Fence*)
Sourcepub unsafe fn wait_for_fence_ptr(&self, fence: *const c_void)
pub unsafe fn wait_for_fence_ptr(&self, fence: *const c_void)
Wait for a fence (raw pointer version).
C++ equivalent: void waitForFence(const Fence*)
§Safety
The fence pointer must be a valid Metal fence object.
Sourcepub fn wait_for_fence(&self, fence: &Fence)
pub fn wait_for_fence(&self, fence: &Fence)
Wait for a fence.
C++ equivalent: void waitForFence(const Fence*)
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub fn set_compute_pipeline_state(&self, state: &ComputePipelineState)
pub fn set_compute_pipeline_state(&self, state: &ComputePipelineState)
Set the compute pipeline state.
C++ equivalent: void setComputePipelineState(const ComputePipelineState*)
Sourcepub fn dispatch_type(&self) -> DispatchType
pub fn dispatch_type(&self) -> DispatchType
Get the dispatch type for this encoder.
C++ equivalent: DispatchType dispatchType() const
Source§impl ComputeCommandEncoder
impl ComputeCommandEncoder
Sourcepub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>
pub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>
Create a ComputeCommandEncoder from a raw pointer.
§Safety
The pointer must be a valid Metal compute command encoder object.
Sourcepub fn device(&self) -> Device
pub fn device(&self) -> Device
Get the device that created this encoder.
C++ equivalent: Device* device() const
Sourcepub fn command_buffer(&self) -> CommandBuffer
pub fn command_buffer(&self) -> CommandBuffer
Get the command buffer that this encoder is encoding into.
C++ equivalent: CommandBuffer* commandBuffer() const
Sourcepub fn label(&self) -> Option<String>
pub fn label(&self) -> Option<String>
Get the label for this encoder.
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 encoder.
C++ equivalent: void setLabel(const NS::String*)
Sourcepub fn end_encoding(&self)
pub fn end_encoding(&self)
End encoding commands with this encoder.
C++ equivalent: void endEncoding()
Sourcepub fn insert_debug_signpost(&self, string: &str)
pub fn insert_debug_signpost(&self, string: &str)
Insert a debug signpost.
C++ equivalent: void insertDebugSignpost(const NS::String*)
Sourcepub fn push_debug_group(&self, string: &str)
pub fn push_debug_group(&self, string: &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 the current debug group.
C++ equivalent: void popDebugGroup()
Sourcepub fn barrier_after_queue_stages(
&self,
after_stages: Stages,
before_stages: Stages,
)
pub fn barrier_after_queue_stages( &self, after_stages: Stages, before_stages: Stages, )
Insert a barrier to synchronize queue stages.
C++ equivalent: void barrierAfterQueueStages(Stages, Stages)