START TYPING KEYWORDS TO SEARCH OUR WEBSITE

Meshing around with shaders coming with DirectX Ultimate

Mesh Shading comes with DirectX updates; and UL benchmarks measure its value

Posted: By Jon Peddie 02.16.21

In late 2019 Microsoft announced it would make a major upgrade to its Windows API DirectX12. The company said it would add two new shader stages: the Mesh Shader and the Amplification Shader.

Mesh shaders incorporate most aspects of Vertex (VS) and Geometry shaders (GS) into one shader stage by processing batches of vertices and primitives before the rasterizer. The VS, HS, DS, and GS shaders are replaced with an Amplification Shader.  (See the GPU Pipeline Evolution diagram. It will help.) A mesh shader is a new type of shader that combines vertex and primitive processing. VS, HS, DS, and GS shader stages are replaced with an Amplification Shader and Mesh Shader.

Those additions were designed to streamline the rendering pipeline, which would, in turn improve efficiency and flexibility. Mesh and Amplification Shaders replace a lot of the legacy graphics pipeline including the Input Assembler, Vertex shader, Geometry, Tessellation, Domain, and Hull Shaders with more robust and general-purpose capabilities.

GPU pipeline evolution

 

The mesh shader feature set is a major part of DX12 Ultimate developed to increase the flexibility and performance of the geometry pipeline. Other key DX12 Ultimate components include ray tracing, variable-rate shading, and sampler feedback.

AMD and Nvidia introduced DX12 Ultimate capabilities with their RDNA 2, and Turing, and subsequent GPUs.

Vulkan does not yet have a cross-vendor mesh shader extension. Mesh shaders in Vulkan are available through an Nvidia vendor extension that was introduced in February 2017. Khronos is having an ongoing debate in the working group whether to follow the DX12 design of mesh shaders because some developers are suggesting some alternate approaches.

In the meantime, UL Labs (Futuremark) has worked up a DX12-based benchmark for mesh shading that is available on Steam. This addition, the 3DMark Mesh Shader feature test, shows how a game can get increased frame rates by using the mesh shader pipeline.

The now-iconic 3DMark mesh shader test image (Source: UL Labs)

 

Mesh shaders simplifies the graphics pipeline by introducing a new approach to geometry processing. It also gives developers additional flexibility and control.

A mesh is a set of vertices, edges, and faces used in In 3D graphics to describe the shape, as well as the location of an object. In legacy 3D pipelines the geometry data of a mesh is processed sequentially before any further refinements can be taken. That sequential step-wise operation creates a performance bottleneck. The GPU’s geometry pipeline hid the parallel nature of its hardware execution behind a simplified programming prior to the mesh shader. The abstraction only provided access to linear shader functions. Therefore, a vertex shader function would get used for each vertex in a serial execution. However, the hardware packs adjacent vertices to fill a SIMD wave, then executes 32 or 64 vertex shader functions in parallel on a single shader core.

Mesh shaders replace the legacy pipeline with a new model that brings the power, flexibility, and control of a compute-programming model to the 3D pipeline.

Mesh shaders offer almost infinite detail. Smaller sections of a mesh, called meshlets, are processed in parallel with a much greater degree of flexibility and control.

It begins with the amplification shaders (the thread dispenser in the above diagram). Among functions, it is used for culling because it can determine the meshlets that are visible prior to shading.

More information about mesh shaders can be found at the Microsoft DirectX Developer Blog and in the DirectX Functional Spec.

Screenshots from the interactive mode that visualize the meshlets in the scene—notice the foreground occludes the faces behind (Source: UL Labs)

 

The test runs in two passes. The first pass uses a traditional approach to geometry culling to provide a performance baseline. The second pass uses mesh shaders to efficiently cull hidden meshlets.

As mentioned above, a meshlet is a subset of the main mesh. It is created through a partitioning of the primary geometry of the model. Meshlets range from 32 up to 200 of the primary vertices, depending on the number of attributes of the vertice. Also, they can have as many shared vertices as possible to allow for vertex re-use during rendering. This partitioning will be pre-computed and stored with the geometry to avoid computation at runtime, unlike the current Input Assembler that attempts to dynamically identify vertex reuse every time a mesh is drawn. Titles can convert meshlets into regular index buffers for vertex shader fallback if a device does not support Mesh Shaders.

The result of the test is the average frame rate for each pass and the difference between the two expressed as a percentage. You can read more about the test in the 3DMark user guide.

Interactive mode

The 3DMark Mesh Shader feature test includes an interactive mode that helps visualize the benefits of using mesh shaders. In the test one can pause and jump to different parts of the timeline and change settings in real-time. Visualizer options are used to highlight meshlets or see the level of detail (LOD) used for each meshlet. You can see a nice GIF animation here.

The 3DMark Mesh Shader feature test has an interactivce mode to help fixualize the benefits of mesh shaders. (Source: 3DMark)

 

DirectX 12 Ultimate adds powerful new features and capabilities to the API. Those features will enable game developers to create more realistic graphics while also improving performance and frame rates.

3DMark has a dedicated test for each of the new features in DirectX 12 Ultimate:

  • 3DMark DirectX Raytracing feature test
  • 3DMark Mesh Shader feature test
  • 3DMark VRS feature test
  • 3DMark Sampler Feedback feature test (coming later this year)

 

As well as measuring performance, each of these tests also has an interactive mode that lets one experiment with different settings to see the effect on image quality and performance.

You can read more about DirectX 12 Ultimate on the Microsoft DirectX Developer blog.

The Mesh Shader feature test is available today as a free update for 3DMark Advanced Edition and available on Steam.

We ran a test of the benchmark and the results are astounding.

A 730% improvement in FPS using mesh shaders

 

The benchmark runs the same scene two times: initially using traditional culling methods and then using Mesh Shaders. The scenes look the same, but the performance difference is incredible. 3DMark feature tests are designed to focus on specific techniques. This often results in them being more synthetic than traditional 3DMark benchmarks. In this feature test, the performance difference is huge. In a game, the benefit will be smaller.

What do we think?

You know the saying, I’ll know it when I see it. Well, you can only see it with UL Labs benchmark.

We couldn’t find any games that are shipping that are using mesh shaders. Maybe this holiday season we’ll see the first ones. To get a hint of what they might be like, look at the Epic demo.

In its epic demo of UE5, Epic showed Nanite and Lumen. We discussed it in October.

Nanite is a tool that virtualizes geometry, which means it automatically generates as much geometric detail as the eye can see. And that, says the company, allows developers to diversify that geometry endlessly based on any source asset. You can only do that LOD with meshes.

The HW for mesh shading has been in GPUs since 2018 (2017 if you believe AMD invented it first), but the SW to invoke it is just now becoming available with Directx 12 Ultimate. No games are using it yet and we probably won't see it in action until 2022 but the UL Labs benchmark is helping to make the case and build demand for mesh shading.