In bounding volume hierarchy building function, I believe there is a condition in one if-statement which prevents us to use the maximum number of primitives in node properly. The code is as follows:
// Either create leaf or split primitives at selected SAH bucket
if (nPrimitives > maxPrimsInNode || minCost < nPrimitives) split the node
else create leaf node
The minCost < nPrimitives is usually fulfilled and a leaf node with maximum primitives in that leaf node is created in very rare cases but as we all knows, when the number of primitives per node is less than maxPrimsInNode, it is better to not split in most cases. Have a look on the attached image. The SAH cost function returns 2.625 for all possible split and it is less than 4 (number of triangles), so the triangles are split. But, it is not give us any performance improvement (it even can adds some overheads).
I'm not sure what change you're suggesting. Is it to always create a leaf if nPrimitives <= maxPrimsInNode? I tried that change and for the two scenes I tried, saw a 10%-30% slowdown.
I am using the acceleration structure for raytracing volumetric data and by this change I got performance improvement. I don't remember how much was it. But logically, it makes sense to always split when the number of primitives get smaller than maximum primitives in the node. In the example above, what performance improvement do we get by splitting? I think it makes sense to not split.