Contents

MTLAccelerationStructure

A collection of model data for GPU-accelerated intersection of rays with the model.

Declaration

protocol MTLAccelerationStructure : MTLResource

Mentioned in

Overview

To accelerate ray tracing, the device instance needs to reorganize your model data into an optimized data structure for intersection testing on that GPU. Create MTLAccelerationStructure instances to contain your model data and reference them in compute and render commands that execute ray-tracing operations.

You don’t define classes that implement this protocol. To create an acceleration structure, you create a descriptor instance and configure its properties with your model data. Then call the makeAccelerationStructure(descriptor:) method on the Metal device instance to create the instance and reserve memory for the structure. To populate the structure with the data, use an MTLAccelerationStructureCommandEncoder to encode GPU commands.

Metal provides multiple descriptor classes, each describing a different type of model data. Choose the appropriate descriptor for each acceleration structure you want to make. Most often, you create an acceleration structure for each list of triangles or bounding boxes. Then collect related geometry structures into a primitive acceleration structure. Create instance acceleration structures when you need to reference instances of primitive acceleration structures at different locations within a scene.

The table below summarizes the descriptor classes:

Descriptor class

Usage

Mtlaccelerationstructuretrianglegeometrydescriptor

Describes an acceleration structure for a list of triangles.

Mtlaccelerationstructureboundingboxgeometrydescriptor

Describes an acceleration structure for a list of bounding boxes.

Mtlprimitiveaccelerationstructuredescriptor

Describes an acceleration structure for a list of bounding-box or triangle acceleration structures, effectively creating a union of all of the underlying geometry.

Mtlinstanceaccelerationstructuredescriptor

Describes an acceleration structure for a list of instances of primitive acceleration structures.

Topics

Reading the structure’s size

Instance Properties

See Also

Acceleration structures