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):
ST_TS with ShMesh.payload_buf): its ISBE payload writes go
to a storage buffer at its workgroup's slot, and after the body it stores the groups it launched in a count of its
own, an atomic maximum of them in the draw's record, and the dispatch's size in the record's y. It calls no
OpEmitMeshTasksEXT;WorkgroupId.y), and
calls OpSetMeshOutputsEXT with 0 and 0 before it returns where its WorkgroupId.x is past that workgroup's count
(RADV hangs on a mesh workgroup that returns without it). The draw is vkCmdDrawMeshTasksIndirectEXT of the record:
x the most groups any task workgroup launched, y the task workgroups, z 1;vkCmdDispatchIndirect of its record's) with the task stage's set and the
same push constants (the first workgroup in SNX_VKB_RS's x, the buffer's slots above the flag in the push
constant's z), and barriers its writes to the mesh stage and the draw's record. The dispatch is recorded outside the
render pass, which the previous draw's pass ends; a barrier before its fill orders the buffer's last reads.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).
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.
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.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:
OpSetMeshOutputsEXT(most vertices, count), the count from map word 3 (0 at the start). Then a loop over
vertices and primitives that writes gl_Position, the generic outputs (Location = generic n, per-primitive ones
PerPrimitiveEXT), and PrimitiveTriangleIndicesEXT from the map. The skew offsets come from the OMAPs and
the most vertices, at translation.OpEmitMeshTasksEXT(word 1, 1, 1) with the payload.
The workgroup index is WorkgroupId.x, from either kind of read at offset 0. SR_LANEID is the subgroup
invocation. Constant banks, textures and global buffers are as in the vertex stage. The 7 task and 12 mesh programs
of one run translate and pass spirv-val (snx-sm86 --task and --mesh).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.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.
SetGeometryProcessingMode takes (2 before mesh draws) and what macro 0x1f does.first reaches the index as the first vertex of the point draw does (the game passes 0, so the runs
cannot show it).PerPrimitiveEXT inputs (with their interpolation decorations), the primitive indices against the vertex
count, and a RenderDoc capture of the first faulting draw.DrawMeshTasksIndirect's is {count, first}, as the
renderer takes it, or the other way round (a GPU-written record, which the CPU can't see when it records the draw;
the pictures with it look right).vs_tex_variant).Made from docs/platforms/nx/ounce.md at 69237645142c. GPL-3.0-or-later.