Repository navigation
Translator: --mesh-compute runs mesh shaders without VK_EXT_mesh_shader - #1053
Conversation
|
Tested 75014c0 on Windows 11 (runtime built from this PR's head, MSVC 14.51, llvm-mc 23.1.6). This is exactly the hardware the PR is for: an Intel UHD 770 has no
With mesh-as-compute the Intel results are identical to the native mesh-shader path on NVIDIA:
So on this iGPU the 9,282 mesh shaders now have a working path at all, where before every mesh test skipped. ctest: 33/33 on NVIDIA. The one Intel ctest failure is |
quackottu
left a comment
There was a problem hiding this comment.
Tested 75014c0 on NVIDIA GeForce RTX 5070 (subgroup 32), driver 621.24, Windows 11 Pro (26300), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (built with scripts/build_llvm_mc.ps1), scripts/run_gpu_tests.py:
- native: 74/101 passed, 27 skipped (
main8df277f here: 64/91 passed, 27 skipped, all wave64 tests needing a 64-wide subgroup) LEONIDA_W64_EMULATE=1: 101/101 passed (mainhere: 91/91)python -m unittest discover -s tests/semantic: Ran 1020 tests in 187.334s OK
75014c0 to
5ee88b0
Compare
|
Rebased onto
The (AI-assisted.) |
5ee88b0 to
0a653ee
Compare
|
Compared native
Both RGBA32F buffers matched the CPU prediction and were byte-identical between paths. For a separate negative control I kept the null bit set and changed only the generated readback VS predicate from |
9,282 of the 26,503 shaders are mesh shaders, and a device without VK_EXT_mesh_shader (NVIDIA Pascal, for one) can't run any of them. With --mesh-compute each becomes a GLCompute module with the same workgroup size and code; only the epilogue changes. After the same barrier, lane 0 writes the vertex and primitive counts, lane i its vertex and its primitive, into this workgroup's slot of an output buffer whose address is in push-constant dwords 36-37 (152 bytes). The slot layout is mesh_compute_layout() and the index records it as mesh_compute. - tools/mesh_compute_vs.py: the vertex shader that draws the slots with a non-indexed draw of groups * max_primitives * 3 vertices; unused and culled primitives are clipped away, params keep their locations. - vk_harness: VKH_MESH_COMPUTE (+ VKH_MESH_SLOT, VKH_MESH_PRIMS) dispatches the module, adds a compute->vertex barrier and draws. - run_gpu_tests.py / check.py: LEONIDA_MESH_COMPUTE=1 (check.mesh_env). - tests/test_mesh_compute.py; docs/design.md row "Mesh shaders as compute", docs/testing.md section. GTX 1060 (Pascal) with LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1: all five ms_* tests pass (SKIP before), zero validation messages. Mesh corpus: 9,282 of 9,282 translate and pass spirv-val with --mesh-compute --wave64-emulate, and all 9,282 generated vertex shaders validate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms
|
Tested 0a653ee on AMD Radeon RX 6800 (RDNA2, RADV NAVI21, Mesa 26.3.1, Vulkan 1.4.363), Arch Linux container on Linux 7.2.15: pass This is the first AMD result posted on this PR, and the first on a device that has both native
5/5 pass in every mode. Checks that the compute path actually ran:
Not run: the full suite with AI-assisted (Claude Code). No game files. The run used a rootless podman container with no network. |
0a653ee to
caad84c
Compare
|
Rebased again after #1127 merged (
Thanks @Vonsek for the native-vs-compute comparison with the null-primitive control, and @EchoTD for the RX 6800 run (EchoTD: the conflict you saw was before this rebase; it's mergeable again). (AI-assisted.) |
|
Tested caad84c (the merged head) on AMD Radeon RX 6800 (RADV NAVI21, Mesa 26.3.1), Arch Linux container: pass. Full run_gpu_tests.py with LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1 LEONIDA_BARY_FALLBACK=1 LEONIDA_TEXOFF_FALLBACK=1: 116/116. ms_* 5/5 native, mesh-as-compute, and mesh-as-compute + emulation, with raw readbacks byte-identical between native mesh and compute. AI-assisted, no game files. |
Claimed in the coordination issue as: mesh shaders without VK_EXT_mesh_shader (#634 (comment))
What and why
9,282 of the 26,503 shaders are mesh shaders (no task shaders). On a device without
VK_EXT_mesh_shader, theycan't run at all. NVIDIA Pascal is one such device: its #166 entry skips all five
ms_*tests. This adds an opt-intranslation that runs them there, the way
--wave64-emulateand--bary-fallback(#804) do for their gaps.tools/rdna2spirv.py --mesh-compute: each mesh shader becomes aGLComputemodule with the same workgroup sizeand code. Only the epilogue changes: after the same barrier, instead of
OpSetMeshOutputsEXTand the mesh outputs,They go into this workgroup's slot of an output buffer: the linear workgroup index ×
slot_bytes, in 64 bits.mesh_compute_layout(), recorded per shader asmesh_computein the index. Everything is16-byte aligned: a header, then the vertices, then the primitives. Each vertex holds its position, its clip and
cull distances padded to whole vec4s, and one vec4 per param. Each primitive holds three indices plus a culled
flag.
shaderClipDistance.tools/mesh_compute_vs.pywrites, from the index, the vertex shader that draws the slots with a non-indexedvkCmdDraw(groups × max_primitives × 3):max_vertices− 1, selects the vertex. Its position, distances andparams go out at the mesh shader's locations, so the pixel shader is unchanged.
ms_v5_workgroup's per-workgroup readback checks that.vk_harness:VKH_MESH_COMPUTE=<vs.spv>(withVKH_MESH_SLOT,VKH_MESH_PRIMS) dispatches the module overthe mesh grid into a zeroed output buffer, adds a compute→vertex barrier, then draws.
--mesh-group-readbackandVKH_SUBGROUP_SIZEwork as before.run_gpu_tests.pywithLEONIDA_MESH_COMPUTE=1translates with the flag, builds<name>.mesh_vs.spv, and runsthe five
ms_*tests through it.check.pyhasmesh_env, whichmesh_v5_testandmesh_w64x_testuse too.Docs: a contract row "Mesh shaders as compute" in
docs/design.md, the extra push-constant dwords, the indexkey, and a
docs/testing.mdsection.Design choice to review: the output address goes in push constants (144 → 152 bytes), which is simplest for the
translator and the generated VS; Pascal allows 256. The alternative is a storage-buffer binding in a set other than
0, which leaves push constants alone but gives the runtime another descriptor set to manage. I'm happy to switch if
that's preferred.
Not in this PR:
DispatchMeshinto dispatch, barrier and draw; that needs the graphics pipelines of Runtime: compute path and graphics draws on Vulkan (D3D-3, D3D-4, milestone M1) #291.Tested
AI-assisted change. NVIDIA GeForce GTX 1060 6GB (Pascal: no
VK_EXT_mesh_shader, subgroup 32), driver 560.94,Vulkan 1.3.280, Windows 10 22H2, Vulkan SDK 1.4.363.0, llvm-mc 23.1.6, MSVC 19.44, on main
067d3e8:run_gpu_tests.py --filter ms_:VK_EXT_mesh_shader).LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1: 5/5 passed.ms_tri,ms_w64x_ballotandms_wave_info_s3: 4096/4096 pixels exact.ms_clip: 2048/4096 covered, as expected.ms_v5_workgroup: 24/24 workgroup coordinates exact (2 × 3 × 4).LEONIDA_MESH_COMPUTE=1alone: 4/5 passed.ms_w64x_ballotskips: it needs exact wave64.run_gpu_tests.py: 66/101 passed without the variables and 97/101 with both, 0 failed either way.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation) on all five compute + draw runs: zeromessages.
--mesh-compute --wave64-emulate, onthe previous base
d1211d0(after the rebase, a 624-shader sample, every 15th, again translates, validates andgets valid vertex shaders):
spirv-val.MeshShadingEXTor a subgroup capability.spirv-val.none.
tests/test_mesh_compute.py(22 tests):--wave64-emulate: no mesh constructs, the exact storecount, the push-constant offsets, and
spirv-val.spirv-valfor 5 layouts, up to 18 params with clip and cull distances.mesh_env.d1211d0: 3363 passed. Two subtests oftest_audio_wav.pyfail identically on clean mainthere. After the rebase onto
067d3e8:test_mesh_compute.py,test_translate.py,test_run_gpu_tests.pyand
test_shader_checks.pypass, 347 tests.Checklist
docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms