mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1282] [CLOSED] shader_disasm: list a wave64 program for wave64 (TOOLS-DISASM-WAVE-SIZE) #1313
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1313
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1282
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/tools-disasm-wave-size📝 Commits (1)
f6290b4shader_disasm: list a wave64 program for wave64 (TOOLS-DISASM-WAVE-SIZE)📊 Changes
4 files changed (+140 additions, -4 deletions)
View changed files
📝
docs/design.md(+9 -0)➕
tests/semantic/test_disasm_wave64_mask_pair.py(+81 -0)📝
tests/test_fspx_unpack.py(+18 -2)📝
tests/test_shader_library.py(+32 -2)📄 Description
Rebased onto
bfef489catf6290b41. Main already sets the disassembler wave size. This diff adds coverage through FSPX unpacking, pipeline-library extraction and translation. The four focused suites passed 91 tests with one skip.Claimed in the coordination issue as: TOOLS-DISASM-WAVE-SIZE (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. #1021 (open, SHADER-W64-SDST-PAIR) repairs the same listings from the other side:
widen_wave64_masksintools/rdna2spirv.pyturns a single-register mask operand into the pair once a program is known to be wave64. The integration branch had that repair too (widen_wave64_valu_masks); it is the same change as #1021 and is not in this pull request. This one makes the disassembler write the pair in the first place, which #1021 does not touch (it says the listings "come from llvm-mc without+wavefrontsize64"). The two do not conflict and either order works: with both, a new listing already has the pairs and the repair finds nothing to widen; an old listing is repaired by #1021. #998 (open) addscompute=Trueto the same twodisasm.disasm(...)calls infspx_unpack.pyandshader_library.pyand a parameter todisasm(): a textual conflict on those lines, both keywords stay. Merged three-way with each open pull request that touches these files (its diff applied to the base, then merged into this branch): #623, #908, #861, #583 and #1021 merge cleanly; #998 conflicts on those two call lines and nowhere else. #957 and #281 also changetools/shader_disasm.py, but their diffs do not apply to this base, so they were not tried.What and why
llvm-mc lists the lane-mask operands of a VALU instruction for the wave size it is told, and wave32 is its default for the CPUs used here. For the same bytes (llvm-mc 23.1.5,
gfx1013):-mattr=-wavefrontsize32,+wavefrontsize64v_cmp_gt_u32_e64 s8, 40, v0v_cmp_gt_u32_e64 s[8:9], 40, v0v_cndmask_b32_e64 v5, 2, 3, s10v_cndmask_b32_e64 v5, 2, 3, s[10:11]v_add_co_ci_u32_e64 v5, s8, v5, 4, s10v_add_co_ci_u32_e64 v5, s[8:9], v5, 4, s[10:11]v_cmp_gt_u32_e32 vcc_lo, 48, v0v_cmp_gt_u32_e32 vcc, 48, v0The same holds for the SDWA compares,
v_cmp_class, the other carry instructions,v_div_scaleandv_mad_[ui]64_[ui]32. Nothing else differs: same instructions, same printed encodings.A wave64 program writes and reads both registers. The translator takes the listing at its word, so from the default listing the high register keeps its old value, and a later 64-bit scalar use of the pair (
s_mov_b64 exec, s[8:9],s_and_saveexec_b64, av_cndmaskon a pair thats_mov_b64wrote) gives lanes 32..63 the wrong bits.shader_disasm.disasm(code, mcpu, backend, wave32)already takes the wave size, andshader_disasm.pyalready reads it from the FSSM header, but only the Python decoder (--backend python) used it. The llvm-mc backend, the default, ignored it. Andfspx_unpack.py --disasmandshader_library.py --disasmdid not pass it, although both have the program's dispatch state (wave32in the index they write).This pull request:
-mattr=-wavefrontsize32,+wavefrontsize64to llvm-mc whenwave32is false; the command for a wave32 program is byte for byte what it was;fspx_unpack.py --disasmandshader_library.py --disasmpass the wave size of the dispatch state. A graphics program of the pipeline library has no dispatch state and keeps the default, as before;docs/design.md, "Disassembling shaders".What changes for a build. The FidelityFX, BVH and pipeline-library steps name
shader_disasm.pyamong their tools and are redone. The game's own shaders are disassembled again only whendisasm.doneno longer matches (it records llvm-mc, not the tool), so an existing work folder keeps its listings until that step is redone; both spellings are valid input for the translator. Bydocs/design.md23,841 of the 26,503 shaders are wave64, so a fresh disassembly lists those with pairs andvcc.Not measured: the corpus. No game shader was disassembled or translated for this pull request, so there are no before and after counts of translated and
spirv-val-clean shaders. What was measured is below, on hand-written programs. #1021 reports a full-corpus run of the equivalent translator-side change on its author's stack (26,503 translated before and after); that is its measurement, not one made here.Tested
Linux (CachyOS, kernel 7.3.5), Python 3.14, LLVM
llvm-mc23.1.5. One commit on6293c1c4f.python3 -I tests/test_shader_disasm.py: 32 tests pass (30 before, 2 new).test_llvm_mc_is_told_the_fssm_wave_sizeruns the tool on a synthetic FSSM blob with a stand-in for llvm-mc that prints the-mattroption it was started with: the option is there under a wave64 header and absent under a wave32 one.test_real_llvm_mc_names_the_mask_pair_of_a_wave64_programuses the real llvm-mc and is skipped without one that has the AMDGPU target: a hand-encodedv_cmp_gt_u32_e64is listed withs[8:9]under a wave64 header and withs8under a wave32 one.python3 -I tests/test_fspx_unpack.py: 35 tests pass, 1 skipped as on the base (1 new):fspx_unpack.py --disasmwith the stand-in, once with a wave64 and once with a wave32 dispatch state.python3 -I tests/test_shader_library.py: 22 tests pass (1 new):shader_library.py --disasmwith the stand-in on a synthetic library. The wave64 compute program gets the option; the wave32 compute program and the pixel program do not.python3 -I tests/semantic/test_disasm_wave64_mask_pair.py(new, 3 tests pass): a hand-written wave64 program of nine instructions, its words given in the file, goes throughshader_disasm.disasm(), the translator and the test interpreter on 64 lanes. One test takes the Python decoder's listing and needs nothing else; it passes on the base too and is the control. One takes llvm-mc's listing and is skipped without llvm-mc. One checks that the wave32 listing of the same bytes is what it was.6293c1c4f; the threetests/test_*.pyfiles of this branch beside itstools/, andLEONIDA_TOOLS_DIRfor the semantic file): 5 tests fail. The stand-in is started without the option intest_shader_disasm.py,test_fspx_unpack.pyandtest_shader_library.py(3), the real llvm-mc listss8(1), and intest_llvm_mc_listinglanes 33..39 store 7 instead of 9 and lane 52 stores 9 instead of 7: 56 of 64 lanes right, 64 of 64 with this change.ci.ymlruns it (compileall, everytests/test_*.pyoutsidetests/semantic, the semantic suite, the tracked-file guard), on the committed tree: one failing file,tests/test_imhex_patterns.py, which fails on the base commit too and is the only one there. Semantic suite: 471 files, 6,171 tests, 0 files failed (the base: 470 files, 6,168 tests; the difference is the new file).python3 -I scripts/check_no_game_data.py: passes.A sweep that is not part of the change (
llvm-mc23.1.5, the translator of the base): 24 hand-written wave64 compute programs, one or two per affected form and three with a 64-bit scalar use of the mask, each disassembled with the default and with the wave64 option, translated natively and with--wave64-emulate(48 pairs of translations) and run on 64 lanes where the test interpreter has the instructions.v_div_scale_f32programs are refused from both (4 of 48).s[8:9]followed bys_mov_b64 exec, s[8:9](lanes 33..39 and 52 wrong, withs9preset to 0x100001), the same withs_and_saveexec_b64, andv_cndmask_b32_e64on a pair written bys_mov_b64 s[8:9], 0xff(lanes 32..39 wrong). 19 give the same 64 words from both listings, and 3 the test interpreter cannot run (an instruction it lacks).Not run: the game's shader corpus and its FSPX and pipeline-library programs (see above), llvm-mc 21 (the option is the one
runtime/test/shaders/*.asmalready name in their; mattr:lines), a GPU, native Windows or macOS, the runtime build (no C++ or build file changes).GPUs tested: none (the disassembler command line, a CPU interpreter).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.docs/design.md, "Disassembling shaders".🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.