rdna2spirv: a wave64 VALU mask operand printed as one SGPR is the pair (SHADER-W64-SDST-PAIR) #1021
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1021
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1021/head"
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?
@DadaCap on GitHub · 2026-11-24 17:00 UTC · original
DadaCap:w64-sdst-pair→main· +114 −0 · 3 files · 1 commits · merged 2026-11-24 22:49 UTCClaim: SHADER-W64-SDST-PAIR (#14).
The shader listings come from llvm-mc without
+wavefrontsize64, so a VALU instruction's lane-mask SGPR is printed as one register:v_cmp_gt_u32_e64 s8, ...for thes[8:9]a wave64 writes,v_cndmask_b32_e64 ..., s10for thes[10:11]it reads. The translator wrotes8alone. A scalar 64-bit instruction prints the pair, andmask_srcgives lanes 32..63 the high register's bit (since804f4aeff), so afters_mov_b64 exec, s[8:9]those lanes had whatevers9held before. The semantic tests print the pair, so none of them saw it.widen_wave64_masksmakes the operand the pair once a program is known to be wave64:v_cmp_*with an SDST, the carry out and in ofv_*_co_*,v_div_scale,v_mad_[ui]64_[ui]32and the mask ofv_cndmask.How it was found: a 128-thread pipeline-library compute shader (
lib_cs_03141) hung an RTX 5080 (device lost) while the retail title's loading screen runs. The translated shader also loops for ever intest_wave64_emulate_opt.run_emulated_workgroupwith the title's own constants; with this it ends after 76 barriers, and the title gets past it.Tested
tests/semantic/test_wave64_single_sdst.py(new): both printed forms translate to the same module, natively and emulated, and all 64 lanes are run. Onmain: 2 failures, 1 error.scripts/run_semantic_tests.py tests/semantic: 470 files, 6,165 tests; the one file that fails,test_image_cube_store_glc, cannot start llvm-mc on this machine (FileNotFoundError).--wave64-emulate, on my boot stack (mainplus other open pull requests): 26,503 translated before and after, the 2,671 pipeline-library programs too, none lost. I did not runspirv-valover the new modules separately; the translator's own assembly step accepted them all.The modules have to be translated again (
make_game.py --stages shaders).AI-assisted (Claude Code, Opus 5.5).
🤖 Generated with Claude Code
@quartz-heron-58 on GitHub · 2026-11-24 17:29 UTC · original
Retail check on a second NVIDIA card, with the fence loss made visible by #1028 (which builds on #980).
Setup:
boot-prototypeat9173e790plus #980 and #1028 cherry-picked; RTX 4080, driver 621.24, Windows 11 26300, MSVC; own 1.0.2.1 copy;LEONIDA_LAZY_PSO=1,LEONIDA_GPU_REGION_MB=10240,LEONIDA_AUTOPRESS=1, the OBS capture layer disabled, noLEONIDA_SKIP_INT3. Shaders: the whole stage translated again (main corpus, pipeline library, FSPX, BVH, executable) with this pull request's commitbc7143b5merged with #674, #593 and #957. One conflict, with #674:widen_wave64_masksandrestore_vcc_tuplesare added at the same place intools/rdna2spirv.py; I kept both.test_wave64_single_sdst.py,test_vcc_tuple_fallback.pyandtest_dpp_compare.pypass in that tree. 26,503 of 26,503 corpus shaders and 2,623 of 2,684 library programs translate and passspirv-val, the same counts as without this commit.UINT64_MAX, thenvkDeviceWaitIdlereturningVK_ERROR_DEVICE_LOSTVK_EXT_device_faultreportINSTRUCTION_POINTER_UNKNOWN, addresses0x2000af410to0x2000af700INSTRUCTION_POINTER_FAULTat0x2000ceee0, and one entry of typeNONEwith address0xb700000000, precision0x1000nvlddmkmevent 153 at the stopSo on this card the device is still lost during the load, but not the same way: the report changes from the hang shape to a fault with an address, about 12 s later. That fits the endless dispatch being gone and a second problem behind it. One run with the fix, so it shows the change, not a rate.
Lines that are in the log of the run with the fix and in none of the 12 earlier runs on this machine, all just before the loss: first calls of list slots 85, 51, 129, 61, 39, 86 and 26 and device slot 71;
unimplemented ID3D12Device8::CreateSamplerFeedbackUnorderedAccessView;ExecuteIndirect with a DISPATCH_MESH signature is not replayed yet; nothing was recorded;RehydrateRaytracingAccelerationStructureBatched2X is not implemented yet; E_NOTIMPL;WriteToSubresource/ReadFromSubresource staging copy failed; replay result 10. I have not established which of them, if any, leads to the fault.Not checked: whether
lib_cs_03141is dispatched in my run (I do not log dispatches), and the semantic suite beyond the three files above. On your note thatVK_EXT_device_faultreported nothing for the hang: here it answers only aftervkDeviceWaitIdlehas returnedVK_ERROR_DEVICE_LOST; before that the count query returnsVK_ERROR_UNKNOWN(details in #1028).Counts and driver addresses only, no game data. AI-assisted.
@fin-github on GitHub · 2026-11-24 18:00 UTC · original · reviewed
tests/semantic/test_wave64_single_sdst.pyon the PR: 3 tests OK. The same file againstmain(32950551e):2 failures and 1 error, so it catches the bug.
unittest discover -s tests/semantic -p "test_wave64*.py": 268 tests OK.Question: the e64 forms can also print
vcc_loas the SDST (v_cmp_gt_u32_e64 vcc_lo, ...,v_cndmask_b32_e64 ..., vcc_lo).widen_wave64_masksleavesspecialoperands alone, whichtest_wave32_keeps_single_registersasserts for the e32 case. I see the existingvcc_lohandling(
vcc_half_keeps_mask,rdna2spirv.py:1629, and the mask-destination path near 6058). Does that already give thee64
vcc_loSDST the full VCC in wave64? If so, a single line in the docstring or the design.md row would save thenext reader from asking the same thing.
Nit: in
elif op.startswith("v_") and "_co_" in op or op in (...),andbinds tighter thanor, which is whatyou want here. Parentheses would make that clear at a glance.
Tested on Windows 11 Pro 26200, CPython 3.14.4, MSVC from VS 18 Community, applied on main
32950551e. No GPU or game files used. AI-assisted (Claude Code).@DadaCap on GitHub · 2026-11-24 18:07 UTC · original
@quartz-heron-58 thank you, this is a very useful check, and the
vkDeviceWaitIdletip works here too: with it, my report gives an address where the fault query answered nothing before.Two of your new lines are explained:
CreateSamplerFeedbackUnorderedAccessView: it is console device slot 71, the unordered-access twin of slot 70 (a view from a resource description, a view description and a GPU address). Forwarded to the PC method it writes nothing, so descriptor tables keep leftover memory and the culling programs read it as V#s. Details in #14 (finding of today, next to RT-TITLE-TEXTURE-VIEWS / #1079).ExecuteIndirect with a DISPATCH_MESH signature: #424 and #429 replay it.After both, the remaining fault on my RTX 5080 was a read in a 24 GiB GPU window (protection
0x801) outside the region. Covering it with a sparse buffer gave one run with no device loss; that run still ended later in an access violation I have not looked into.On the conflict with #674: keeping both functions is right.
AI-assisted.
@milk4sale on GitHub · 2026-11-24 18:14 UTC · original
Tested on another setup, with counts over the whole corpus (1.0.2.1, all 26,503 listings, llvm-mc backend), this head
bc7143b5falone:v_cmp_gt_u32_e64 s4, 40, v1(default) and... s[4:5], ...(+wavefrontsize64) to the same eight bytes.main, 13,314 wave64 shaders (7,120 PS, 4,918 MS, 664 CS, 612 VS) read such a pair back with a 64-bit scalar op while the mask analysis knew nothing of the high register: 162,431 reads, mostlys_and_b64(86,137),s_or_b64(50,843) ands_and_saveexec_b64(15,399).--wave64-emulate: 26,503 translated, 26,503 passspirv-val. 19,453 modules differ frommain1504c1af6, all wave64 (MS 9,282 of 9,282, PS 8,021 of 10,974, VS 1,169 of 2,236, CS 786 of 1,154, GS 195 of 195); none of the 2,662 wave32 modules changes.wave64_halves.py --census). The halves analysis took the pair for "a lane mask combined with a register that is not one". With this change 504 shaders leave tier C and none enters it: A 5,059 -> 5,267, B 101 -> 397, C 8,245 -> 7,741;tainted-branch6,534 -> 1,181.s_and_b64,s_or_b64,s_xor_b64,s_andn2_b64,s_and_saveexec_b64,s_mov_b64 exec,s_bcnt1/s_ff1and SCC, with another mask, 0 or nothing in the high register beforehand): RTX 4070 Ti, Linux, driver 620.70.06, subgroup 32,LEONIDA_W64_EMULATE=1.mainstores none of its eight ISA-derived words, this branch all eight. It is #1090, stacked on this one (TEST-W64-SDST-PAIR-GPU).scripts/run_semantic_tests.py tests/semanticon this head plus that fixture: 472 files, 6,176 tests, 0 files failed.s_wqm_b64 exec, execbecomes visible to the halves analysis, and 452 more pixel shaders leave tier C.Not checked: a 64-wide device (
--require-wave64), and the retail title. Counts and opcode names only, no game data. AI-assisted (Claude Code).@thesubtleties on GitHub · 2026-11-24 19:21 UTC · original
Tested
bc7143b5f(#1021) and9f1a072f7(#1090), each merged onto main3aa97542. NVIDIA RTX 3080 (620.73.04) and AMD Raphael RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS.cs_w64x_cmp_sdstpasses on gfx1036 with native 64-wide subgroups, and withLEONIDA_W64_EMULATE=1on gfx1036 and the 3080. With main'srdna2spirv.pyit fails in all three (16384 16384, five0xffffffff,1).run_semantic_tests.py tests/semantic: 471 files / 6,171 tests (#1021) and 472 / 6,179 (#1090), 0 failed.This runs translated SPIR-V, not native RDNA2 code. Not tested: game corpus. AI-assisted (Claude Code)
@aslan2142 on GitHub · 2026-11-24 22:49 UTC · original
Merged. Thanks, and thanks to everyone who tested it. Checked locally on
main0f98d193c+bc7143b5f:SHADER-W64-SDST-PAIRwas posted at 16:38 UTC, before this PR, and is unedited.tests/semantic/test_wave64_single_sdst.py: againstmain's translator it gives 2 failures and 1 error; with this PR all 3 tests pass.test_docs_*files,test_text_write_line_endingsandcheck_no_game_data.pyon the three changed files are clean.s105or above. A slice of 832 shaders translates and passesspirv-val832 of 832 before and after.milk4sale,thesubtletiesandquartz-heron-58.On
fin-github's question: yes, ane64vcc_lomask already means the full VCC in wave64:mask_dststoresvcc_loto the whole%vccandmask_srcloads%vccfor it. A line saying so in the docstring would help the next reader.Two small things for a follow-up, neither blocking:
test_wave32_keeps_single_registerscalls the helper directly, so the wave32 path itself isn't exercised.#1090 and #1091 are stacked on this one and can move now.
AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).