Package apple.metal.protocol
Interface MTLAccelerationStructureCommandEncoder
-
- All Superinterfaces:
MTLCommandEncoder
public interface MTLAccelerationStructureCommandEncoder extends MTLCommandEncoder
API-Since: 14.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbuildAccelerationStructureDescriptorScratchBufferScratchBufferOffset(@NotNull MTLAccelerationStructure accelerationStructure, @NotNull MTLAccelerationStructureDescriptor descriptor, @NotNull MTLBuffer scratchBuffer, long scratchBufferOffset)Encode an acceleration structure build into the command buffer.voidcopyAccelerationStructureToAccelerationStructure(@NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull MTLAccelerationStructure destinationAccelerationStructure)Copy an acceleration structure.voidcopyAndCompactAccelerationStructureToAccelerationStructure(@NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull MTLAccelerationStructure destinationAccelerationStructure)Copy and compact an acceleration structure.voidrefitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffset(@NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull MTLAccelerationStructureDescriptor descriptor, @Nullable MTLAccelerationStructure destinationAccelerationStructure, @Nullable MTLBuffer scratchBuffer, long scratchBufferOffset)Encode an acceleration structure refit into the command buffer.voidrefitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffsetOptions(@NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull MTLAccelerationStructureDescriptor descriptor, @Nullable MTLAccelerationStructure destinationAccelerationStructure, @Nullable MTLBuffer scratchBuffer, long scratchBufferOffset, long options)Encode an acceleration structure refit into the command buffer.voidsampleCountersInBufferAtSampleIndexWithBarrier(@NotNull MTLCounterSampleBuffer sampleBuffer, long sampleIndex, boolean barrier)sampleCountersInBuffer:atSampleIndex:withBarrier: Sample hardware counters at this point in the acceleration structure encoder and store the counter sample into the sample buffer at the specified index.voidupdateFence(@NotNull MTLFence fence)updateFence: Update the fence to capture all GPU work so far enqueued by this encoder.voiduseHeap(@NotNull MTLHeap heap)useHeap: Declare that the resources allocated from a heap may be accessed as readonly by the encoder through an argument buffer For tracked MTLHeaps, this method protects against data hazards.voiduseHeapsCount(@NotNull 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 encoder through an argument buffer For tracked MTLHeaps, this method protects against data hazards.voiduseResourcesCountUsage(@NotNull 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.voiduseResourceUsage(@NotNull 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.voidwaitForFence(@NotNull MTLFence fence)waitForFence: Prevent further GPU work until the fence is reached.voidwriteCompactedAccelerationStructureSizeToBufferOffset(@NotNull MTLAccelerationStructure accelerationStructure, @NotNull MTLBuffer buffer, long offset)Compute the compacted size for an acceleration structure and write it into a buffer.voidwriteCompactedAccelerationStructureSizeToBufferOffsetSizeDataType(@NotNull MTLAccelerationStructure accelerationStructure, @NotNull MTLBuffer buffer, long offset, long sizeDataType)Compute the compacted size for an acceleration structure and write it into a buffer.-
Methods inherited from interface apple.metal.protocol.MTLCommandEncoder
device, endEncoding, insertDebugSignpost, label, popDebugGroup, pushDebugGroup, setLabel
-
-
-
-
Method Detail
-
buildAccelerationStructureDescriptorScratchBufferScratchBufferOffset
void buildAccelerationStructureDescriptorScratchBufferScratchBufferOffset(@NotNull @NotNull MTLAccelerationStructure accelerationStructure, @NotNull @NotNull MTLAccelerationStructureDescriptor descriptor, @NotNull @NotNull MTLBuffer scratchBuffer, long scratchBufferOffset)Encode an acceleration structure build into the command buffer. All bottom-level acceleration structure builds must have completed before a top-level acceleration structure build may begin. The resulting acceleration structure will not retain any references to the input vertex buffer, instance buffer, etc. The acceleration structure build will not be completed until the command buffer has been committed and finished executing. However, it is safe to encode ray tracing work against the acceleration structure as long as the command buffers are scheduled and synchronized such that the command buffer will have completed by the time the ray tracing starts. The acceleration structure and scratch buffer must be at least the size returned by the [MTLDevice accelerationStructureSizesWithDescriptor:] query.- Parameters:
accelerationStructure- Acceleration structure storage to build intodescriptor- Object describing the acceleration structure to buildscratchBuffer- Scratch buffer to use while building the acceleration structure. The contents may be overwritten and are undefined after the build has started/completed.scratchBufferOffset- Offset into the scratch buffer
-
copyAccelerationStructureToAccelerationStructure
void copyAccelerationStructureToAccelerationStructure(@NotNull @NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull @NotNull MTLAccelerationStructure destinationAccelerationStructure)Copy an acceleration structure. The source and destination acceleration structures must not overlap in memory. If this is a top level acceleration structure, references to bottom level acceleration structures will be preserved. The destination acceleration structure must be at least as large as the source acceleration structure, unless the source acceleration structure has been compacted, in which case the destination acceleration structure must be at least as large as the compacted size of the source acceleration structure.- Parameters:
sourceAccelerationStructure- Acceleration structure to copy fromdestinationAccelerationStructure- Acceleration structure to copy to
-
copyAndCompactAccelerationStructureToAccelerationStructure
void copyAndCompactAccelerationStructureToAccelerationStructure(@NotNull @NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull @NotNull MTLAccelerationStructure destinationAccelerationStructure)Copy and compact an acceleration structure. The source and destination acceleration structures must not overlap in memory. If this is a top level acceleration structure, references to bottom level acceleration structures will be preserved. The destination acceleration structure must be at least as large as the compacted size of the source acceleration structure, which is computed by the writeCompactedAccelerationStructureSize method.- Parameters:
sourceAccelerationStructure- Acceleration structure to copy and compactdestinationAccelerationStructure- Acceleration structure to copy to
-
refitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffset
void refitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffset(@NotNull @NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull @NotNull MTLAccelerationStructureDescriptor descriptor, @Nullable @Nullable MTLAccelerationStructure destinationAccelerationStructure, @Nullable @Nullable MTLBuffer scratchBuffer, long scratchBufferOffset)Encode an acceleration structure refit into the command buffer. Refitting can be used to update the acceleration structure when geometry changes and is much faster than rebuilding from scratch. However, the quality of the acceleration structure and the subsequent ray tracing performance will degrade depending on how much the geometry changes. Refitting can not be used after certain changes, such as adding or removing geometry. Acceleration structures can be refit 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 are not the same, they must not overlap in memory. The destination acceleration structure must be at least as large as the source acceleration structure, unless the source acceleration structure has been compacted, in which case the destination acceleration structure must be at least as large as the compacted size of the source acceleration structure. The scratch buffer must be at least the size returned by the accelerationStructureSizesWithDescriptor method of the MTLDevice.- Parameters:
descriptor- Object describing the acceleration structure to buildsourceAccelerationStructure- Acceleration structure to copy fromdestinationAccelerationStructure- Acceleration structure to copy toscratchBuffer- Scratch buffer to use while refitting the acceleration structure. The contents may be overwritten and are undefined after the refit has started/completed.scratchBufferOffset- Offset into the scratch buffer.
-
sampleCountersInBufferAtSampleIndexWithBarrier
void sampleCountersInBufferAtSampleIndexWithBarrier(@NotNull @NotNull MTLCounterSampleBuffer sampleBuffer, long sampleIndex, boolean barrier)sampleCountersInBuffer:atSampleIndex:withBarrier: Sample hardware counters at this point in the acceleration structure encoder and store the counter sample into the sample buffer at the specified index.- Parameters:
sampleBuffer- The sample buffer to sample intosampleIndex- The index into the counter buffer to write the samplebarrier- 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. API-Since: 14.0
-
updateFence
void updateFence(@NotNull @NotNull MTLFence fence)updateFence: Update the fence to capture all GPU work so far enqueued by this encoder. The fence is updated at build 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.
-
useHeap
void useHeap(@NotNull @NotNull MTLHeap heap)useHeap: Declare that the resources allocated from a heap may be accessed as readonly by the encoder through an argument buffer For tracked MTLHeaps, this method protects against data hazards. This method must be called before encoding any acceleration structure 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(@NotNull @NotNull 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 encoder through an argument buffer For tracked MTLHeaps, this method protects against data hazards. This method must be called before encoding any acceleration structure 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(@NotNull @NotNull 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 acceleration structure 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(@NotNull @NotNull 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 acceleration structure 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.
-
waitForFence
void waitForFence(@NotNull @NotNull MTLFence fence)waitForFence: Prevent further GPU work until the fence is reached. The fence is evaluated at build 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.
-
writeCompactedAccelerationStructureSizeToBufferOffset
void writeCompactedAccelerationStructureSizeToBufferOffset(@NotNull @NotNull MTLAccelerationStructure accelerationStructure, @NotNull @NotNull MTLBuffer buffer, long offset)Compute the compacted size for an acceleration structure and write it into a buffer. This size is potentially smaller than the source acceleration structure. To perform compaction, read this size from the buffer once the command buffer has completed and use it to allocate a smaller acceleration structure. Then create another encoder and call the copyAndCompactAccelerationStructure method.- Parameters:
accelerationStructure- Source acceleration structurebuffer- Destination size buffer. The compacted size will be written as a 32 bit unsigned integer representing the compacted size in bytes.offset- Offset into the size buffer
-
writeCompactedAccelerationStructureSizeToBufferOffsetSizeDataType
void writeCompactedAccelerationStructureSizeToBufferOffsetSizeDataType(@NotNull @NotNull MTLAccelerationStructure accelerationStructure, @NotNull @NotNull MTLBuffer buffer, long offset, long sizeDataType)Compute the compacted size for an acceleration structure and write it into a buffer. This size is potentially smaller than the source acceleration structure. To perform compaction, read this size from the buffer once the command buffer has completed and use it to allocate a smaller acceleration structure. Then create another encoder and call the copyAndCompactAccelerationStructure method.- Parameters:
accelerationStructure- Source acceleration structurebuffer- Destination size buffer. The compacted size will be written as either a 32 bit or 64 bit value depending on the sizeDataType argument unsigned integer representing the compacted size in bytes.offset- Offset into the size buffersizeDataType- Data type of the size to write into the buffer. Must be either MTLDataTypeUInt (32 bit) or MTLDataTypeULong (64 bit) API-Since: 15.0
-
refitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffsetOptions
void refitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffsetOptions(@NotNull @NotNull MTLAccelerationStructure sourceAccelerationStructure, @NotNull @NotNull MTLAccelerationStructureDescriptor descriptor, @Nullable @Nullable MTLAccelerationStructure destinationAccelerationStructure, @Nullable @Nullable MTLBuffer scratchBuffer, long scratchBufferOffset, long options)Encode an acceleration structure refit into the command buffer. Refitting can be used to update the acceleration structure when geometry changes and is much faster than rebuilding from scratch. However, the quality of the acceleration structure and the subsequent ray tracing performance will degrade depending on how much the geometry changes. Refitting can not be used after certain changes, such as adding or removing geometry. Acceleration structures can be refit 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 are not the same, they must not overlap in memory. The destination acceleration structure must be at least as large as the source acceleration structure, unless the source acceleration structure has been compacted, in which case the destination acceleration structure must be at least as large as the compacted size of the source acceleration structure. The scratch buffer must be at least the size returned by the accelerationStructureSizesWithDescriptor method of the MTLDevice.- Parameters:
descriptor- Object describing the acceleration structure to buildsourceAccelerationStructure- Acceleration structure to copy fromdestinationAccelerationStructure- Acceleration structure to copy toscratchBuffer- Scratch buffer to use while refitting the acceleration structure. The contents may be overwritten and are undefined after the refit has started/completed.scratchBufferOffset- Offset into the scratch buffer.options- Options specifying the elements of the acceleration structure to refit. API-Since: 16.0
-
-