Purpose of TLAS in DirectX Raytracing

DirectX Raytracing (DXR) utilizes a two-level acceleration structure hierarchy to achieve real-time ray traversal performance. This article explains the vital role of the Top-Level Acceleration Structure (TLAS) in scene management, detailing how it organizes geometry instances, enables dynamic transformations with minimal computational overhead, conserves memory through instancing, and controls shader execution.

The Two-Level Hierarchy

Ray tracing requires spatial partitioning structures, such as bounding volume hierarchies (BVH), to avoid testing every ray against every triangle in a scene. DXR splits this system into two tiers: the Bottom-Level Acceleration Structure (BLAS) and the Top-Level Acceleration Structure (TLAS).

While a BLAS holds the actual geometric primitives (triangles, procedural geometry, and vertices) in local coordinate space, the TLAS sits above it to represent the entire scene. A TLAS does not store raw mesh data; instead, it contains an array of instance descriptors that reference various BLAS objects placed throughout the world.

Efficient Mesh Instancing

One of the primary purposes of the TLAS is facilitating geometry instancing. In modern game environments, identical objects—such as trees, rocks, or generic props—appear repeatedly.

Without the TLAS, every single object would require unique primitive data in a massive acceleration structure, quickly exhausting GPU memory. With a TLAS, the geometry is built once into a single BLAS. The TLAS then references that single BLAS dozens or thousands of times, applying unique 3x4 transformation matrices, material IDs, and flags to each instance. This drastically minimizes the memory footprint of complex scenes.

High-Performance Dynamic Scene Updates

Full acceleration structure generation is computationally expensive because it requires sorting and organizing large volumes of triangle data. In dynamic scenes where objects move, rotate, or scale every frame, rebuilding the entire spatial hierarchy from scratch would destroy real-time performance.

The TLAS solves this bottleneck by separating motion from geometry:

  • Static BLAS: Rigid meshes remain unchanged in their local BLAS.
  • Dynamic TLAS: The TLAS, containing only a flat list of instance transforms and references, can be rebuilt or refitted rapidly on the GPU every frame.

When an actor moves across the screen, the application merely updates the transformation matrix within the instance description in the TLAS. The underlying vertex data inside the BLAS remains untouched.

Instance Masking and Ray Filtering

The TLAS provides ray traversal control through 8-bit instance inclusion masks. Each instance inside a TLAS is assigned a bitmask, and each TraceRay() call in HLSL defines a matching mask.

During traversal, the hardware performs a bitwise AND operation between the ray's mask and the instance mask. If the result is zero, the entire BLAS referenced by that instance is skipped. This mechanism allows developers to selectively omit objects from specific ray operations—such as ignoring small debris for shadow rays or isolating specific geometry layers for reflection passes—without altering the underlying geometry.

Shader Binding Table Indexing

The TLAS serves as the bridge between scene objects and the GPU's Shader Binding Table (SBT). Each instance within the TLAS contains an instance contribution offset, which dictates which hit group (intersection, any-hit, and closest-hit shaders) runs when a ray strikes that specific object. This enables different instances sharing the same BLAS to execute entirely different materials or rendering logic based on how they are defined in the TLAS.