how to get a null acceleration structure w/o trigging an API validation error

I want to turn off my ray-tracing conditionally. There's is_null_acceleration_structure but when I don't bind an acceleration structure (or pass nil to setFragmentAccelerationStructure), I get the following API validation error:

-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5782: failed assertion `Draw Errors Validation
Fragment Function(vol_deferred_lighting): missing instanceAccelerationStructure binding at index 6 for accelerationStructure[0].

I can turn off API validation and it works, but it seems like I should be able to use nil for the acceleration structure w/o triggering a validation error. Seems like a bug, right?

I suppose I can work around this by creating a separate pipeline with the ray-tracing disabled via a function constant instead of using is_null_acceleration_structure.

(Can we get a ray-tracing tag for questions?)

Answered by Graphics and Games Engineer in 814946022

You could bind an argument buffer instead at that buffer index and encode a 0 MTLResourceID into it for a null acceleration structure, but a direct binding in a [[buffer()]] slot needs to be bound if it's mentioned in the function declaration.

Accepted Answer

You could bind an argument buffer instead at that buffer index and encode a 0 MTLResourceID into it for a null acceleration structure, but a direct binding in a [[buffer()]] slot needs to be bound if it's mentioned in the function declaration.

how to get a null acceleration structure w/o trigging an API validation error
 
 
Q