Repository navigation
[vk] Run a mesh draw's task program as a compute dispatch - #2655
Merged
Merged
Conversation
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>
xinitrcn1
approved these changes
Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ACEwith the nativeTaskEXTshader. The same shape faulted NVIDIA's driver in #1478.
vk_mesh_path's Auto, the default, now runs the task programas 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 computeentry point where its key has
payload_buf. It writes its payload, its counts and the draw's record into a storagebuffer, and the mesh program reads that buffer and culls workgroups past their task workgroup's count by calling
OpSetMeshOutputsEXTwith 0 and 0. The renderer fills the record, dispatches the task program (directly, or withvkCmdDispatchIndirect), and barriers its writes to the mesh stage and the draw's record. Native stays for a devicethat 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):
native path lost the GPU at the first indirect task+mesh gang, in three runs.
of it (each run is one run of the same script).
OpSetMeshOutputsEXT; theworkaround (0 and 0 before the return) is in the commit.
Tests without a game:
test_mesh_task_computeintests/shader_sm86.cruns the task and mesh modules intests/support/spv_eval.cand 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_meshdraws the same depths through the nativepath, the compute path and an indirect record, and
vulkan_headless_mesh_nativechooses the native path.ctestpasses 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 thevk-descriptors-mode=2 --draw-state-check=1mesh check, which fails 5 of 10 runs on a pristinemainbuild 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 onthis 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_shaderstill 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_shaderstill 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.SPDX-License-Identifier: GPL-3.0-or-laterand the project's copyright line.docs/CREDITS.md. (No code was ported; the issue's reference projects were read for behavior only.)