writeCompactedSize(sourceAccelerationStructure:destinationBuffer:)
Encodes a command to compute the size an acceleration structure can compact into, writing the result into a buffer.
Declaration
func writeCompactedSize(sourceAccelerationStructure accelerationStructure: any MTLAccelerationStructure, destinationBuffer buffer: MTL4BufferRange)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.
Discussion
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 copyAndCompact(sourceAccelerationStructure:destinationAccelerationStructure:) method to perform the copy.