Skip to content

[vk] Run a mesh draw's task program as a compute dispatch - #2655

Merged
xinitrcn1 merged 1 commit into
scarletnx:mainfrom
VIGO-VI:issue-2229
Nov 20, 2026
Merged

xinitrcn1 merged 1 commit into
scarletnx:mainfrom
VIGO-VI:issue-2229

Conversation

@VIGO-VI

@VIGO-VI VIGO-VI commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

A draw whose program is a task program submits Vulkan's task and mesh stages together, and RADV on RDNA4 hangs the
GPU on that shape. On an RX 9060 XT (RADV, Mesa 26.2.6) an Ounce game's first 3D scene lost the device at the first
indirect task+mesh draw, and RADV's hang dump named DISPATCH_TASKMESH_INDIRECT_MULTI_ACE with the native TaskEXT
shader. The same shape faulted NVIDIA's driver in #1478. vk_mesh_path's Auto, the default, now runs the task program
as a compute dispatch and draws the mesh program with no task stage, for direct and indirect draws, so no gang is
submitted.

  • [vk] Run a mesh draw's task program as a compute dispatch: the translator emits the task program as a compute
    entry point where its key has payload_buf. It writes its payload, its counts and the draw's record into a storage
    buffer, and the mesh program reads that buffer and culls workgroups past their task workgroup's count by calling
    OpSetMeshOutputsEXT with 0 and 0. The renderer fills the record, dispatches the task program (directly, or with
    vkCmdDispatchIndirect), and barriers its writes to the mesh stage and the draw's record. Native stays for a device
    that binds graphics descriptors in heaps, and for vk_mesh_path=native.

Testing: an Ounce game's first 3D scene on an RX 9060 XT (RADV, Mesa 26.2.6):

  • 120 seconds with the compute path: 73,628 mesh draws, 22,298 of them through it, none skipped, no device loss. The
    native path lost the GPU at the first indirect task+mesh gang, in three runs.
  • 90 seconds of the same scene at 37.5 and 39.6 frames a second in two runs, against 35.8 for the native build's run
    of it (each run is one run of the same script).
  • A second hang, in the compute path itself, was a mesh workgroup that returned without OpSetMeshOutputsEXT; the
    workaround (0 and 0 before the return) is in the commit.

Tests without a game: test_mesh_task_compute in tests/shader_sm86.c runs the task and mesh modules in
tests/support/spv_eval.c and checks the record, the counts, a slot's payload and a culled workgroup's zero outputs;
the two modules also pass spirv-val (vulkan1.3). vulkan_headless_mesh draws the same depths through the native
path, the compute path and an indirect record, and vulkan_headless_mesh_native chooses the native path. ctest
passes except the cases this machine fails on unmodified main too: present_fx, present_fx_validation,
vulkan_headless_uma, vulkan_headless_pages, vulkan_headless_descriptor_buffers_uma, and the
vk-descriptors-mode=2 --draw-state-check=1 mesh check, which fails 5 of 10 runs on a pristine main build as well.

Not tested: NVIDIA's driver with vk_ext_mesh_shader=on (the ban keeps the extension off there, and no such GPU is on
this machine); a device that binds graphics descriptors in heaps, which keeps the native path; RADV on RDNA4 cards
other than an RX 9060 XT; and path 2 of the issue, the task and mesh stages as compute with the records drawn as
triangles, so a device without VK_EXT_mesh_shader still draws no mesh program.

Part of #2229. The rest is path 2 of the issue, the task and mesh stages as compute with the records drawn as triangles, which a device without VK_EXT_mesh_shader still needs.

The commit message still ends with Fixes #2229, written before path 2 was kept apart. The issue stays open for path 2 whichever way this merges.

  • No keys, dumps, game files or saves in the commits or the description.
  • A new file starts with SPDX-License-Identifier: GPL-3.0-or-later and the project's copyright line.
  • Code ported from another project keeps its copyright lines, names where it came from and is listed in docs/CREDITS.md. (No code was ported; the issue's reference projects were read for behavior only.)

A draw whose program is a task program submits Vulkan's task and mesh stages
together, and RADV on RDNA4 hangs the GPU on that shape: an RX 9060 XT lost the
device at the first indirect task+mesh draw of an Ounce game's first 3D scene,
and the hang dump named DISPATCH_TASKMESH_INDIRECT_MULTI_ACE with the native
TaskEXT shader. The same shape faulted NVIDIA's driver in scarletnx#1478.

vk_mesh_path's Auto, the default, now runs the task program as a compute program
and draws the mesh program with no task stage:

- the translator emits the task program as a compute entry point where its key
  has payload_buf. Its ISBE payload writes go to a slot of a storage buffer, and
  after the body it stores the groups it launched in a count of its own, the
  largest of them in the draw's record, and its dispatch's size in the record's
  y. It calls no OpEmitMeshTasksEXT.
- a mesh program after a task reads that slot (WorkgroupId.y) and calls
  OpSetMeshOutputsEXT with 0 and 0 before it returns where its WorkgroupId.x is
  past its task workgroup's count, as RADV also hangs a mesh workgroup that
  returns without it.
- the renderer keeps one buffer for each frame in flight, fills its record,
  dispatches the task program with the task stage's set and push constants, and
  barriers its writes to the mesh stage and to the draw's indirect record. A
  direct draw's count is the draw's, and an indirect one's is its record's
  (vkCmdDispatchIndirect).

Native stays for a device that binds graphics descriptors in heaps, where a heap
bind is the graphics pipeline's, and for vk_mesh_path=native.

Verified on an RX 9060 XT (RADV, Mesa 26.2.6):

- an Ounce game's first 3D scene ran 120 seconds with 73,628 mesh draws, 22,298
  of them through the compute path, none skipped, and no device loss, where the
  native path lost the GPU at the first indirect task+mesh gang;
- 90 seconds of the same scene ran at 36.9 frames a second against 35.8 for the
  native build's run of it.

Tests: tests/shader_sm86.c's test_mesh_task_compute runs the task and mesh
modules in tests/support/spv_eval.c and checks the record, the counts, a slot's
payload and a culled workgroup's zero outputs, with no GPU. vulkan_headless_mesh
draws the same depths through the native path, the compute path and an indirect
record, and vulkan_headless_mesh_native chooses the native path. ctest passes
except the five cases this machine fails on main too: present_fx,
present_fx_validation, vulkan_headless_uma, vulkan_headless_pages and
vulkan_headless_descriptor_buffers_uma.

Fixes scarletnx#2229

Signed-off-by: Vigo <77800979+VIGO-VI@users.noreply.github.com>
@VIGO-VI
VIGO-VI marked this pull request as ready for review November 20, 2026 14:31
@xinitrcn1
xinitrcn1 merged commit acec3f4 into scarletnx:main Nov 20, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants