anv: Implement experimental support for Mesh Shading pipeline in XeHP
Dependencies:
Related
Add support for Mesh Pipeline through the VK_NV_mesh_shader extension. Both Mesh and Task shaders are supported. Multiview will appear as a separate MR. The extension is only advertised when ANV_EXPERIMENTAL_NV_MESH_SHADER
environment variable is set to 1
or true
.
About the Mesh Pipeline
The existing variant of Graphics Pipeline, referred to as Primitive Pipeline, uses VS and optionally TCS/TES/GS, to produce the geometry. This MR adds a new variant, the Mesh pipeline, that uses Task and Mesh shaders. Fragment Shader is used by both variants. See https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/chap10.html and https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/chap25.html.
Both new shader stages are similar to compute shaders with the addition of Input and Output that's "per workgroup", i.e. the entire workgroup produces a single set of outputs. The output can be written collaboratively by the various invocations in the workgroup.
A Task shader workgroup will define how many Mesh shader workgroups will be dispatched, the Task Output will become Mesh Input for all those dispatched meshes.
A Mesh shader workgroup will define a set of primitives, their vertices, and their (user defined) attributes. These attributes are arrayed and can be per-vertex or per-primitive (which corresponds to a "flat" attribute that doesn't need interpolation).
About VK_NV_mesh_shader
We are using the NV extension since is the one already published for Vulkan. When/if a cross-vendor extension appears the plan is to move the effort to support that. See https://github.com/KhronosGroup/Vulkan-Docs/issues/1423
Future work
- Multiview
- I/O optimization
- State handling optimization
- Cross-vendor extension work (pending issue above)