GPU-Driven Rendering
In this chapter, we will upgrade the geometry pipeline to use the latest available technology: mesh shaders and meshlets. The idea behind this technique is to move the flow of mesh rendering from the CPU to the GPU, moving culling and draw command generation into different shaders.
We will first work on the mesh structure on the CPU, by separating it into different meshlets that are groups of up to 64 triangles, each with an individual bounding sphere. We will then use compute shaders to perform culling and write a list of commands to draw the meshlets in the different passes. Finally, we will use the mesh shaders to render the meshlets. There will also be a compute version provided, as mesh shaders are still available only on Nvidia GPUs for now.
Traditionally, geometry culling has been performed on the CPU. Each mesh on the scene is usually represented by an axis aligned bounding box (AABB). An AABB can easily be culled against the camera frustum, but...