Mesh shading is a programmable geometric shading pipeline that uses what NVIDIA calls cooperative thread groups to create compact meshes on-chip. The main purpose of mesh shading is to offload some heavy computational lifting from the CPU in order to leverage the immense processing capabilities of the parallel computing-intensive GPU.
To showcase how mesh shading works, NVIDIA has created the Asteroids demo, which presents a scene with a space ship navigating through an asteroid field. In the demo, there are 350,000 asteroids that have been generated, each comprised of up to 10 million triangles. In total, there are 3.5 trillion triangles that must be processed.
To further lessen the amount of computing resources needed, primitives that will never been seen are removed from the equation; this only leaves the visible pixels that must be shaded. From there, NVIDIA is using a level of detail (LOD) method to increase the number of triangles (and hence, detail) depending on how far away an asteroid is from the ship. The LOD scale goes from 0 to 10, with 10 being the highest (NVIDIA reckons around 20 triangles for LOD 0 and in excess of 6 million for LOD 10).
"By combining together efficient GPU culling and LOD techniques, we decrease the number of triangles drawn by several orders of magnitude, retaining only those necessary to maintain a very high level of image fidelity," writes NVIDIA's Manuel Kraemer. "The real-time drawn triangle counters can be seen in the lower corner of the screen. Mesh shaders make it possible to implement extremely efficient solutions that can be targeted specifically to the content being rendered."
NVIDIA claims that its mesh shading approach greatly improves rendering efficiency and it expects developers to implement it to increase performance and visual fidelity in their games going forward.