Repository navigation
Conversation
…GPR pair tools/shader_disasm.py disassembles every program in llvm-mc's default wave32 mode, so in a wave64 program a VOP3 lane mask that is s[6:7] prints as s6 (the encoding is the same in both modes). Gen.mask_src widened only s[6:7], so lanes 32-63 read s6's bits. For wave64 programs, widen_wave64_lane_masks now reads an even SGPR as the pair at the 64-bit mask positions: v_cndmask_b32_e64's condition, v_cmp_*_e64's destination, the carry of v_add/sub/subrev_co_u32, v_mad_u64_u32/v_mad_i64_i32 and v_div_scale_*, and both carries of *_co_ci_u32. Found through XboxBvhBuilder's PrefixSum256..4096 (TEST-594), whose upper half adds the lower half's total through v_cndmask_b32_e64 ..., s6 with s6=0, s7=-1. GPU fixture cs_w64_mask_pair_w32text (0 0 1 1 1 1 0 0; 0 0 0 0 1 1 0 0 before); tests/semantic/test_wave64_mask_pair_text.py requires the wave32-printed and pair-printed forms to translate to identical SPIR-V. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 39f62b5 on Windows, CPython 3.14.7, CPU only (no GPU, no game files): pass.
The GPU fixture was not run. No defect found. AI-assisted. |
…fix sums The runner now sets VKC_SUBGROUP_SIZE from index.json's wave64 flag, as check.py does: a wave64 program left to the device's default may run 32 wide. PrefixSum64..PrefixSum4096 are checked against their exclusive scan and total. On main the five wave64 ones fail at element 128 or 256 (a VOP3 lane mask printed as s6 for s[6:7], fixed by ItsNotRexed#3910); with ItsNotRexed#3910 all twelve checked programs match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated test:
Same machine and setup as my earlier manual reports. AI-assisted (Claude Code). |
|
Tested
AI-assisted (Gemini, Antigravity). |
|
Tested 39f62b5 on Windows 11, AMD Radeon iGPU gfx1036 (RDNA2, driver 26.10.1, subgroup 32..64, native wave64) and RTX 5080 (driver 616.92, subgroup 32), runtime built from this head (MSVC, RelWithDebInfo),
AI-assisted. |
|
Correction to my earlier comment (Tested 39f62b5): on this machine AI-assisted. |
|
Following up on @justr4mzi's
So adding AI-assisted. |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). |
jeremygold02
left a comment
There was a problem hiding this comment.
I compared aa2988cc with 39f62b5b on an independently indexed, 14-meshlet input. I passed the same default LLVM gfx1013 listing to both translators with --wave64-emulate --mesh-compute. The shader header selects wave64. I checked each emitted triangle's three indices and cull flag against the source index buffer.
| Diagnostic readback | Base | PR head |
|---|---|---|
| Correct triangle records | 498 / 809 | 809 / 809 |
| Valid triangles incorrectly marked culled | 311 | 0 |
| Exact vertex positions and UV pairs | 1,663 / 1,663 | 1,663 / 1,663 |
Every lost record on base came from lanes 32–63 of a logical wave. As a separate control, I disassembled the identical instruction bytes with LLVM's explicit wave64 setting. Translating that listing on an earlier revision produced the same complete output buffer as the PR head using the default listing.
I drew the head's captured positions, UVs and triangle indices with a diagnostic camera and three fragment checks (UVs, a uniform diffuse texture and a nonuniform texture). Each 320 × 96 RGBA32F frame matched a separate draw from the source geometry byte for byte, including all 8,062 covered pixels.
Both revisions used the same diagnostic change to forward the shader's own allocation count through a storage buffer. With the stock allocation path, the head still emitted a zero-count header for the first meshlet. The comparison isolates mask handling. End-to-end allocation and the original surface pixel shader remain separate.
The seven tests in test_wave64_mask_pair_text.py passed. Native Windows Vulkan on NVIDIA GeForce RTX 5070, driver 621.01, subgroup 32. Intel Core Ultra 7 265K, Windows 11 Home 25H2 build 26200.9974, LLVM 21.1.8. Only aggregate results are included here.
AI-assisted by Codex.
|
Corpus count + full-corpus SPIR-V diff + RX 9060 XT validation for the wave32-printed SGPR-pair mask fix. Corpus count (the "not measured" item)I ran the corpus disassembly through
The wave32-printed pair form is the common case for wave64 VALU mask operands in this corpus, not a rarity. Full-corpus SPIR-V diff, aa2988c vs 39f62b5Translated the whole corpus on both heads, same FSSM sidecars and options:
So this changes the emitted SPIR-V of about three quarters of the corpus's translated shaders. GPU validation, AMD Radeon RX 9060 XT (RDNA4)Windows 11, driver 32.0.32015.7029, native wave64 (subgroup 32..64,
First RDNA4 result for this PR. AI-assisted (Devin). |
|
Independent cross-GPU check of @Dom-in’s wave64 mask fix at For one group, the CPU reference predicted 128 vertices and 125 triangles. On an M3 Max through Leonida’s mesh-to-compute path, the baseline returned the right vertex and primitive counts but spuriously culled 61 triangles. Only 64 of the 125 index triples matched. With this PR’s change, all 125 matched, all 128 positions agreed within 2.04e-7, and the range checks recorded zero faults. The native RTX 5090 mesh path covered 180 pixels on the baseline and 261 after the change, matching the 261-pixel CPU reference. Explicit wave64 disassembly provided a separate positive control. These are controlled geometry checks with supplied draw constants, not a measurement of title frame selection. The separate RTX mesh-to-compute diagnostic returned an empty frame in this setup, so the RTX comparison above is for native mesh execution only. AI-assisted verification. Only aggregate results are included. |
Claim: #3574 (comment)
The bug
tools/shader_disasm.pydisassembles every program in llvm-mc's default wave32 mode. In a wave64 program, a VOP3 lane mask that is the SGPR pairs[6:7]therefore prints ass6; the encoding is the same in both modes, only the text differs. RDNA2's wave64 VOP3 SSRC2 and VOPC/VOP3b SDST are 64-bit pairs.Gen.mask_srconly widens an operand written ass[6:7](n == 2), so for the wave32-printed form, lanes 32-63 read the low SGPR's bits instead of the high one's.docs/design.mdcounts 23,841 of the corpus's 26,503 shaders as wave64, and they all reach the translator as wave32-printed listings. Every one that keeps a VALU mask in an SGPR pair, rather than VCC, was translated wrong in its upper half.How it showed up
XboxBvhBuilder's
PrefixSum256toPrefixSum4096(TEST-594, #3618) scan in place. Their upper half adds the lower half's total throughv_cndmask_b32_e64 …, s6afters6 = 0, s7 = -1. Translated as before and run 64 wide on an RX 9070, the scan restarted at 0 at element 128 or 256. With this PR, all seven prefix sums match their exclusive scan byte for byte.The fix
For a wave64 program,
widen_wave64_lane_masksruns once after the wave size is known. It reads an even SGPR as the pair at the 64-bit mask positions:v_cndmask_b32_e64's condition;v_cmp_*_e64's destination (v_cmpxwrites EXEC);v_add/sub/subrev_co_u32,v_mad_u64_u32/v_mad_i64_i32andv_div_scale_*;*_co_ci_u32forms.VOP2/VOPC take VCC implicitly (
vcc_lo), which is already handled. A listing already written withs[6:7]is unchanged, as is a wave32 program.Tests
tests/semantic/test_wave64_mask_pair_text.py: each wave64 program translates to identical SPIR-V whether written with pairs or with the single SGPRs shader_disasm prints. It covers thev_cndmaskcondition, av_cmp_e64destination read back, bothv_add_co_cicarries, and thev_mad_u64_u32carry. Unit checks cover the positions widened and the ones left alone: data operands,v_cmpx, VCC, odd SGPRs, existing pairs. A wave32 program isn't widened. Without the fix, 6 of 7 fail.runtime/test/shaders/cs_w64_mask_pair_w32text.asm, wired intocheck.pyandrun_gpu_tests.py:0 0 1 1 1 1 0 0on an RX 9070 at subgroup 64; before the fix,0 0 0 0 1 1 0 0. The write-then-read half already passed, because the translator keeps a mask av_cmpwrites as each lane's own bit, and it stays as a guard.check.py: 173 of 176 pass, 3 skipped (the mesh fixturesbuild.pydoesn't build), on the RX 9070.run_gpu_tests.py --filter cs_w64_mask: 3/3.tests/semantic,test_rdna2spirv*,test_wave64*,test_lane_masks*,test_translate*): 8,009 passed, 5 skipped, 1 xfailed, 0 failed. After rebasing ontomainaa2988c, the wave64, lane-mask and runner subsets give 408 passed.docs/design.md's Wave64 row records the rule and the checks.Not measured: how many of the corpus's wave64 shaders change. That needs the corpus disassembled, which I haven't run here. The rule only changes programs with a single-SGPR operand at those positions.
AI-assisted (Claude Code).
🤖 Generated with Claude Code