Interface MTLComputeCommandEncoder

  • All Superinterfaces:
    MTLCommandEncoder

    public interface MTLComputeCommandEncoder
    extends MTLCommandEncoder
    [@protocol] MTLComputeCommandEncoder A command encoder that writes data parallel compute commands.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void dispatchThreadgroupsThreadsPerThreadgroup​(MTLSize threadgroupsPerGrid, MTLSize threadsPerThreadgroup)
      dispatchThreadgroups:threadsPerThreadgroup: Enqueue a compute function dispatch as a multiple of the threadgroup size.
      void dispatchThreadgroupsWithIndirectBufferIndirectBufferOffsetThreadsPerThreadgroup​(MTLBuffer indirectBuffer, long indirectBufferOffset, MTLSize threadsPerThreadgroup)
      dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup: Enqueue a compute function dispatch using an indirect buffer for threadgroupsPerGrid see MTLDispatchThreadgroupsIndirectArguments.
      void dispatchThreadsThreadsPerThreadgroup​(MTLSize threadsPerGrid, MTLSize threadsPerThreadgroup)
      dispatchThreads:threadsPerThreadgroup: Enqueue a compute function dispatch using an arbitrarily-sized grid.
      long dispatchType()
      [@property] dispatchType The dispatch type of the compute command encoder.
      void executeCommandsInBufferIndirectBufferIndirectBufferOffset​(MTLIndirectCommandBuffer indirectCommandbuffer, MTLBuffer indirectRangeBuffer, long indirectBufferOffset)
      executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: Execute commands in the buffer within the range specified by the indirect range buffer.
      void executeCommandsInBufferWithRange​(MTLIndirectCommandBuffer indirectCommandBuffer, NSRange executionRange)
      executeCommandsInBuffer:withRange: Execute commands in the buffer within the range specified.
      void memoryBarrierWithResourcesCount​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> resources, long count)
      memoryBarrierWithResources Encodes a barrier between currently dispatched kernels in a concurrent compute command encoder and any subsequent ones on an array of resources.
      void memoryBarrierWithScope​(long scope)
      memoryBarrierWithScope Encodes a barrier between currently dispatched kernels in a concurrent compute command encoder and any subsequent ones on a specified resource group This API ensures that all dispatches in the encoder have completed execution and their side effects are visible to subsequent dispatches in that encoder.
      void sampleCountersInBufferAtSampleIndexWithBarrier​(MTLCounterSampleBuffer sampleBuffer, long sampleIndex, boolean barrier)
      sampleCountersInBuffer:atSampleIndex:withBarrier: Sample hardware counters at this point in the compute encoder and store the counter sample into the sample buffer at the specified index.
      void setAccelerationStructureAtBufferIndex​(MTLAccelerationStructure accelerationStructure, long bufferIndex)
      setAccelerationStructure:atBufferIndex: Set a global raytracing acceleration structure for all compute kernels at the given buffer bind point index.
      void setBufferOffsetAtIndex​(long offset, long index)
      setBufferOffset:atIndex: Set the offset within the current global buffer for all compute kernels at the given bind point index.
      void setBufferOffsetAtIndex​(MTLBuffer buffer, long offset, long index)
      setBuffer:offset:atIndex: Set a global buffer for all compute kernels at the given bind point index.
      void setBuffersOffsetsWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> buffers, org.moe.natj.general.ptr.ConstNUIntPtr offsets, NSRange range)
      setBuffers:offsets:withRange: Set an array of global buffers for all compute kernels with the given bind point range.
      void setBytesLengthAtIndex​(org.moe.natj.general.ptr.ConstVoidPtr bytes, long length, long index)
      setBytes:length:atIndex: Set the data (by copy) for a given buffer binding point.
      void setComputePipelineState​(MTLComputePipelineState state)
      setComputePipelineState: Set the compute pipeline state that will be used.
      void setImageblockWidthHeight​(long width, long height)
      setImageblockWidth:height: Set imageblock sizes.
      void setIntersectionFunctionTableAtBufferIndex​(MTLIntersectionFunctionTable intersectionFunctionTable, long bufferIndex)
      setIntersectionFunctionTable:atBufferIndex: Set a visible function table at the given buffer index
      void setIntersectionFunctionTablesWithBufferRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> intersectionFunctionTables, NSRange range)
      setIntersectionFunctionTables:withBufferRange: Set visible function tables at the given buffer index range
      void setSamplerStateAtIndex​(MTLSamplerState sampler, long index)
      setSamplerState:atIndex: Set a global sampler for all compute kernels at the given bind point index.
      void setSamplerStateLodMinClampLodMaxClampAtIndex​(MTLSamplerState sampler, float lodMinClamp, float lodMaxClamp, long index)
      setSamplerState:lodMinClamp:lodMaxClamp:atIndex: Set a global sampler for all compute kernels at the given bind point index.
      void setSamplerStatesLodMinClampsLodMaxClampsWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> samplers, org.moe.natj.general.ptr.ConstFloatPtr lodMinClamps, org.moe.natj.general.ptr.ConstFloatPtr lodMaxClamps, NSRange range)
      setSamplers:lodMinClamps:lodMaxClamps:withRange: Set an array of global samplers for all compute kernels with the given bind point range.
      void setSamplerStatesWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> samplers, NSRange range)
      setSamplers:withRange: Set an array of global samplers for all compute kernels with the given bind point range.
      void setStageInRegion​(MTLRegion region)
      setStageInRegion:region: Set the region of the stage_in attributes to apply the compute kernel.
      void setStageInRegionWithIndirectBufferIndirectBufferOffset​(MTLBuffer indirectBuffer, long indirectBufferOffset)
      setStageInRegionWithIndirectBuffer:indirectBufferOffset: sets the stage in region indirectly for the following indirect dispatch calls.
      void setTextureAtIndex​(MTLTexture texture, long index)
      setTexture:atIndex: Set a global texture for all compute kernels at the given bind point index.
      void setTexturesWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> textures, NSRange range)
      setTextures:withRange: Set an array of global textures for all compute kernels with the given bind point range.
      void setThreadgroupMemoryLengthAtIndex​(long length, long index)
      setThreadgroupMemoryLength:atIndex: Set the threadgroup memory byte length at the binding point specified by the index.
      void setVisibleFunctionTableAtBufferIndex​(MTLVisibleFunctionTable visibleFunctionTable, long bufferIndex)
      setVisibleFunctionTable:atBufferIndex: Set a visible function table at the given buffer index
      void setVisibleFunctionTablesWithBufferRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> visibleFunctionTables, NSRange range)
      setVisibleFunctionTables:withBufferRange: Set visible function tables at the given buffer index range
      void updateFence​(MTLFence fence)
      updateFence: Update the fence to capture all GPU work so far enqueued by this encoder.
      void useHeap​(MTLHeap heap)
      useHeap: Declare that the resources allocated from a heap may be accessed as readonly by the render pass through an argument buffer For tracked MTLHeaps, this method protects against data hazards.
      void useHeapsCount​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> heaps, long count)
      useHeaps:count: Declare that the resources allocated from an array of heaps may be accessed as readonly by the render pass through an argument buffer For tracked MTLHeaps, this method protects against data hazards.
      void useResourcesCountUsage​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> resources, long count, long usage)
      useResources:count:usage: Declare that an array of resources may be accessed through an argument buffer by the command encoder For tracked MTL Resources, this method protects against data hazards.
      void useResourceUsage​(MTLResource resource, long usage)
      useResource:usage: Declare that a resource may be accessed by the command encoder through an argument buffer For tracked MTLResources, this method protects against data hazards.
      void waitForFence​(MTLFence fence)
      waitForFence: Prevent further GPU work until the fence is reached.
    • Method Detail

      • dispatchThreadgroupsThreadsPerThreadgroup

        void dispatchThreadgroupsThreadsPerThreadgroup​(MTLSize threadgroupsPerGrid,
                                                       MTLSize threadsPerThreadgroup)
        dispatchThreadgroups:threadsPerThreadgroup: Enqueue a compute function dispatch as a multiple of the threadgroup size.
      • dispatchThreadgroupsWithIndirectBufferIndirectBufferOffsetThreadsPerThreadgroup

        void dispatchThreadgroupsWithIndirectBufferIndirectBufferOffsetThreadsPerThreadgroup​(MTLBuffer indirectBuffer,
                                                                                             long indirectBufferOffset,
                                                                                             MTLSize threadsPerThreadgroup)
        dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup: Enqueue a compute function dispatch using an indirect buffer for threadgroupsPerGrid see MTLDispatchThreadgroupsIndirectArguments.
        Parameters:
        indirectBuffer - A buffer object that the device will read dispatchThreadgroups arguments from, see MTLDispatchThreadgroupsIndirectArguments.
        indirectBufferOffset - Byte offset within @a indirectBuffer to read arguments from. @a indirectBufferOffset must be a multiple of 4.
      • setBufferOffsetAtIndex

        void setBufferOffsetAtIndex​(MTLBuffer buffer,
                                    long offset,
                                    long index)
        setBuffer:offset:atIndex: Set a global buffer for all compute kernels at the given bind point index.
      • setBufferOffsetAtIndex

        void setBufferOffsetAtIndex​(long offset,
                                    long index)
        setBufferOffset:atIndex: Set the offset within the current global buffer for all compute kernels at the given bind point index.
      • setBuffersOffsetsWithRange

        void setBuffersOffsetsWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> buffers,
                                        org.moe.natj.general.ptr.ConstNUIntPtr offsets,
                                        NSRange range)
        setBuffers:offsets:withRange: Set an array of global buffers for all compute kernels with the given bind point range.
      • setBytesLengthAtIndex

        void setBytesLengthAtIndex​(org.moe.natj.general.ptr.ConstVoidPtr bytes,
                                   long length,
                                   long index)
        setBytes:length:atIndex: Set the data (by copy) for a given buffer binding point. This will remove any existing MTLBuffer from the binding point.
      • setComputePipelineState

        void setComputePipelineState​(MTLComputePipelineState state)
        setComputePipelineState: Set the compute pipeline state that will be used.
      • setSamplerStateAtIndex

        void setSamplerStateAtIndex​(MTLSamplerState sampler,
                                    long index)
        setSamplerState:atIndex: Set a global sampler for all compute kernels at the given bind point index.
      • setSamplerStateLodMinClampLodMaxClampAtIndex

        void setSamplerStateLodMinClampLodMaxClampAtIndex​(MTLSamplerState sampler,
                                                          float lodMinClamp,
                                                          float lodMaxClamp,
                                                          long index)
        setSamplerState:lodMinClamp:lodMaxClamp:atIndex: Set a global sampler for all compute kernels at the given bind point index.
      • setSamplerStatesLodMinClampsLodMaxClampsWithRange

        void setSamplerStatesLodMinClampsLodMaxClampsWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> samplers,
                                                               org.moe.natj.general.ptr.ConstFloatPtr lodMinClamps,
                                                               org.moe.natj.general.ptr.ConstFloatPtr lodMaxClamps,
                                                               NSRange range)
        setSamplers:lodMinClamps:lodMaxClamps:withRange: Set an array of global samplers for all compute kernels with the given bind point range.
      • setSamplerStatesWithRange

        void setSamplerStatesWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> samplers,
                                       NSRange range)
        setSamplers:withRange: Set an array of global samplers for all compute kernels with the given bind point range.
      • setStageInRegion

        void setStageInRegion​(MTLRegion region)
        setStageInRegion:region: Set the region of the stage_in attributes to apply the compute kernel.
      • setTextureAtIndex

        void setTextureAtIndex​(MTLTexture texture,
                               long index)
        setTexture:atIndex: Set a global texture for all compute kernels at the given bind point index.
      • setTexturesWithRange

        void setTexturesWithRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> textures,
                                  NSRange range)
        setTextures:withRange: Set an array of global textures for all compute kernels with the given bind point range.
      • setThreadgroupMemoryLengthAtIndex

        void setThreadgroupMemoryLengthAtIndex​(long length,
                                               long index)
        setThreadgroupMemoryLength:atIndex: Set the threadgroup memory byte length at the binding point specified by the index. This applies to all compute kernels.
      • updateFence

        void updateFence​(MTLFence fence)
        updateFence: Update the fence to capture all GPU work so far enqueued by this encoder. The fence is updated at kernel submission to maintain global order and prevent deadlock. Drivers may delay fence updates until the end of the encoder. Drivers may also wait on fences at the beginning of an encoder. It is therefore illegal to wait on a fence after it has been updated in the same encoder.
      • waitForFence

        void waitForFence​(MTLFence fence)
        waitForFence: Prevent further GPU work until the fence is reached. The fence is evaluated at kernel submision to maintain global order and prevent deadlock. Drivers may delay fence updates until the end of the encoder. Drivers may also wait on fences at the beginning of an encoder. It is therefore illegal to wait on a fence after it has been updated in the same encoder.
      • dispatchThreadsThreadsPerThreadgroup

        void dispatchThreadsThreadsPerThreadgroup​(MTLSize threadsPerGrid,
                                                  MTLSize threadsPerThreadgroup)
        dispatchThreads:threadsPerThreadgroup: Enqueue a compute function dispatch using an arbitrarily-sized grid. threadsPerGrid does not have to be a multiple of the threadGroup size
      • setImageblockWidthHeight

        void setImageblockWidthHeight​(long width,
                                      long height)
        setImageblockWidth:height: Set imageblock sizes.
      • useHeap

        void useHeap​(MTLHeap heap)
        useHeap: Declare that the resources allocated from a heap may be accessed as readonly by the render pass through an argument buffer For tracked MTLHeaps, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resources allocated from the heap through an argument buffer. This method may cause all of the color attachments allocated from the heap to become decompressed. Therefore, it is recommended that the useResource:usage: or useResources:count:usage: methods be used for color attachments instead, with a minimal (i.e. read-only) usage. [@warning] Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
      • useHeapsCount

        void useHeapsCount​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> heaps,
                           long count)
        useHeaps:count: Declare that the resources allocated from an array of heaps may be accessed as readonly by the render pass through an argument buffer For tracked MTLHeaps, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resources allocated from the heaps through an argument buffer. This method may cause all of the color attachments allocated from the heaps to become decompressed. Therefore, it is recommended that the useResource:usage: or useResources:count:usage: methods be used for color attachments instead, with a minimal (i.e. read-only) usage. [@warning] Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
      • useResourceUsage

        void useResourceUsage​(MTLResource resource,
                              long usage)
        useResource:usage: Declare that a resource may be accessed by the command encoder through an argument buffer For tracked MTLResources, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resource through an argument buffer. [@warning] Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
      • useResourcesCountUsage

        void useResourcesCountUsage​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> resources,
                                    long count,
                                    long usage)
        useResources:count:usage: Declare that an array of resources may be accessed through an argument buffer by the command encoder For tracked MTL Resources, this method protects against data hazards. This method must be called before encoding any dispatch commands which may access the resources through an argument buffer. [@warning] Prior to iOS 13, macOS 10.15, this method does not protect against data hazards. If you are deploying to older versions of macOS or iOS, use fences to ensure data hazards are resolved.
      • dispatchType

        long dispatchType()
        [@property] dispatchType The dispatch type of the compute command encoder.
      • executeCommandsInBufferIndirectBufferIndirectBufferOffset

        void executeCommandsInBufferIndirectBufferIndirectBufferOffset​(MTLIndirectCommandBuffer indirectCommandbuffer,
                                                                       MTLBuffer indirectRangeBuffer,
                                                                       long indirectBufferOffset)
        executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: Execute commands in the buffer within the range specified by the indirect range buffer. The same indirect command buffer may be executed any number of times within the same encoder.
        Parameters:
        indirectRangeBuffer - An indirect buffer from which the device reads the execution range parameter, as laid out in the MTLIndirectCommandBufferExecutionRange structure.
        indirectBufferOffset - The byte offset within indirectBuffer where the execution range parameter is located. Must be a multiple of 4 bytes.
      • executeCommandsInBufferWithRange

        void executeCommandsInBufferWithRange​(MTLIndirectCommandBuffer indirectCommandBuffer,
                                              NSRange executionRange)
        executeCommandsInBuffer:withRange: Execute commands in the buffer within the range specified. The same indirect command buffer may be executed any number of times within the same encoder.
      • memoryBarrierWithResourcesCount

        void memoryBarrierWithResourcesCount​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> resources,
                                             long count)
        memoryBarrierWithResources Encodes a barrier between currently dispatched kernels in a concurrent compute command encoder and any subsequent ones on an array of resources. This API ensures that all dispatches in the encoder have completed execution and side effects on the specified resources are visible to subsequent dispatches in that encoder. Calling barrier on a serial encoder is allowed, but ignored.
      • memoryBarrierWithScope

        void memoryBarrierWithScope​(long scope)
        memoryBarrierWithScope Encodes a barrier between currently dispatched kernels in a concurrent compute command encoder and any subsequent ones on a specified resource group This API ensures that all dispatches in the encoder have completed execution and their side effects are visible to subsequent dispatches in that encoder. Calling barrier on a serial encoder is allowed, but ignored.
      • setStageInRegionWithIndirectBufferIndirectBufferOffset

        void setStageInRegionWithIndirectBufferIndirectBufferOffset​(MTLBuffer indirectBuffer,
                                                                    long indirectBufferOffset)
        setStageInRegionWithIndirectBuffer:indirectBufferOffset: sets the stage in region indirectly for the following indirect dispatch calls.
        Parameters:
        indirectBuffer - A buffer object that the device will read the stageIn region arguments from, see MTLStageInRegionIndirectArguments.
        indirectBufferOffset - Byte offset within indirectBuffer to read arguments from. indirectBufferOffset must be a multiple of 4.
      • sampleCountersInBufferAtSampleIndexWithBarrier

        void sampleCountersInBufferAtSampleIndexWithBarrier​(MTLCounterSampleBuffer sampleBuffer,
                                                            long sampleIndex,
                                                            boolean barrier)
        sampleCountersInBuffer:atSampleIndex:withBarrier: Sample hardware counters at this point in the compute encoder and store the counter sample into the sample buffer at the specified index. On devices where MTLCounterSamplingPointAtDispatchBoundary is unsupported, this method is not available and will generate an error if called.
        Parameters:
        sampleBuffer - The sample buffer to sample into
        sampleIndex - The index into the counter buffer to write the sample
        barrier - Insert a barrier before taking the sample. Passing YES will ensure that all work encoded before this operation in the encoder is complete but does not isolate the work with respect to other encoders. Passing NO will allow the sample to be taken concurrently with other operations in this encoder. In general, passing YES will lead to more repeatable counter results but may negatively impact performance. Passing NO will generally be higher performance but counter results may not be repeatable.
      • setAccelerationStructureAtBufferIndex

        void setAccelerationStructureAtBufferIndex​(MTLAccelerationStructure accelerationStructure,
                                                   long bufferIndex)
        setAccelerationStructure:atBufferIndex: Set a global raytracing acceleration structure for all compute kernels at the given buffer bind point index.
      • setIntersectionFunctionTableAtBufferIndex

        void setIntersectionFunctionTableAtBufferIndex​(MTLIntersectionFunctionTable intersectionFunctionTable,
                                                       long bufferIndex)
        setIntersectionFunctionTable:atBufferIndex: Set a visible function table at the given buffer index
      • setIntersectionFunctionTablesWithBufferRange

        void setIntersectionFunctionTablesWithBufferRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> intersectionFunctionTables,
                                                          NSRange range)
        setIntersectionFunctionTables:withBufferRange: Set visible function tables at the given buffer index range
      • setVisibleFunctionTableAtBufferIndex

        void setVisibleFunctionTableAtBufferIndex​(MTLVisibleFunctionTable visibleFunctionTable,
                                                  long bufferIndex)
        setVisibleFunctionTable:atBufferIndex: Set a visible function table at the given buffer index
      • setVisibleFunctionTablesWithBufferRange

        void setVisibleFunctionTablesWithBufferRange​(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> visibleFunctionTables,
                                                     NSRange range)
        setVisibleFunctionTables:withBufferRange: Set visible function tables at the given buffer index range