Skip to main content

ComputeCommandEncoder

Struct ComputeCommandEncoder 

Source
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

Source

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.

Source

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)

Source

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.

Source

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.

Source

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.

Source

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

Source

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)

Source

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)

Source

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)

Source

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)

Source

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)

Source

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)

Source

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.

Source

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.

Source

pub fn set_texture(&self, texture: &Texture, index: UInteger)

Set a texture at an index.

C++ equivalent: void setTexture(const Texture*, NS::UInteger)

Source

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.

Source

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)

Source

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)

Source

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.

Source

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.

Source

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)

Source

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

Source

pub fn set_stage_in_region(&self, region: Region)

Set the stage-in region.

C++ equivalent: void setStageInRegion(MTL::Region)

Source

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)

Source

pub fn dispatch_threadgroups( &self, threadgroups_per_grid: Size, threads_per_threadgroup: Size, )

Dispatch threadgroups.

C++ equivalent: void dispatchThreadgroups(MTL::Size, MTL::Size)

Source

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)

Source

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

Source

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.

Source

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

pub unsafe fn sample_counters_in_buffer_ptr( &self, sample_buffer: *const c_void, sample_index: UInteger, barrier: bool, )

Sample counters (raw pointer version).

C++ equivalent: void sampleCountersInBuffer(...)

§Safety

The sample buffer pointer must be a valid counter sample buffer object.

Source§

impl ComputeCommandEncoder

Source

pub fn memory_barrier_with_scope(&self, scope: BarrierScope)

Insert a memory barrier with scope.

C++ equivalent: void memoryBarrier(MTL::BarrierScope)

Source

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.

Source

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.

Source

pub fn use_buffer(&self, buffer: &Buffer, usage: ResourceUsage)

Declare that a buffer will be used.

C++ equivalent: void useResource(const Resource*, MTL::ResourceUsage)

Source

pub fn use_texture(&self, texture: &Texture, usage: ResourceUsage)

Declare that a texture will be used.

C++ equivalent: void useResource(const Resource*, MTL::ResourceUsage)

Source

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.

Source

pub fn use_heap(&self, heap: &Heap)

Declare that a heap will be used.

C++ equivalent: void useHeap(const Heap*)

Source

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.

Source

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.

Source

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.

Source

pub fn update_fence(&self, fence: &Fence)

Update a fence.

C++ equivalent: void updateFence(const Fence*)

Source

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.

Source

pub fn wait_for_fence(&self, fence: &Fence)

Wait for a fence.

C++ equivalent: void waitForFence(const Fence*)

Source§

impl ComputeCommandEncoder

Source

pub fn set_compute_pipeline_state(&self, state: &ComputePipelineState)

Set the compute pipeline state.

C++ equivalent: void setComputePipelineState(const ComputePipelineState*)

Source

pub fn dispatch_type(&self) -> DispatchType

Get the dispatch type for this encoder.

C++ equivalent: DispatchType dispatchType() const

Source§

impl ComputeCommandEncoder

Source

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.

Source

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

Get the raw pointer to the encoder.

Source

pub fn device(&self) -> Device

Get the device that created this encoder.

C++ equivalent: Device* device() const

Source

pub fn command_buffer(&self) -> CommandBuffer

Get the command buffer that this encoder is encoding into.

C++ equivalent: CommandBuffer* commandBuffer() const

Source

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

Get the label for this encoder.

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

Source

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

Set the label for this encoder.

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

Source

pub fn end_encoding(&self)

End encoding commands with this encoder.

C++ equivalent: void endEncoding()

Source

pub fn insert_debug_signpost(&self, string: &str)

Insert a debug signpost.

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

Source

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

Push a debug group.

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

Source

pub fn pop_debug_group(&self)

Pop the current debug group.

C++ equivalent: void popDebugGroup()

Source

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)

Trait Implementations§

Source§

impl Clone for ComputeCommandEncoder

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 ComputeCommandEncoder

Source§

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

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

impl Drop for ComputeCommandEncoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Referencing for ComputeCommandEncoder

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 ComputeCommandEncoder

Source§

impl Sync for ComputeCommandEncoder

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.