public interface MTLAccelerationStructureCommandEncoder extends MTLCommandEncoder
| Modifier and Type | Method and Description |
|---|---|
void |
buildAccelerationStructureDescriptorScratchBufferScratchBufferOffset(MTLAccelerationStructure accelerationStructure,
MTLAccelerationStructureDescriptor descriptor,
MTLBuffer scratchBuffer,
long scratchBufferOffset)
Encode an acceleration structure build into the command buffer.
|
void |
copyAccelerationStructureToAccelerationStructure(MTLAccelerationStructure sourceAccelerationStructure,
MTLAccelerationStructure destinationAccelerationStructure)
Copy an acceleration structure.
|
void |
copyAndCompactAccelerationStructureToAccelerationStructure(MTLAccelerationStructure sourceAccelerationStructure,
MTLAccelerationStructure destinationAccelerationStructure)
Copy and compact an acceleration structure.
|
void |
refitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffset(MTLAccelerationStructure sourceAccelerationStructure,
MTLAccelerationStructureDescriptor descriptor,
MTLAccelerationStructure destinationAccelerationStructure,
MTLBuffer scratchBuffer,
long scratchBufferOffset)
Encode an acceleration structure refit into the command buffer.
|
void |
sampleCountersInBufferAtSampleIndexWithBarrier(MTLCounterSampleBuffer sampleBuffer,
long sampleIndex,
boolean barrier)
sampleCountersInBuffer:atSampleIndex:withBarrier:
|
void |
updateFence(MTLFence fence)
updateFence:
|
void |
useHeap(MTLHeap heap)
useHeap:
|
void |
useHeapsCount(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> heaps,
long count)
useHeaps:count:
|
void |
useResourcesCountUsage(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> resources,
long count,
long usage)
useResources:count:usage:
|
void |
useResourceUsage(MTLResource resource,
long usage)
useResource:usage:
|
void |
waitForFence(MTLFence fence)
waitForFence:
|
void |
writeCompactedAccelerationStructureSizeToBufferOffset(MTLAccelerationStructure accelerationStructure,
MTLBuffer buffer,
long offset)
Compute the compacted size for an acceleration structure and write it into a buffer.
|
void |
writeCompactedAccelerationStructureSizeToBufferOffsetSizeDataType(MTLAccelerationStructure accelerationStructure,
MTLBuffer buffer,
long offset,
long sizeDataType)
Compute the compacted size for an acceleration structure and write it into a buffer.
|
device, endEncoding, insertDebugSignpost, label, popDebugGroup, pushDebugGroup, setLabelvoid buildAccelerationStructureDescriptorScratchBufferScratchBufferOffset(MTLAccelerationStructure accelerationStructure, MTLAccelerationStructureDescriptor descriptor, MTLBuffer scratchBuffer, long scratchBufferOffset)
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.
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 buffervoid copyAccelerationStructureToAccelerationStructure(MTLAccelerationStructure sourceAccelerationStructure, MTLAccelerationStructure destinationAccelerationStructure)
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.
sourceAccelerationStructure - Acceleration structure to copy fromdestinationAccelerationStructure - Acceleration structure to copy tovoid copyAndCompactAccelerationStructureToAccelerationStructure(MTLAccelerationStructure sourceAccelerationStructure, MTLAccelerationStructure destinationAccelerationStructure)
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.
sourceAccelerationStructure - Acceleration structure to copy and compactdestinationAccelerationStructure - Acceleration structure to copy tovoid refitAccelerationStructureDescriptorDestinationScratchBufferScratchBufferOffset(MTLAccelerationStructure sourceAccelerationStructure, MTLAccelerationStructureDescriptor descriptor, MTLAccelerationStructure destinationAccelerationStructure, MTLBuffer scratchBuffer, long scratchBufferOffset)
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.
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.void sampleCountersInBufferAtSampleIndexWithBarrier(MTLCounterSampleBuffer sampleBuffer, long sampleIndex, boolean barrier)
Sample hardware counters at this point in the compute encoder and store the counter sample into the sample buffer at the specified index.
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.void updateFence(MTLFence fence)
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.
void useHeap(MTLHeap heap)
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.
void useHeapsCount(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> heaps,
long 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.
void useResourceUsage(MTLResource resource, long 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.
void useResourcesCountUsage(org.moe.natj.general.ptr.Ptr<org.moe.natj.objc.ObjCObject> resources,
long count,
long 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.
void waitForFence(MTLFence fence)
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.
void writeCompactedAccelerationStructureSizeToBufferOffset(MTLAccelerationStructure accelerationStructure, MTLBuffer buffer, long offset)
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.
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 buffervoid writeCompactedAccelerationStructureSizeToBufferOffsetSizeDataType(MTLAccelerationStructure accelerationStructure, MTLBuffer buffer, long offset, long sizeDataType)
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.
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)