
324 VI GPGPU
The construction stage is divided in four steps:
1. Generate AABBs and 32-bit Morton codes for each primitive.
2. Sort primitives using their Morton codes as their keys.
3. Build the tree.
4. Generate AABBs for each node.
Generate AABBs and Morton codes for each primitive. The first step is straight-
forward. Each thread computes the Morton code of one primitive. This process
assumes that the bounding box for the whole model is known. Since we know
the boundaries of the bounding box of the root, it is possible to initialize node 0
(which is invalid) and node 1, which “contains” the whole model. The output of
this stage is the input of the