Repository navigation
rdna2spirv: bound structured nesting depth with the dispatch-loop form (SHADER-299) - #1993
Conversation
spirv-val's structured-control-flow checking cost grows roughly with the cube of the nesting depth: over the 1.0.2.1 corpus the deepest block sits 118 constructs deep and about 85% of validation time is in modules nested 20 or deeper. cfg_structure.depth() measures the tree and a module deeper than MAX_STRUCTURED_DEPTH (16) is emitted in the existing flat dispatch-loop form instead, which emits the same blocks and only changes the routing. Depth 5-12 shows no gain, hence the bound at 16.
|
Game-copy check of the driver side, which the Setup. My own 1.0.2.1 copy; a random sample of 400 modules (fixed seed; the two #884 giants excluded). Translated with
All pipelines compile in both forms, with no failures. The trade on this sample: about 24 s of So the bound might be better applied only where AI-assisted; counts and timings only, no game data. |
|
Tested 3e38c98 on AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.6-arch3.1, Linux 7.3.4-1-cachyos: pass.
Code read of |
- test_translate: #1904 caps structured depth at 16, so the #1993 dispatch-loop test lowers MAX_STRUCTURED_DEPTH. - test_ctest_registration: skip-code scan ignores conditional returns. - test_d3d12_stubs_generation: INCLUDE uses os.pathsep. - docs/README.md: one Other languages line. - first_light.py, make_game.py: LF text writes; stdout guard on three tools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent package validation of SHADER-299 on main at 4947579, including subsequent control-flow changes. On Windows 11 with an RTX 5070 (subgroup size 32, driver 32.0.16.1656), the first 200 sorted inputs all translated with wave64 emulation and passed spirv-val. Vulkan pipeline creation succeeded for 171 mesh and 29 pixel shaders, with zero failures or skips. The slice did not exercise the depth limit. A separate package pixel shader measured at nesting depth 18 selected the dispatch-loop fallback and successfully created a Vulkan graphics pipeline. This exercised compilation and pipeline creation only. The four CFG structure tests and the synthetic deep-nesting regression also passed. AI-assisted validation. |
|
Post-merge check of Translation, shards 0–3/16 (6,628 of 26,503 listings)
MoltenVK pipeline creation
So on the two drivers measured so far, NVIDIA and MoltenVK, the bound trades about 0.3 s of build-time validation per switched module for seconds to minutes of first-run pipeline compile per module, on the player's machine. I agree with @Thatters that it fits better as an option, or with a much higher bound. I'll post this as a finding in the coordination issue so someone can pick it up. From the diff, latent (no game shader hits it)
No game data. AI-assisted. |
VeTkN
left a comment
There was a problem hiding this comment.
Post-merge full-corpus check of 3e38c983 against its parent 89b047cd (git diff --stat between them: only this PR's 5 files), on my own 1.0.2.1 copy. make_game.py --stages shaders --jobs 11 (--wave64-emulate picked automatically), the same disassembly reused for every run. Ryzen 5 5500X3D (12 threads), Windows 11 Pro (10.0.26200), Python 3.14.7, llvm-mc 21.1.8.
89b047cd (parent) 3e38c983 (this PR)
translated / spirv-val 26,503 / 26,503 26,503 / 26,503 (both runs)
structured 13,066 7,199
dispatch loop 0 5,867
emulated wave64 rounds 10,149 10,149
straight line 3,246 3,246
barrier rounds 42 42
make_game.py wall time 2,727 s 2,415 s and 2,280 s
(check + shaders)
- 5,867 of the 13,066 structured modules (44.9%) switch to the dispatch loop, 22.1% of the corpus. Every other
control_flowcount is unchanged. make_game.py(check + shaders) was 312 s and 447 s faster on the two PR runs (11-16%). Run order was PR, parent, PR, with one parent run.- Driver-side pipeline compile time isn't measured here.
AI-assisted (Claude).
Item: SHADER-299 (tracker #1745).
spirv-valtime grows roughly with the cube of the structured nesting depth. Measured over the 1.0.2.1 corpus (26,503 modules,spirv-val2026.4):spirv-valtime is in modules nested 20 or deeper;spirv-valtime for one module in the settled vs the flat form: depth 20 181 -> 129 ms (1.4x), 30 507 -> 371 (1.4x), 50 1,712 -> 738 (2.3x), 64 2,692 -> 1,163 (2.3x), 77 5,122 -> 1,130 (4.5x), 118 13,683 -> 1,352 (10.1x);Change:
cfg_structure.depth()measures a tree fromstructure();rdna2spirvfalls back to the existing flat dispatch-loop form when the tree is deeper thanMAX_STRUCTURED_DEPTH(16) and recordsgen.nesting. Both forms emit the same blocks, in the same order; only the routing differs. The rule is in the "Control flow" row ofdocs/design.mdwith how it was confirmed.Tests:
tests/test_translate.py::test_deep_structured_nesting_uses_the_dispatch_loop: a tree above the bound comes out as the dispatch loop and passesspirv-val; raising the bound restores the structured form.tests/test_cfg_structure.py::test_depth: depth counts blocks at 0 and each guard/loop as one.py -3 -m pytest tests/test_translate.py tests/test_cfg_structure.py -q-> 473 passed, 2 skipped.--limit 200: 200 translated and 200 passspirv-valwith the default form, and 200/200 with--dispatch-loop.Counts and timings only; no shader text.