The compute-task path

A draw whose task program launches the mesh program takes VK_EXT_mesh_shader's two stages in one submission, and that gang is the shape that faulted NVIDIA's driver and hangs RADV on RDNA4 (Driver quirks). vk_mesh_path's Auto, the default, takes them apart instead (sm86.h has the buffer's layout, vk/render.c the dispatch and the draw):

The programs, their outputs, the payload's bytes and the fragment program's PerPrimitiveEXT inputs are the ones the native path draws. A direct draw and an indirect one both take the path. A device whose graphics descriptors are heaps keeps the native path, because a heap bind is the graphics pipeline's. On an RX 9060 XT (RADV Mesa 26.2.6) the native path hangs the GPU as soon as an indirect task+mesh gang is submitted, and the compute path draws a game's first 3D scene for 120 seconds with 23,204 mesh draws through it and none skipped (Driver quirks).

Design

The host (an RTX 2080) has VK_EXT_mesh_shader with 256 vertices and primitives and 128 task invocations, more than the game asks for.

  1. NVN (done). NvnProgram keeps stages 6 and 7 (NVN_STAGES) last, in an Ounce game's program object only: another game's keeps its own fields from byte 0x80 (NVN_PROGRAM_SWITCH_BYTES). SetShaders keeps the sections' fields (DsMeshKey) by the program's serial (nvn_program_mesh). OP_DRAW_MESH records {first, count}, a 3D draw as x y z workgroups in a row from 0, and an indirect one with the buffer's address, count address and stride. The replay (nvn_draw.c) makes it a DrawCall with mesh set, of DsPrograms' task and mesh programs and the fragment program.
  2. Translator (done, sm86_translate.c, with its interface in sm86.h: ShaderInfo.mesh is the key, a task program takes descriptor set 2 and a mesh program set 0). New stages ST_TS and ST_MS, given by NVN, not by the SPH. Model the ISBE as Workgroup arrays: the output area (u32 [V + primitive area]), the map (u32 [4 + 3 * most primitives], a byte to a word) and, for a task program, the payload as TaskPayloadWorkgroupEXT. ISBEWR and ISBERD become stores and loads at their offsets, so the program's own addressing needs no decode. EXIT returns from the program's function. An epilogue in main after a workgroup barrier then does the outputs:
  3. Fragment linkage. A fragment program reads per-primitive generic n as a plain input. Its module must declare them PerPrimitiveEXT, so the fragment shader key gets a mask of per-primitive locations from the mesh program (pipeline.c's key, fs_variant in render.c). The translator's half is done: a fragment program's ShaderInfo.prim_mask names those inputs, the mesh program's prim_mask.
  4. Vulkan (done but the indirect forms). device.c turns on meshShader and taskShader with subgroupSizeControl and computeFullSubgroups, when the device has a required subgroup size of 32 in the mesh and task stages. Else the log says why once, and the mesh draws are skipped. The mesh and task bits join the push constants' stages and the visibility of sets 0 and 2. A mesh pipeline (PipeKey.mesh) has its mesh shader in the vertex slot and its task shader in the tessellation control slot, so the pipeline file needs no new fields. It has no vertex input, input assembly or tessellation state, and no topology, restart or vertex input dynamic state. Its stages require a subgroup of 32, and whole subgroups when the workgroup is 32 invocations (8 cannot be). render.c draws with vkCmdDrawMeshTasksEXT(count, 1, 1) and the first workgroup in push constant x. The periodic vulkan: stats line counts the mesh draws and those skipped. The storage writes of the two stages are in the barriers before their results land (buffer.c's out_stages).

On a Radeon 890M (RADV, Mesa 26.2.5) the mesh draws, direct and indirect, ran without a fault in every run so far, the menus and the first 3D scene. With RADV_DEBUG=hang, which waits for each draw (syncshaders), the first mesh draws of the menus hung the GPU twice, once with every task draw of 0 workgroups (the gfx ring, then a compute ring timed out; the dump's compute IB held an ACQUIRE_MEM and NOPs, with the shader engines idle): a task program's draw is a gang submission, its task stage on an ACE queue, which that option's waits stall. Don't take it to a run with mesh draws. On an RX 6700 XT (RADV, Mesa 26.2.6) a run from boot into a race drew 213,192 mesh draws, and one under the validation layer 78,495, with no fault.

With the mesh draws on, the draws translate and draw, with no not translated line and no validation message of their own, but 6 of 7 runs through the menus on an RTX 2080 (driver 615.78.08) ended in a GPU fault: Xid 109 (context switch timeout) and Xid 31 (MMU faults of GPCCLIENT_GCC, reads at addresses such as 0xfffff079_ad3f2000), then VK_ERROR_DEVICE_LOST. Runs without mesh draws had none. GPU-assisted validation reported nothing about them. What did not remove the faults: the per-primitive SPH at the right offset, the fragment inputs no mesh output writes read as 0, 0, 0, 1, and storage buffers of the two stages bound to all the memory mapped from their addresses. A run that drew only the mesh programs alone without per-primitive outputs had no fault in 319 frames, which is too few to be sure. So VK_EXT_mesh_shader is off on NVIDIA's driver on Turing GPUs (deviceIDs 0x1e00 to 0x1fff and 0x2180 to 0x21ff), by its line in src/common/gpu/vk/extension_bans.txt, which vk_ext_mesh_shader=on goes over to test it again (the vulkan_headless_mesh test does). Newer GPUs draw them: on an RTX 4090 (Ada, driver 621.01, Windows), a run of 181 seconds through the field drew 347,323 mesh draws with no fault, through the compute task path that vk_mesh_path=auto takes there. 7,178 of them (2%) were still skipped, for a reason the log does not give.

Open questions


Made from docs/platforms/nx/ounce.md at 69237645142c. GPL-3.0-or-later.