Metal 4 & Acceleration Structures

I have really enjoyed looking through the code and videos related to Metal 4. Currently, my interest is to update a ReSTIR Project and take advantage of more robust ways to refit acceleration Structures and more powerful ways to access resources.

I am working in Swift and have encountered a couple of puzzles:

What is the 'accepted' way to create a MTL4BufferRange to store indices and vertices?

How do I properly rewrite Swift code to build and compact an Acceleration Structure?

I do realize that this is all in Beta and will happily look through Code Samples this Fall. If other guidance is available earlier, that would be fabulous!

Thank you

Hello,

That makes at least two of us who really enjoyed the Metal 4 sessions. :)

Give us some time to determine answers for your questions about Swift and Metal. Documentation is expected to be available in both Obj-C and Swift so that's a start.

Please clarify "How do I properly rewrite Swift code to build and compact an Acceleration Structure?"

Are you asking how to use copyAndCompact(sourceAccelerationStructure:destinationAccelerationStructure:) or how would write your own equivalent in Swift (for use with ReSTIR)?

Re: sample code, it looks like we're continuing to publish samples primarily in Obj-C. Please let us know if you'd like more samples written with Swift by sending us an enhancement request using the Feedback Assistant.

Thanks for your reply.

My first issue came up when trying to use a MTL4ComputeCommandEncoder to build an AccelerationStructure:

func build(destinationAccelerationStructure: any MTLAccelerationStructure, descriptor: MTL4AccelerationStructureDescriptor, scratchBuffer: MTL4BufferRange)

The setup of the scratch buffer ( MTL4BufferRangeMake(::) ) is unfamiliar to me although I have looked through the documentation

I am accustomed to using the MTLDevice and Acceleration Structure Sizes to build an old-school scratch buffer. Any naive attempts to use the gpuAddress value from such an existing MTLBuffer have predictably failed with the message:

__buildAccelerationStructure:descriptor:scratchBuffer:]:2450: failed assertion `Compute Command Encoder Build Acceleration Structure Validation Metal 4 does not support raytracing with software emulation __

So, I guess my initial question is how do I properly create a MTL4BufferRange to use in the build function?

Metal 4 & Acceleration Structures
 
 
Q