pub unsafe trait MTL4ComputeCommandEncoder: MTL4CommandEncoder {
Show 36 methods
// Provided methods
fn stages(&self) -> MTLStages
where Self: Sized + Message { ... }
fn setComputePipelineState(
&self,
state: &ProtocolObject<dyn MTLComputePipelineState>,
)
where Self: Sized + Message { ... }
unsafe fn setThreadgroupMemoryLength_atIndex(
&self,
length: NSUInteger,
index: NSUInteger,
)
where Self: Sized + Message { ... }
fn setImageblockWidth_height(&self, width: NSUInteger, height: NSUInteger)
where Self: Sized + Message { ... }
fn dispatchThreads_threadsPerThreadgroup(
&self,
threads_per_grid: MTLSize,
threads_per_threadgroup: MTLSize,
)
where Self: Sized + Message { ... }
fn dispatchThreadgroups_threadsPerThreadgroup(
&self,
threadgroups_per_grid: MTLSize,
threads_per_threadgroup: MTLSize,
)
where Self: Sized + Message { ... }
unsafe fn dispatchThreadgroupsWithIndirectBuffer_threadsPerThreadgroup(
&self,
indirect_buffer: MTLGPUAddress,
threads_per_threadgroup: MTLSize,
)
where Self: Sized + Message { ... }
fn dispatchThreadsWithIndirectBuffer(&self, indirect_buffer: MTLGPUAddress)
where Self: Sized + Message { ... }
unsafe fn executeCommandsInBuffer_withRange(
&self,
indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
execution_range: NSRange,
)
where Self: Sized + Message { ... }
unsafe fn executeCommandsInBuffer_indirectBuffer(
&self,
indirect_commandbuffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
indirect_range_buffer: MTLGPUAddress,
)
where Self: Sized + Message { ... }
unsafe fn copyFromTexture_toTexture(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
destination_texture: &ProtocolObject<dyn MTLTexture>,
)
where Self: Sized + Message { ... }
unsafe fn copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
slice_count: NSUInteger,
level_count: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
source_origin: MTLOrigin,
source_size: MTLSize,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
destination_origin: MTLOrigin,
)
where Self: Sized + Message { ... }
unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
source_origin: MTLOrigin,
source_size: MTLSize,
destination_buffer: &ProtocolObject<dyn MTLBuffer>,
destination_offset: NSUInteger,
destination_bytes_per_row: NSUInteger,
destination_bytes_per_image: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
source_origin: MTLOrigin,
source_size: MTLSize,
destination_buffer: &ProtocolObject<dyn MTLBuffer>,
destination_offset: NSUInteger,
destination_bytes_per_row: NSUInteger,
destination_bytes_per_image: NSUInteger,
options: MTLBlitOption,
)
where Self: Sized + Message { ... }
unsafe fn copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size(
&self,
source_buffer: &ProtocolObject<dyn MTLBuffer>,
source_offset: NSUInteger,
destination_buffer: &ProtocolObject<dyn MTLBuffer>,
destination_offset: NSUInteger,
size: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
&self,
source_buffer: &ProtocolObject<dyn MTLBuffer>,
source_offset: NSUInteger,
source_bytes_per_row: NSUInteger,
source_bytes_per_image: NSUInteger,
source_size: MTLSize,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
destination_origin: MTLOrigin,
)
where Self: Sized + Message { ... }
unsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options(
&self,
source_buffer: &ProtocolObject<dyn MTLBuffer>,
source_offset: NSUInteger,
source_bytes_per_row: NSUInteger,
source_bytes_per_image: NSUInteger,
source_size: MTLSize,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
destination_origin: MTLOrigin,
options: MTLBlitOption,
)
where Self: Sized + Message { ... }
unsafe fn copyFromTensor_sourceOrigin_sourceDimensions_toTensor_destinationOrigin_destinationDimensions(
&self,
source_tensor: &ProtocolObject<dyn MTLTensor>,
source_origin: &MTLTensorExtents,
source_dimensions: &MTLTensorExtents,
destination_tensor: &ProtocolObject<dyn MTLTensor>,
destination_origin: &MTLTensorExtents,
destination_dimensions: &MTLTensorExtents,
)
where Self: Sized + Message { ... }
unsafe fn generateMipmapsForTexture(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
)
where Self: Sized + Message { ... }
unsafe fn fillBuffer_range_value(
&self,
buffer: &ProtocolObject<dyn MTLBuffer>,
range: NSRange,
value: u8,
)
where Self: Sized + Message { ... }
unsafe fn optimizeContentsForGPUAccess(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
)
where Self: Sized + Message { ... }
unsafe fn optimizeContentsForGPUAccess_slice_level(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
slice: NSUInteger,
level: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn optimizeContentsForCPUAccess(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
)
where Self: Sized + Message { ... }
unsafe fn optimizeContentsForCPUAccess_slice_level(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
slice: NSUInteger,
level: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn resetCommandsInBuffer_withRange(
&self,
buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
range: NSRange,
)
where Self: Sized + Message { ... }
unsafe fn copyIndirectCommandBuffer_sourceRange_destination_destinationIndex(
&self,
source: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
source_range: NSRange,
destination: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
destination_index: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn optimizeIndirectCommandBuffer_withRange(
&self,
indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
range: NSRange,
)
where Self: Sized + Message { ... }
fn setArgumentTable(
&self,
argument_table: Option<&ProtocolObject<dyn MTL4ArgumentTable>>,
)
where Self: Sized + Message { ... }
unsafe fn buildAccelerationStructure_descriptor_scratchBuffer(
&self,
acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
descriptor: &MTL4AccelerationStructureDescriptor,
scratch_buffer: MTL4BufferRange,
)
where Self: Sized + Message { ... }
unsafe fn refitAccelerationStructure_descriptor_destination_scratchBuffer(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
descriptor: &MTL4AccelerationStructureDescriptor,
destination_acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>,
scratch_buffer: MTL4BufferRange,
)
where Self: Sized + Message { ... }
unsafe fn refitAccelerationStructure_descriptor_destination_scratchBuffer_options(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
descriptor: &MTL4AccelerationStructureDescriptor,
destination_acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>,
scratch_buffer: MTL4BufferRange,
options: MTLAccelerationStructureRefitOptions,
)
where Self: Sized + Message { ... }
unsafe fn copyAccelerationStructure_toAccelerationStructure(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
destination_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
)
where Self: Sized + Message { ... }
unsafe fn writeCompactedAccelerationStructureSize_toBuffer(
&self,
acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
buffer: MTL4BufferRange,
)
where Self: Sized + Message { ... }
unsafe fn copyAndCompactAccelerationStructure_toAccelerationStructure(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
destination_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
)
where Self: Sized + Message { ... }
unsafe fn writeTimestampWithGranularity_intoHeap_atIndex(
&self,
granularity: MTL4TimestampGranularity,
counter_heap: &ProtocolObject<dyn MTL4CounterHeap>,
index: NSUInteger,
)
where Self: Sized + Message { ... }
}MTL4CommandEncoder and MTL4ComputeCommandEncoder only.Expand description
Encodes a compute pass and other memory operations into a command buffer.
Use instances of this abstraction to encode a compute pass into MTL4CommandBuffer instances, as well as commands
that copy and modify the underlying memory of various Metal resources, and commands that build or refit acceleration
structures.
See also Apple’s documentation
Provided Methods§
Sourcefn stages(&self) -> MTLStages
Available on crate feature MTLCommandEncoder only.
fn stages(&self) -> MTLStages
MTLCommandEncoder only.Queries a bitmask representing the shader stages on which commands currently present in this command encoder operate.
Metal dynamically updates this property based on the commands you encode into the command encoder, for example,
it sets the bit MTLStages/MTLStageDispatch if this encoder contains any commands that dispatch a compute kernel.
Similarly, it sets the bit MTLStages/MTLStageBlit if this encoder contains any commands to copy or modify buffers,
textures, or indirect command buffers.
Finally, Metal sets the bit MTLStages/MTLStageAccelerationStructure if this encoder contains any commands that
build, copy, or refit acceleration structures.
- Returns: a bitmask representing shader stages that commands currently present in this command encoder operate on.
Sourcefn setComputePipelineState(
&self,
state: &ProtocolObject<dyn MTLComputePipelineState>,
)
Available on crate features MTLAllocation and MTLComputePipeline only.
fn setComputePipelineState( &self, state: &ProtocolObject<dyn MTLComputePipelineState>, )
MTLAllocation and MTLComputePipeline only.Configures this encoder with a compute pipeline state that applies to your subsequent dispatch commands.
- Parameter state: a non-
nilMTLComputePipelineState.
Sourceunsafe fn setThreadgroupMemoryLength_atIndex(
&self,
length: NSUInteger,
index: NSUInteger,
)
unsafe fn setThreadgroupMemoryLength_atIndex( &self, length: NSUInteger, index: NSUInteger, )
Configures the size of a threadgroup memory buffer for a threadgroup argument in the compute shader function.
- Parameters:
- length: The size of the threadgroup memory, in bytes. Use a multiple of
16bytes. - index: An integer that corresponds to the index of the argument you annotate with attribute
[[threadgroup(index)]]in the shader function.
§Safety
index might not be bounds-checked.
Sourcefn setImageblockWidth_height(&self, width: NSUInteger, height: NSUInteger)
fn setImageblockWidth_height(&self, width: NSUInteger, height: NSUInteger)
Specifies the size, in pixels, of imageblock data in tile memory.
- Parameters:
- width: The width of the imageblock, in pixels.
- height: The height of the imageblock, in pixels.
Sourcefn dispatchThreads_threadsPerThreadgroup(
&self,
threads_per_grid: MTLSize,
threads_per_threadgroup: MTLSize,
)
Available on crate feature MTLTypes only.
fn dispatchThreads_threadsPerThreadgroup( &self, threads_per_grid: MTLSize, threads_per_threadgroup: MTLSize, )
MTLTypes only.Encodes a compute dispatch command using an arbitrarily-sized grid.
- Parameters:
- threadsPerGrid: An
MTLSizeinstance that represents the number of threads in the grid, in each dimension. - threadsPerThreadgroup: An
MTLSizeinstance that represents the number of threads in one threadgroup, in each dimension.
Sourcefn dispatchThreadgroups_threadsPerThreadgroup(
&self,
threadgroups_per_grid: MTLSize,
threads_per_threadgroup: MTLSize,
)
Available on crate feature MTLTypes only.
fn dispatchThreadgroups_threadsPerThreadgroup( &self, threadgroups_per_grid: MTLSize, threads_per_threadgroup: MTLSize, )
MTLTypes only.Encodes a compute dispatch command with a grid that aligns to threadgroup boundaries.
- Parameters:
- threadgroupsPerGrid: An
MTLSizeinstance that represents the number of threadgroups in the grid, in each dimension. - threadsPerThreadgroup: An
MTLSizeinstance that represents the number of threads in one threadgroup, in each dimension.
Sourceunsafe fn dispatchThreadgroupsWithIndirectBuffer_threadsPerThreadgroup(
&self,
indirect_buffer: MTLGPUAddress,
threads_per_threadgroup: MTLSize,
)
Available on crate features MTLGPUAddress and MTLTypes only.
unsafe fn dispatchThreadgroupsWithIndirectBuffer_threadsPerThreadgroup( &self, indirect_buffer: MTLGPUAddress, threads_per_threadgroup: MTLSize, )
MTLGPUAddress and MTLTypes only.Encodes a compute dispatch command with a grid that aligns to threadgroup boundaries, using an indirect buffer for arguments.
This method allows you to supply the threadgroups-per-grid counts indirectly via an MTLBuffer index. This
enables you to calculate this value in the GPU timeline from a shader function, enabling GPU-driven workflows.
Metal assumes that the buffer contents correspond to the layout of struct MTLDispatchThreadgroupsIndirectArguments.
You are responsible for ensuring this address aligns to 4-bytes.
Use an instance of MTLResidencySet to mark residency of the indirect buffer that the indirectBuffer
parameter references.
- Parameters:
- indirectBuffer: GPUAddress of a
MTLBufferinstance providing compute parameters. Lay out the data in this buffer as described in theMTLDispatchThreadgroupsIndirectArgumentsstructure. This address requires 4-byte alignment. - threadsPerThreadgroup: A
MTLSizeinstance that represents the number of threads in one threadgroup, in each dimension.
Sourcefn dispatchThreadsWithIndirectBuffer(&self, indirect_buffer: MTLGPUAddress)
Available on crate feature MTLGPUAddress only.
fn dispatchThreadsWithIndirectBuffer(&self, indirect_buffer: MTLGPUAddress)
MTLGPUAddress only.Encodes a compute dispatch command with an arbitrarily sized grid, using an indirect buffer for arguments.
- Parameters:
- indirectBuffer: GPUAddress of a
MTLBufferinstance providing arguments. Lay out the data in this buffer as described in theMTLDispatchThreadsIndirectArgumentsstructure. This address requires 4-byte alignment.
Sourceunsafe fn executeCommandsInBuffer_withRange(
&self,
indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
execution_range: NSRange,
)
Available on crate features MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.
unsafe fn executeCommandsInBuffer_withRange( &self, indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>, execution_range: NSRange, )
MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.Encodes a command to execute a series of commands from an indirect command buffer.
- Parameters:
- indirectCommandBuffer:
MTLIndirectCommandBufferinstance containing the commands to execute. - executionRange: The range of commands to execute.
§Safety
indirect_command_buffermay need to be synchronized.indirect_command_buffermay be unretained, you must ensure it is kept alive while in use.executionRangemight not be bounds-checked.
Sourceunsafe fn executeCommandsInBuffer_indirectBuffer(
&self,
indirect_commandbuffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
indirect_range_buffer: MTLGPUAddress,
)
Available on crate features MTLAllocation and MTLGPUAddress and MTLIndirectCommandBuffer and MTLResource only.
unsafe fn executeCommandsInBuffer_indirectBuffer( &self, indirect_commandbuffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>, indirect_range_buffer: MTLGPUAddress, )
MTLAllocation and MTLGPUAddress and MTLIndirectCommandBuffer and MTLResource only.Encodes an instruction to execute commands from an indirect command buffer, using an indirect buffer for arguments.
Use an instance of MTLResidencySet to mark residency of the indirect buffer that the indirectRangeBuffer
parameter references.
- Parameters:
- indirectCommandbuffer:
MTLIndirectCommandBufferinstance containing the commands to execute. - indirectRangeBuffer: GPUAddress of a
MTLBuffercontaining the execution range. Lay out the data in this buffer as described in theMTLIndirectCommandBufferExecutionRangestructure. This address requires 4-byte alignment.
§Safety
indirect_commandbuffermay need to be synchronized.indirect_commandbuffermay be unretained, you must ensure it is kept alive while in use.indirectRangeBuffermight not be bounds-checked.
Sourceunsafe fn copyFromTexture_toTexture(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
destination_texture: &ProtocolObject<dyn MTLTexture>,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn copyFromTexture_toTexture( &self, source_texture: &ProtocolObject<dyn MTLTexture>, destination_texture: &ProtocolObject<dyn MTLTexture>, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that copies data from a texture to another.
- Parameters:
- sourceTexture: An
MTLTextureinstance the command copies data from. - destinationTexture: Another
MTLTextureinstance the command copies the data into that has the sameMTLTexture/pixelFormatandMTLTexture/sampleCountassourceTexture.
§Safety
source_texturemay need to be synchronized.source_texturemay be unretained, you must ensure it is kept alive while in use.destination_texturemay need to be synchronized.destination_texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
slice_count: NSUInteger,
level_count: NSUInteger,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount( &self, source_texture: &ProtocolObject<dyn MTLTexture>, source_slice: NSUInteger, source_level: NSUInteger, destination_texture: &ProtocolObject<dyn MTLTexture>, destination_slice: NSUInteger, destination_level: NSUInteger, slice_count: NSUInteger, level_count: NSUInteger, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that copies slices of a texture to slices of another texture.
- Parameters:
- sourceTexture: A
MTLTexturetexture that the command copies data from. To read the source texture contents, you need to set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false> prior to drawing into it. - sourceSlice: A slice within
sourceTexturethe command uses as a starting point to copy data from. Set this to0ifsourceTextureisn’t a texture array or a cube texture. - sourceLevel: A mipmap level within
sourceTexture. - destinationTexture: Another
MTLTexturethe command copies the data to that has the sameMTLTexture/pixelFormatandMTLTexture/sampleCountassourceTexture. To write the contents into this texture, you need to set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false>. - destinationSlice: A slice within
destinationTexturethe command uses as its starting point for copying data to. Set this to0ifdestinationTextureisn’t a texture array or a cube texture. - destinationLevel: A mipmap level within
destinationTexture. The mipmap level you reference needs to have the same size as thesourceTextureslice’s mipmap atsourceLevel. - sliceCount: The number of slices the command copies so that it satisfies the conditions
that the sum of
sourceSliceandsliceCountdoesn’t exceed the number of slices insourceTextureand the sum ofdestinationSliceandsliceCountdoesn’t exceed the number of slices indestinationTexture. - levelCount: The number of mipmap levels the command copies so that it satisfies the
conditions that the sum of
sourceLevelandlevelCountdoesn’t exceed the number of mipmap levels insourceTextureand the sum ofdestinationLevelandlevelCountdoesn’t exceed the number of mipmap levels indestinationTexture.
§Safety
source_texturemay need to be synchronized.source_texturemay be unretained, you must ensure it is kept alive while in use.destination_texturemay need to be synchronized.destination_texturemay be unretained, you must ensure it is kept alive while in use.sliceCountmight not be bounds-checked.levelCountmight not be bounds-checked.
Sourceunsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
source_origin: MTLOrigin,
source_size: MTLSize,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
destination_origin: MTLOrigin,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture and MTLTypes only.
unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin( &self, source_texture: &ProtocolObject<dyn MTLTexture>, source_slice: NSUInteger, source_level: NSUInteger, source_origin: MTLOrigin, source_size: MTLSize, destination_texture: &ProtocolObject<dyn MTLTexture>, destination_slice: NSUInteger, destination_level: NSUInteger, destination_origin: MTLOrigin, )
MTLAllocation and MTLResource and MTLTexture and MTLTypes only.Encodes a command that copies image data from a slice of a texture into a slice of another texture.
- Parameters:
- sourceTexture: An
MTLTexturetexture that the command copies data from. To read the source texture contents, you need to set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false> prior to drawing into it. - sourceSlice: A slice within
sourceTexturethe command uses as a starting point to copy data from. Set this to0ifsourceTextureisn’t a texture array or a cube texture. - sourceLevel: A mipmap level within
sourceTexture. - sourceOrigin: An
MTLOrigininstance that represents a location withinsourceTexturethat the command begins copying data from. Assign0to each dimension that’s not relevant tosourceTexture. - sourceSize: An
MTLSizeinstance that represents the size of the region, in pixels, that the command copies fromsourceTexture, starting atsourceOrigin. Assign1to each dimension that’s not relevant tosourceTexture. If sourceTexture uses a compressed pixel format, setsourceSizeto a multiple of the pixel format’s block size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationTexture: Another
MTLTexturethe command copies the data to that has the sameMTLTexture/pixelFormatandMTLTexture/sampleCountassourceTexture. To write the contents into this texture, you need to set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false>. - destinationSlice: A slice within
destinationTexturethe command uses as its starting point for copying data to. Set this to0ifdestinationTextureisn’t a texture array or a cube texture. - destinationLevel: A mipmap level within
destinationTexture. The mipmap level you reference needs to have the same size as thesourceTextureslice’s mipmap atsourceLevel. - destinationOrigin: An
MTLOrigininstance that represents a location withindestinationTexturethat the command begins copying data to. Assign0to each dimension that’s not relevant todestinationTexture.
§Safety
source_texturemay need to be synchronized.source_texturemay be unretained, you must ensure it is kept alive while in use.sourceSizemight not be bounds-checked.destination_texturemay need to be synchronized.destination_texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
source_origin: MTLOrigin,
source_size: MTLSize,
destination_buffer: &ProtocolObject<dyn MTLBuffer>,
destination_offset: NSUInteger,
destination_bytes_per_row: NSUInteger,
destination_bytes_per_image: NSUInteger,
)
Available on crate features MTLAllocation and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.
unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage( &self, source_texture: &ProtocolObject<dyn MTLTexture>, source_slice: NSUInteger, source_level: NSUInteger, source_origin: MTLOrigin, source_size: MTLSize, destination_buffer: &ProtocolObject<dyn MTLBuffer>, destination_offset: NSUInteger, destination_bytes_per_row: NSUInteger, destination_bytes_per_image: NSUInteger, )
MTLAllocation and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.Encodes a command that copies image data from a slice of an MTLTexture instance to an MTLBuffer instance.
- Parameters:
- sourceTexture: An
MTLTexturetexture that the command copies data from. To read the source texture contents, you need to set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false> prior to drawing into it. - sourceSlice: A slice within
sourceTexturethe command uses as a starting point to copy data from. Set this to0ifsourceTextureisn’t a texture array or a cube texture. - sourceLevel: A mipmap level within
sourceTexture. - sourceOrigin: An
MTLOrigininstance that represents a location withinsourceTexturethat the command begins copying data from. Assign0to each dimension that’s not relevant tosourceTexture. - sourceSize: An
MTLSizeinstance that represents the size of the region, in pixels, that the command copies fromsourceTexture, starting atsourceOrigin. Assign1to each dimension that’s not relevant tosourceTexture. IfsourceTextureuses a compressed pixel format, setsourceSizeto a multiple of thesourceTexture'sMTLTexture/pixelFormatblock size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationBuffer: An
MTLBufferinstance the command copies data to. - destinationOffset: A byte offset within
destinationBufferthe command copies to. The value you provide as this argument needs to be a multiple ofsourceTexture'spixel size, in bytes. - destinationBytesPerRow: The number of bytes between adjacent rows of pixels in
destinationBuffer. This value must be a multiple ofsourceTexture'spixel size, in bytes, and less than or equal to the product ofsourceTexture'spixel size, in bytes, and the largest pixel widthsourceTexture’stype allows. IfsourceTextureuses a compressed pixel format, setdestinationBytesPerRowto the number of bytes between the starts of two row blocks. - destinationBytesPerImage: The number of bytes between each 2D image of a 3D texture. This value must
be a multiple of
sourceTexture'spixel size, in bytes. Set this value to0ifsourceSize'sMTLSize/depthvalue is1.
§Safety
source_texturemay need to be synchronized.source_texturemay be unretained, you must ensure it is kept alive while in use.sourceSizemight not be bounds-checked.destination_buffermay need to be synchronized.destination_buffermay be unretained, you must ensure it is kept alive while in use.destination_buffercontents should be of the correct type.destinationOffsetmight not be bounds-checked.
Sourceunsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options(
&self,
source_texture: &ProtocolObject<dyn MTLTexture>,
source_slice: NSUInteger,
source_level: NSUInteger,
source_origin: MTLOrigin,
source_size: MTLSize,
destination_buffer: &ProtocolObject<dyn MTLBuffer>,
destination_offset: NSUInteger,
destination_bytes_per_row: NSUInteger,
destination_bytes_per_image: NSUInteger,
options: MTLBlitOption,
)
Available on crate features MTLAllocation and MTLBlitCommandEncoder and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.
unsafe fn copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options( &self, source_texture: &ProtocolObject<dyn MTLTexture>, source_slice: NSUInteger, source_level: NSUInteger, source_origin: MTLOrigin, source_size: MTLSize, destination_buffer: &ProtocolObject<dyn MTLBuffer>, destination_offset: NSUInteger, destination_bytes_per_row: NSUInteger, destination_bytes_per_image: NSUInteger, options: MTLBlitOption, )
MTLAllocation and MTLBlitCommandEncoder and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.Encodes a command that copies image data from a slice of a texture instance to a buffer, with options for special texture formats.
- Parameters:
- sourceTexture: An
MTLTexturetexture that the command copies data from. To read the source texture contents, you need to set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false> prior to drawing into it. - sourceSlice: A slice within
sourceTexturethe command uses as a starting point to copy data from. Set this to0ifsourceTextureisn’t a texture array or a cube texture. - sourceLevel: A mipmap level within
sourceTexture. - sourceOrigin: An
MTLOrigininstance that represents a location withinsourceTexturethat the command begins copying data from. Assign0to each dimension that’s not relevant tosourceTexture. - sourceSize: An
MTLSizeinstance that represents the size of the region, in pixels, that the command copies fromsourceTexture, starting atsourceOrigin. Assign1to each dimension that’s not relevant tosourceTexture. IfsourceTextureuses a compressed pixel format, setsourceSizeto a multiple of thesourceTexture'sMTLTexture/pixelFormatblock size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationBuffer: An
MTLBufferinstance the command copies data to. - destinationOffset: A byte offset within
destinationBufferthe command copies to. The value you provide as this argument needs to be a multiple ofsourceTexture'spixel size, in bytes. - destinationBytesPerRow: The number of bytes between adjacent rows of pixels in
destinationBuffer. This value must be a multiple ofsourceTexture'spixel size, in bytes, and less than or equal to the product ofsourceTexture'spixel size, in bytes, and the largest pixel widthsourceTexture’stype allows. IfsourceTextureuses a compressed pixel format, setdestinationBytesPerRowto the number of bytes between the starts of two row blocks. - destinationBytesPerImage: The number of bytes between each 2D image of a 3D texture. This value must
be a multiple of
sourceTexture'spixel size, in bytes. Set this value to0ifsourceSize'sMTLSize/depthvalue is1. - options: A
MTLBlitOptionvalue that applies to textures with applicable pixel formats, such as combined depth/stencil or PVRTC formats. IfsourceTexture'sMTLTexture/pixelFormatis a combined depth/stencil format, setoptionsto eitherMTLBlitOption/MTLBlitOptionDepthFromDepthStencilorMTLBlitOption/MTLBlitOptionStencilFromDepthStencil, but not both. IfsourceTexture'sMTLTexture/pixelFormatis a PVRTC format, setoptionstoMTLBlitOption/MTLBlitOptionRowLinearPVRTC.
§Safety
source_texturemay need to be synchronized.source_texturemay be unretained, you must ensure it is kept alive while in use.sourceSizemight not be bounds-checked.destination_buffermay need to be synchronized.destination_buffermay be unretained, you must ensure it is kept alive while in use.destination_buffercontents should be of the correct type.destinationOffsetmight not be bounds-checked.
Sourceunsafe fn copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size(
&self,
source_buffer: &ProtocolObject<dyn MTLBuffer>,
source_offset: NSUInteger,
destination_buffer: &ProtocolObject<dyn MTLBuffer>,
destination_offset: NSUInteger,
size: NSUInteger,
)
Available on crate features MTLAllocation and MTLBuffer and MTLResource only.
unsafe fn copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size( &self, source_buffer: &ProtocolObject<dyn MTLBuffer>, source_offset: NSUInteger, destination_buffer: &ProtocolObject<dyn MTLBuffer>, destination_offset: NSUInteger, size: NSUInteger, )
MTLAllocation and MTLBuffer and MTLResource only.Encodes a command that copies data from a buffer instance into another.
- Parameters:
- sourceBuffer: An
MTLBufferinstance the command copies data from. - sourceOffset: A byte offset within
sourceBufferthe command copies from. - destinationBuffer: An
MTLBufferinstance the command copies data to. - destinationOffset: A byte offset within
destinationBufferthe command copies to. - size: The number of bytes the command copies from
sourceBuffertodestinationBuffer.
§Safety
source_buffermay need to be synchronized.source_buffermay be unretained, you must ensure it is kept alive while in use.source_buffercontents should be of the correct type.sourceOffsetmight not be bounds-checked.destination_buffermay need to be synchronized.destination_buffermay be unretained, you must ensure it is kept alive while in use.destination_buffercontents should be of the correct type.destinationOffsetmight not be bounds-checked.sizemight not be bounds-checked.
Sourceunsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(
&self,
source_buffer: &ProtocolObject<dyn MTLBuffer>,
source_offset: NSUInteger,
source_bytes_per_row: NSUInteger,
source_bytes_per_image: NSUInteger,
source_size: MTLSize,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
destination_origin: MTLOrigin,
)
Available on crate features MTLAllocation and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.
unsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin( &self, source_buffer: &ProtocolObject<dyn MTLBuffer>, source_offset: NSUInteger, source_bytes_per_row: NSUInteger, source_bytes_per_image: NSUInteger, source_size: MTLSize, destination_texture: &ProtocolObject<dyn MTLTexture>, destination_slice: NSUInteger, destination_level: NSUInteger, destination_origin: MTLOrigin, )
MTLAllocation and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.Encodes a command to copy image data from a buffer instance into a texture.
- Parameters:
- sourceBuffer: A
MTLBufferinstance the command copies data from. - sourceOffset: A byte offset within
sourceBufferthe command copies from. Set this value to a multiple ofdestinationTexture'spixel size, in bytes. - sourceBytesPerRow: The number of bytes between adjacent rows of pixels in
sourceBuffer. Set this value to a multiple ofdestinationTexture'spixel size, in bytes, and less than or equal to the product ofdestinationTexture'spixel size, in bytes, and the largest pixel widthdestinationTexture'stype allows. IfdestinationTextureuses a compressed pixel format, setsourceBytesPerRowto the number of bytes between the starts of two row blocks. - sourceBytesPerImage: The number of bytes between each 2D image of a 3D texture. Set this value to a
multiple of
destinationTexture'spixel size, in bytes, or0ifsourceSize'sMTLSize/depthvalue is1. - sourceSize: A
MTLSizeinstance that represents the size of the region indestinationTexture, in pixels, that the command copies data to, starting atdestinationOrigin. Assign1to each dimension that’s not relevant todestinationTexture. IfdestinationTextureuses a compressed pixel format, setsourceSizeto a multiple ofdestinationTexture'sMTLTexture/pixelFormatblock size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationTexture: An
MTLTextureinstance the command copies data to. In order to copy the contents into the destination texture, set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false> and don’t use a combined depth/stencilMTLTexture/pixelFormat. - destinationSlice: A slice within
destinationTexturethe command uses as its starting point for copying data to. Set this to0ifdestinationTextureisn’t a texture array or a cube texture. - destinationLevel: A mipmap level within
destinationTexturethe command copies data to. - destinationOrigin: An
MTLOrigininstance that represents a location withindestinationTexturethat the command begins copying data to. Assign0to each dimension that’s not relevant todestinationTexture.
§Safety
source_buffermay need to be synchronized.source_buffermay be unretained, you must ensure it is kept alive while in use.source_buffercontents should be of the correct type.sourceOffsetmight not be bounds-checked.sourceSizemight not be bounds-checked.destination_texturemay need to be synchronized.destination_texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options(
&self,
source_buffer: &ProtocolObject<dyn MTLBuffer>,
source_offset: NSUInteger,
source_bytes_per_row: NSUInteger,
source_bytes_per_image: NSUInteger,
source_size: MTLSize,
destination_texture: &ProtocolObject<dyn MTLTexture>,
destination_slice: NSUInteger,
destination_level: NSUInteger,
destination_origin: MTLOrigin,
options: MTLBlitOption,
)
Available on crate features MTLAllocation and MTLBlitCommandEncoder and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.
unsafe fn copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options( &self, source_buffer: &ProtocolObject<dyn MTLBuffer>, source_offset: NSUInteger, source_bytes_per_row: NSUInteger, source_bytes_per_image: NSUInteger, source_size: MTLSize, destination_texture: &ProtocolObject<dyn MTLTexture>, destination_slice: NSUInteger, destination_level: NSUInteger, destination_origin: MTLOrigin, options: MTLBlitOption, )
MTLAllocation and MTLBlitCommandEncoder and MTLBuffer and MTLResource and MTLTexture and MTLTypes only.Encodes a command to copy image data from a buffer into a texture with options for special texture formats.
- Parameters:
- sourceBuffer: An
MTLBufferinstance the command copies data from. - sourceOffset: A byte offset within
sourceBufferthe command copies from. Set this value to a multiple ofdestinationTexture'spixel size, in bytes. - sourceBytesPerRow: The number of bytes between adjacent rows of pixels in
sourceBuffer. Set this value to a multiple ofdestinationTexture'spixel size, in bytes, and less than or equal to the product ofdestinationTexture'spixel size, in bytes, and the largest pixel widthdestinationTexture'stype allows. IfdestinationTextureuses a compressed pixel format, setsourceBytesPerRowto the number of bytes between the starts of two row blocks. - sourceBytesPerImage: The number of bytes between each 2D image of a 3D texture. Set this value to a
multiple of
destinationTexture'spixel size, in bytes, or0ifsourceSize'sMTLSize/depthvalue is1. - sourceSize: An
MTLSizeinstance that represents the size of the region indestinationTexture, in pixels, that the command copies data to, starting atdestinationOrigin. Assign1to each dimension that’s not relevant todestinationTexture. IfdestinationTextureuses a compressed pixel format, setsourceSizeto a multiple ofdestinationTexture'sMTLTexture/pixelFormatblock size. If the block extends outside the bounds of the texture, clampsourceSizeto the edge of the texture. - destinationTexture: An
MTLTextureinstance the command copies data to. In order to copy the contents into the destination texture, set itsMTLTexture/framebufferOnlyproperty to <doc ://com.apple.documentation/documentation/swift/false> and don’t use a combined depth/stencilMTLTexture/pixelFormat. - destinationSlice: A slice within
destinationTexturethe command uses as its starting point for copying data to. Set this to0ifdestinationTextureisn’t a texture array or a cube texture. - destinationLevel: A mipmap level within
destinationTexturethe command copies data to. - destinationOrigin: An
MTLOrigininstance that represents a location withindestinationTexturethat the command begins copying data to. Assign0to each dimension that’s not relevant todestinationTexture. - options: An
MTLBlitOptionvalue that applies to textures with applicable pixel formats, such as combined depth/stencil or PVRTC formats. IfdestinationTexture'sMTLTexture/pixelFormatis a combined depth/stencil format, setoptionsto eitherMTLBlitOption/MTLBlitOptionDepthFromDepthStencilorMTLBlitOption/MTLBlitOptionStencilFromDepthStencil, but not both. IfdestinationTexture'sMTLTexture/pixelFormatis a PVRTC format, setoptionstoMTLBlitOption/MTLBlitOptionRowLinearPVRTC.
§Safety
source_buffermay need to be synchronized.source_buffermay be unretained, you must ensure it is kept alive while in use.source_buffercontents should be of the correct type.sourceOffsetmight not be bounds-checked.sourceSizemight not be bounds-checked.destination_texturemay need to be synchronized.destination_texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn copyFromTensor_sourceOrigin_sourceDimensions_toTensor_destinationOrigin_destinationDimensions(
&self,
source_tensor: &ProtocolObject<dyn MTLTensor>,
source_origin: &MTLTensorExtents,
source_dimensions: &MTLTensorExtents,
destination_tensor: &ProtocolObject<dyn MTLTensor>,
destination_origin: &MTLTensorExtents,
destination_dimensions: &MTLTensorExtents,
)
Available on crate features MTLAllocation and MTLResource and MTLTensor only.
unsafe fn copyFromTensor_sourceOrigin_sourceDimensions_toTensor_destinationOrigin_destinationDimensions( &self, source_tensor: &ProtocolObject<dyn MTLTensor>, source_origin: &MTLTensorExtents, source_dimensions: &MTLTensorExtents, destination_tensor: &ProtocolObject<dyn MTLTensor>, destination_origin: &MTLTensorExtents, destination_dimensions: &MTLTensorExtents, )
MTLAllocation and MTLResource and MTLTensor only.Encodes a command to copy data from a tensor instance into another.
If the sourceTensor and destinationTensor instances are not aliasable, this command applies the correct reshapes
to enable this operation.
- Parameters:
- sourceTensor: An
MTLTensorinstance the command copies data from. - sourceSlice: The slice of
sourceTensorfrom which Metal copies data. - destinationTensor: An
MTLTensorinstance the command copies data to. - destinationSlice: The slice of
destinationTensorto which Metal copies data.
§Safety
source_tensormay need to be synchronized.source_tensormay be unretained, you must ensure it is kept alive while in use.destination_tensormay need to be synchronized.destination_tensormay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn generateMipmapsForTexture(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn generateMipmapsForTexture( &self, texture: &ProtocolObject<dyn MTLTexture>, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that generates mipmaps for a texture instance from the base mipmap level up to the highest mipmap level.
This method generates mipmaps for a mipmapped texture. The texture you provide needs to have a
MTLTexture/mipmapLevelCount greater than 1, and a color-renderable or color-filterable
MTLTexture/pixelFormat.
- Parameter texture: A mipmapped, color-renderable or color-filterable
MTLTextureinstance the command generates mipmaps for.
§Safety
texturemay need to be synchronized.texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn fillBuffer_range_value(
&self,
buffer: &ProtocolObject<dyn MTLBuffer>,
range: NSRange,
value: u8,
)
Available on crate features MTLAllocation and MTLBuffer and MTLResource only.
unsafe fn fillBuffer_range_value( &self, buffer: &ProtocolObject<dyn MTLBuffer>, range: NSRange, value: u8, )
MTLAllocation and MTLBuffer and MTLResource only.Encodes a command that fills a buffer with a constant value for each byte.
- Parameters:
- buffer: A
MTLBufferinstance for which this command assigns each byte in a range to a value. - range: A range of bytes within
bufferthe command assigns value to. When calling this method, pass in a range with a length greater than0. - value: The value to write to each byte.
§Safety
buffermay need to be synchronized.buffermay be unretained, you must ensure it is kept alive while in use.buffercontents should be of the correct type.rangemight not be bounds-checked.
Sourceunsafe fn optimizeContentsForGPUAccess(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn optimizeContentsForGPUAccess( &self, texture: &ProtocolObject<dyn MTLTexture>, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that modifies the contents of a texture to improve the performance of GPU accesses to its contents.
Optimizing a texture for GPU access may affect the performance of CPU accesses, however, the data the CPU retrieves from the texture remains consistent.
You typically run this command for:
- Textures the GPU accesses for an extended period of time.
- Textures with a
MTLTextureDescriptor/storageModeproperty that’sMTLStorageMode/MTLStorageModeSharedorMTLStorageMode/MTLStorageModeManaged.
- Parameter texture: A
MTLTextureinstance the command optimizes for GPU access.
§Safety
texturemay need to be synchronized.texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn optimizeContentsForGPUAccess_slice_level(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
slice: NSUInteger,
level: NSUInteger,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn optimizeContentsForGPUAccess_slice_level( &self, texture: &ProtocolObject<dyn MTLTexture>, slice: NSUInteger, level: NSUInteger, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that modifies the contents of a texture instance to improve the performance of GPU accesses to its contents in a specific region.
Optimizing a texture for GPU access may affect the performance of CPU accesses, however, the data the CPU retrieves from the texture remains consistent.
You typically run this command for:
- Textures the GPU accesses for an extended period of time.
- Textures with a
MTLTextureDescriptor/storageModeproperty that’sMTLStorageMode/MTLStorageModeSharedorMTLStorageMode/MTLStorageModeManaged.
- Parameters:
- texture: A
MTLTexturethe command optimizes for GPU access. - slice: A slice within
texture. - level: A mipmap level within
texture.
§Safety
texturemay need to be synchronized.texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn optimizeContentsForCPUAccess(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn optimizeContentsForCPUAccess( &self, texture: &ProtocolObject<dyn MTLTexture>, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that modifies the contents of a texture to improve the performance of CPU accesses to its contents.
Optimizing a texture for CPU access may affect the performance of GPU accesses, however, the data the GPU retrieves from the texture remains consistent.
You typically use this command for:
- Textures the CPU accesses for an extended period of time.
- Textures with a
MTLTextureDescriptor/storageModeproperty that’sMTLStorageMode/MTLStorageModeSharedorMTLStorageMode/MTLStorageModeManaged.
- Parameter texture: A
MTLTextureinstance the command optimizes for CPU access.
§Safety
texturemay need to be synchronized.texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn optimizeContentsForCPUAccess_slice_level(
&self,
texture: &ProtocolObject<dyn MTLTexture>,
slice: NSUInteger,
level: NSUInteger,
)
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
unsafe fn optimizeContentsForCPUAccess_slice_level( &self, texture: &ProtocolObject<dyn MTLTexture>, slice: NSUInteger, level: NSUInteger, )
MTLAllocation and MTLResource and MTLTexture only.Encodes a command that modifies the contents of a texture to improve the performance of CPU accesses to its contents in a specific region.
Optimizing a texture for CPU access may affect the performance of GPU accesses, however, the data the GPU retrieves from the texture remains consistent.
You typically use this command for:
- Textures the CPU accesses for an extended period of time.
- Textures with a
MTLTextureDescriptor/storageModeproperty that’sMTLStorageMode/MTLStorageModeSharedorMTLStorageMode/MTLStorageModeManaged.
- Parameters:
- texture: A
MTLTexturethe command optimizes for CPU access. - slice: A slice within
texture. - level: A mipmap level within
texture.
§Safety
texturemay need to be synchronized.texturemay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn resetCommandsInBuffer_withRange(
&self,
buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
range: NSRange,
)
Available on crate features MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.
unsafe fn resetCommandsInBuffer_withRange( &self, buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>, range: NSRange, )
MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.Encodes a command that resets a range of commands in an indirect command buffer.
- Parameters:
- buffer: An
MTLIndirectCommandBufferthe command resets. - range: A range of commands within
buffer.
§Safety
buffermay need to be synchronized.buffermay be unretained, you must ensure it is kept alive while in use.rangemight not be bounds-checked.
Sourceunsafe fn copyIndirectCommandBuffer_sourceRange_destination_destinationIndex(
&self,
source: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
source_range: NSRange,
destination: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
destination_index: NSUInteger,
)
Available on crate features MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.
unsafe fn copyIndirectCommandBuffer_sourceRange_destination_destinationIndex( &self, source: &ProtocolObject<dyn MTLIndirectCommandBuffer>, source_range: NSRange, destination: &ProtocolObject<dyn MTLIndirectCommandBuffer>, destination_index: NSUInteger, )
MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.Encodes a command that copies commands from an indirect command buffer into another.
- Parameters:
- source: An
MTLIndirectCommandBufferinstance from where the command copies. - sourceRange: The range of commands in
sourceto copy. The copy operation requires that the source range starts at a valid execution point. - destination: Another
MTLIndirectCommandBufferinstance into which the command copies. - destinationIndex: An index in
destinationinto where the command copies content to. The copy operation requires that the destination index is a valid execution point with enough space left indestinationto accommodatesourceRange.countcommands.
§Safety
sourcemay need to be synchronized.sourcemay be unretained, you must ensure it is kept alive while in use.sourceRangemight not be bounds-checked.destinationmay need to be synchronized.destinationmay be unretained, you must ensure it is kept alive while in use.destinationIndexmight not be bounds-checked.
Sourceunsafe fn optimizeIndirectCommandBuffer_withRange(
&self,
indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>,
range: NSRange,
)
Available on crate features MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.
unsafe fn optimizeIndirectCommandBuffer_withRange( &self, indirect_command_buffer: &ProtocolObject<dyn MTLIndirectCommandBuffer>, range: NSRange, )
MTLAllocation and MTLIndirectCommandBuffer and MTLResource only.Encode a command to attempt to improve the performance of a range of commands within an indirect command buffer.
- Parameters:
- indirectCommandBuffer: An
MTLIndirectCommandBufferinstance that this command optimizes. - range: A range of commands within
indirectCommandBuffer.
§Safety
indirect_command_buffermay need to be synchronized.indirect_command_buffermay be unretained, you must ensure it is kept alive while in use.rangemight not be bounds-checked.
Sourcefn setArgumentTable(
&self,
argument_table: Option<&ProtocolObject<dyn MTL4ArgumentTable>>,
)
Available on crate feature MTL4ArgumentTable only.
fn setArgumentTable( &self, argument_table: Option<&ProtocolObject<dyn MTL4ArgumentTable>>, )
MTL4ArgumentTable only.Sets an argument table for the compute shader stage of this pipeline.
Metal takes a snapshot of the resources in the argument table when you make dispatch or execute calls on this encoder instance. Metal makes the snapshot contents available to the compute shader function of the current pipeline state.
- Parameters:
- argumentTable: A
MTL4ArgumentTableto set on the command encoder.
Sourceunsafe fn buildAccelerationStructure_descriptor_scratchBuffer(
&self,
acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
descriptor: &MTL4AccelerationStructureDescriptor,
scratch_buffer: MTL4BufferRange,
)
Available on crate features MTL4AccelerationStructure and MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.
unsafe fn buildAccelerationStructure_descriptor_scratchBuffer( &self, acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, descriptor: &MTL4AccelerationStructureDescriptor, scratch_buffer: MTL4BufferRange, )
MTL4AccelerationStructure and MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.Encodes an acceleration structure build into the command buffer.
Before you build an instance acceleration structure, you are responsible for ensuring the build operations for all primitive acceleration structures is complete. The built acceleration structure doesn’t retain any references to the input buffers of the descriptor, such as the vertex buffer or instance buffer, among others.
The acceleration structure build process may continue as long as the command buffer is not completed. However, you can safely encode ray tracing work against the acceleration structure if you schedule and synchronize the command buffers that contain this ray tracing work such that the command buffer with the build command is complete by the time ray tracing starts.
You are responsible for ensuring that the acceleration structure and scratch buffer are at least the size
that the query MTLDevice/accelerationStructureSizesWithDescriptor: returns.
Use an instance of MTLResidencySet to mark residency of the scratch buffer the scratchBuffer parameter references,
as well as for all the primitive acceleration structures you directly and indirectly reference.
- Parameters:
- accelerationStructure: Acceleration structure storage to build into.
- descriptor: A descriptor for the acceleration structure Metal builds.
- scratchBuffer: Scratch buffer Metal can use while building the acceleration structure. Metal may overwrite the contents of this buffer, and you should consider them “undefined” after the refit operation starts and completes.
§Safety
acceleration_structuremay need to be synchronized.acceleration_structuremay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn refitAccelerationStructure_descriptor_destination_scratchBuffer(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
descriptor: &MTL4AccelerationStructureDescriptor,
destination_acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>,
scratch_buffer: MTL4BufferRange,
)
Available on crate features MTL4AccelerationStructure and MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.
unsafe fn refitAccelerationStructure_descriptor_destination_scratchBuffer( &self, source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, descriptor: &MTL4AccelerationStructureDescriptor, destination_acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>, scratch_buffer: MTL4BufferRange, )
MTL4AccelerationStructure and MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.Encodes an acceleration structure refit into the command buffer.
You refit an acceleration structure to update it when the geometry it references changes. This operation is typically much faster than rebuilding the acceleration structure from scratch. The trade off is that after you refit the acceleration structure, its quality, as well as the performance of any subsequent ray tracing operation degrades, depending on how much the geometry changes.
After certain operations, refitting an acceleration structure may not be possible, for example, after adding or removing geometry.
When you refit an acceleration structure, you can do so in place, by specifying the same source and destination
acceleration structures, or by providing a nil destination acceleration structure. If the source and destination
acceleration structures aren’t the same, then you are responsible for ensuring they don’t overlap in memory.
Typically, the destination acceleration structure is at least as large as the source acceleration structure, except in cases where you compact the source acceleration structure. In this case, you need to allocate the destination acceleration to be at least as large as the compacted size of the source acceleration structure.
The scratch buffer you provide for the refit operation needs to be at least as large as the size that the query
MTLDevice/accelerationStructureSizesWithDescriptor: returns. If the size this query returns is zero, you
can omit providing a scratch buffer by passing 0 as the address to the scratchBuffer parameter.
Use an instance of MTLResidencySet to mark residency of the scratch buffer the scratchBuffer parameter references,
as well as for all the instance and primitive acceleration structures you directly and indirectly reference.
- Parameters:
- sourceAccelerationStructure: Acceleration structure to refit.
- descriptor: A descriptor for the acceleration structure to refit.
- destinationAccelerationStructure: Acceleration structure to store the refit result into.
If
destinationAccelerationStructureisnil, Metal performs an in-place refit operation of thesourceAccelerationStructure. - scratchBuffer: Scratch buffer Metal can use while refitting the acceleration structure. Metal may overwrite the contents of this buffer, and you should consider them “undefined” after the refit operation starts and completes.
§Safety
source_acceleration_structuremay need to be synchronized.source_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.destination_acceleration_structuremay need to be synchronized.destination_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn refitAccelerationStructure_descriptor_destination_scratchBuffer_options(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
descriptor: &MTL4AccelerationStructureDescriptor,
destination_acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>,
scratch_buffer: MTL4BufferRange,
options: MTLAccelerationStructureRefitOptions,
)
Available on crate features MTL4AccelerationStructure and MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.
unsafe fn refitAccelerationStructure_descriptor_destination_scratchBuffer_options( &self, source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, descriptor: &MTL4AccelerationStructureDescriptor, destination_acceleration_structure: Option<&ProtocolObject<dyn MTLAccelerationStructure>>, scratch_buffer: MTL4BufferRange, options: MTLAccelerationStructureRefitOptions, )
MTL4AccelerationStructure and MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.Encodes an acceleration structure refit operation into the command buffer, providing additional options.
You refit an acceleration structure to update it when the geometry it references changes. This operation is typically much faster than rebuilding the acceleration structure from scratch. The trade off is that after you refit the acceleration structure, its quality, as well as the performance of any subsequent ray tracing operation degrades, depending on how much the geometry changes.
After certain operations, refitting an acceleration structure may not be possible, for example, after adding or removing geometry.
When you refit an acceleration structure, you can do so in place, by specifying the same source and destination
acceleration structures, or by providing a nil destination acceleration structure. If the source and destination
acceleration structures aren’t the same, then you are responsible for ensuring they don’t overlap in memory.
Typically, the destination acceleration structure is at least as large as the source acceleration structure, except in cases where you compact the source acceleration structure. In this case, you need to allocate the destination acceleration to be at least as large as the compacted size of the source acceleration structure.
The scratch buffer you provide for the refit operation needs to be at least as large as the size that the query
MTLDevice/accelerationStructureSizesWithDescriptor: returns. If the size this query returns is zero, you
can omit providing a scratch buffer by passing 0 as the address to the scratchBuffer parameter.
Use an instance of MTLResidencySet to mark residency of the scratch buffer the scratchBuffer parameter references,
as well as for all the instance and primitive acceleration structures you directly and indirectly reference.
- Parameters:
- sourceAccelerationStructure: Acceleration structure to refit.
- descriptor: A descriptor for the acceleration structure to refit.
- destinationAccelerationStructure: Acceleration structure to store the refit result into.
If
destinationAccelerationStructureisnil, Metal performs an in-place refit operation of thesourceAccelerationStructure. - scratchBuffer: Scratch buffer Metal can use while refitting the acceleration structure. Metal may overwrite the contents of this buffer, and you should consider them “undefined” after the refit operation starts and completes.
- options: Options specifying the elements of the acceleration structure to refit.
§Safety
source_acceleration_structuremay need to be synchronized.source_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.destination_acceleration_structuremay need to be synchronized.destination_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn copyAccelerationStructure_toAccelerationStructure(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
destination_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
)
Available on crate features MTLAccelerationStructure and MTLAllocation and MTLResource only.
unsafe fn copyAccelerationStructure_toAccelerationStructure( &self, source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, destination_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, )
MTLAccelerationStructure and MTLAllocation and MTLResource only.Encodes an acceleration structure copy operation into the command buffer.
You are responsible for ensuring the source and destination acceleration structures don’t overlap in memory. If this is an instance acceleration structure, Metal preserves references to the primitive acceleration structures it references.
Typically, the destination acceleration structure is at least as large as the source acceleration structure, except in cases where you compact the source acceleration structure. In this case, you need to allocate the destination acceleration to be at least as large as the compacted size of the source acceleration structure.
- Parameters:
- sourceAccelerationStructure: Acceleration structure to copy from.
- destinationAccelerationStructure: Acceleration structure to copy to.
§Safety
source_acceleration_structuremay need to be synchronized.source_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.destination_acceleration_structuremay need to be synchronized.destination_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn writeCompactedAccelerationStructureSize_toBuffer(
&self,
acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
buffer: MTL4BufferRange,
)
Available on crate features MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.
unsafe fn writeCompactedAccelerationStructureSize_toBuffer( &self, acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, buffer: MTL4BufferRange, )
MTL4BufferRange and MTLAccelerationStructure and MTLAllocation and MTLGPUAddress and MTLResource only.Encodes a command to compute the size an acceleration structure can compact into, writing the result into a buffer.
This size is potentially smaller than the acceleration structure. To perform compaction, you typically read
this size from the buffer once the command buffer completes. You then use it to allocate a new, potentially
smaller acceleration structure. Finally, you call the copyAndCompactAccelerationStructure:toAccelerationStructure:
method to perform the copy.
- Parameters:
- accelerationStructure: Source acceleration structure.
- buffer: Destination size buffer. Metal writes the compacted size as a 64-bit unsigned integer value, representing the compacted size in bytes.
§Safety
acceleration_structuremay need to be synchronized.acceleration_structuremay be unretained, you must ensure it is kept alive while in use.- This might not be bounds-checked.
Sourceunsafe fn copyAndCompactAccelerationStructure_toAccelerationStructure(
&self,
source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
destination_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>,
)
Available on crate features MTLAccelerationStructure and MTLAllocation and MTLResource only.
unsafe fn copyAndCompactAccelerationStructure_toAccelerationStructure( &self, source_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, destination_acceleration_structure: &ProtocolObject<dyn MTLAccelerationStructure>, )
MTLAccelerationStructure and MTLAllocation and MTLResource only.Encodes a command to copy and compact an acceleration structure.
You are responsible for ensuring that the source and destination acceleration structures don’t overlap in memory. If this is an instance acceleration structure, Metal preserves references to primitive acceleration structures it references.
This operation requires that the destination acceleration structure is at least as large as the compacted size of
the source acceleration structure. You can compute this size by calling the
writeCompactedAccelerationStructureSize:toBuffer: method.
- Parameters:
- sourceAccelerationStructure: Acceleration structure to copy and compact.
- destinationAccelerationStructure: Acceleration structure to copy to.
§Safety
source_acceleration_structuremay need to be synchronized.source_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.destination_acceleration_structuremay need to be synchronized.destination_acceleration_structuremay be unretained, you must ensure it is kept alive while in use.
Sourceunsafe fn writeTimestampWithGranularity_intoHeap_atIndex(
&self,
granularity: MTL4TimestampGranularity,
counter_heap: &ProtocolObject<dyn MTL4CounterHeap>,
index: NSUInteger,
)
Available on crate feature MTL4Counters only.
unsafe fn writeTimestampWithGranularity_intoHeap_atIndex( &self, granularity: MTL4TimestampGranularity, counter_heap: &ProtocolObject<dyn MTL4CounterHeap>, index: NSUInteger, )
MTL4Counters only.Writes a GPU timestamp into a heap.
The method ensures that any prior work finishes, but doesn’t delay any subsequent work.
You can alter this command’s behavior through the granularity parameter.
-
Pass
MTL4TimestampGranularity/MTL4TimestampGranularityRelaxedto allow Metal to provide timestamps with minimal impact to runtime performance, but with less detail. For example, the command may group all timestamps for a pass together. -
Pass
MTL4TimestampGranularity/MTL4TimestampGranularityPreciseto request that Metal provides timestamps with the most detail. This can affect runtime performance. -
Parameters:
-
granularity:
MTL4TimestampGranularityhint to Metal about acceptable the level of precision. -
counterHeap:
MTL4CounterHeapto write timestamps into. -
index: The index value into which Metal writes the timestamp.
§Safety
index might not be bounds-checked.