rdna2spirv: a lane mask read as a number is the wave's mask word (SHADER-MASK-AS-DATA) #1043
Open
github-bot
wants to merge 3 commits from
github-bot/gh-1043 into main
AGit
pull from: github-bot/gh-1043
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1043
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1043"
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?
@thesubtleties on GitHub · 2026-11-24 17:08 UTC · original
thesubtleties:mask-as-data→main· +307 −18 · 10 files · 3 commits · openClaimed in the coordination issue as: SHADER-MASK-AS-DATA
What and why
A lane mask is one word for the wave on hardware; the translator keeps each lane's own 0 / ~0. An op that read the mask as a number therefore got a different wrong value per lane, with no error: with mask
0x3ff,s_add_u32 d, mask, 1was 0 or 1 andv_mov_b32 v, maskwas 0 or ~0 (crosslane_fuzz.py"maskdata", the old #293).s_bcnt/s_ff/s_flbitalready rebuild the word. This does the same for:lane_masks.NUMBER_READERS);v_mov_b32of a mask, when nov_readfirstlane_b32or vector bitwise op reads that value as a mask. Each copy is followed forward, through VGPR-to-VGPR copies (second commit).The emulation planner counts such an op as an exchange, it never joins an active run, and
wave32_pixel_scan.pycounts it asmask_word.Partial on purpose. Not covered: the values excluded above (the v_mov / v_or3 / v_readfirstlane idiom needs each lane's own bit), compares, SDWA and DPP, and 16-bit, float and 64-bit ops.
Three existing tests changed:
test_salu_movrels_lane_mask,test_scselect_b64_dataandtest_salu64_bitwise_dataread a mask back withv_mov_b32and expected the lane's own 0 / ~0; they now expect the mask word.Tested
Measured on base
82a2aabc, then rebased; the semantic suite and the touched tests were rerun after the rebase.tests/semantic/test_mask_as_data.py(wave32, native wave64, partial EXEC, the through-a-VGPR idiom, emulated translation): fails onmain, passes here.run_semantic_tests.py: 0 files failed.crosslane_fuzz.py, hard mismatches, main -> this PR; no program fails here that passed on main:--ext, seed 880606 (300), 3080 and gfx1036--ext, seed 880707 (300), gfx1036The 880xxx main rows were run on
98a977b4. With--no-maskdatathere are no hard mismatches there on main. Correction: the first version of this text said the remaining mismatches werev_readfirstlanereads. Minimizing them showed most came from a plain VGPR-to-VGPR copy that the first commit counted as a mask read; the second commit fixes that. What is left on wave32 seeds 991201, 991202 and 993301 (11 mismatches, plus 4 programs with a hypothesis op) is now minimized on the 3080: every reduction contains av_mov_b32of a mask into a VGPR that av_readfirstlane_b32or a vector bitwise op then reads, the idiom this PR leaves alone. The shortest isv_cmp_ne_u32_e32 vcc_lo, 9, v6/v_mov_b32_e32 v2, vcc_lo/v_readfirstlane_b32 s8, v2. The wave64 leftovers (seed 880606 emulated on the 3080, seed 880707 native on gfx1036) minimize to the same idiom. Caveat: two hard reductions stayed at 14 and 17 lines, where the pattern is present but not shown to be the cause, and the six programs with a hypothesis op (4 wave32, 2 wave64 native) are not explained.cf_diff.py: 2,000 programs on the second commit (wave32 and wave64), 0 mismatches.run_gpu_tests.py: per-test results identical to main: 3080 201/252, 3080 emulated 233/252, gfx1036 234/252, gfx1036 emulated 234/252; only the two known tfe fixtures fail (#31). Rerun on the second commit.GPUs tested: NVIDIA RTX 3080 (620.73.04) and AMD RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS Linux 7.3.5
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.@morodirule on GitHub · 2026-11-24 17:10 UTC · original
Independent Linux check (stdlib only, no game/GPU): all four files pass on head
02d62939f— test_mask_as_data 9/9, test_salu64_bitwise_data 11/11, test_salu_movrels_lane_mask 3/3, test_scselect_b64_data 12/12. Same files against the unmodified tools fail 172+9+32+2 respectively, so the tests fully exercise the change. Not claiming; review evidence.@KernelSmoker on GitHub · 2026-11-24 17:24 UTC · original · approved these changes
Verified on exact head
02d62939f6(base96e1e22261). Focused tests pass: new mask-as-data 9/9; updated SALU64, MOVRELS and SCSELECT regressions 11/11, 3/3 and 12/12; lane-mask, planner and pixel-scan unit suites also pass (including wave64 emulation 31/31). One additional SPIR-V validation test skipped becausespirv-as/spirv-valare absent. The full semantic run covered 471 files / 6,174 tests; onlytest_sopc_validationandtest_unary_f16_validationfailed, both because those executables are missing, so I do not report the full suite as green. Changed-file no-game-data/diff checks and merge-tree pass. The addeddocs/design.mdcontract entry is present. CPU semantic validation only; no local GPU or game-data run.@thesubtleties on GitHub · 2026-11-24 17:28 UTC · original
Thanks @morodirule and @KernelSmoker. I pushed a second commit, so your checks cover
02d62939fand not the new head. It changes only howlane_masks.number_movesdecides whichv_mov_b32copies are read as numbers: a VGPR-to-VGPR copy no longer counts as a mask read. Wave32 fuzz mismatches go from 10 to 0 (seed 880505). My earlier explanation of those 10 was wrong, and the description is corrected. AI-assisted (Claude Code).@Sangonapou on GitHub · 2026-11-24 18:24 UTC · original
Tested
68b964e4on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, and a GPU before/after withcrosslane_fuzzRuntime built with
scripts\build_runtime.ps1(MSVC 19.51; this PR changes no runtime file);llvm-mc23.1.6, SPIRV-Tools 2026.4. No game files.crosslane_fuzz.py --wave both --modes both --programs 300 --seed 20261123(the samevk_compute_test), on this PR's based4de3a7dand at this head. "Flagged" = programs reported asmismatch, including the hypothesis-op ones; every flagged program in both columns containsmaskdata:--dpp--extThe base counts are identical to a run of the same seed on
main867d922fthe day before, so the drop is this change. 0 rejected and 0 harness errors in all runs. Still flagged at this head (seed 20261123, reproducible with--show):cs_xl32_2026173083373,cs_xl64_2026173083374,…396,…450,…524,…564,…632,…660--dpp:cs_xl32_2026173083409,…425,…639,cs_xl64_2026173083512,…528,…580,…642--ext:cs_xl32_2026173083373,cs_xl64_2026173083562Also at this head:
test_mask_as_data.py13 OK,test_salu64_bitwise_data.py11 OK,test_salu_movrels_lane_mask.py3 OK,test_scselect_b64_data.py12 OK (unittest discover). GPU suite: 261 shaders, 261 translated, 261 pass spirv-val; native 201/252, emulated 233/252; the only failures arecs_imgload_tfe/cs_imgload_d16_tfe, as onmainon this card (#892).@thesubtleties on GitHub · 2026-11-24 18:54 UTC · original
More evidence on head
68b964e42; no code change.tools/wave_diff.py --masks-as-data(CPU only, seed 551117, 2,000 programs per wave size), main3aa97542against this branch:The first remaining failure in each is a
v_mov_b32of a mask followed by av_readfirstlane_b32of that VGPR, the idiom this PR leaves alone. I did not check the other 26 one by one (that tool has no minimizer).The wave64
crosslane_fuzz.pyleftovers from the description are minimized now (seed 880606 emulated on the 3080, seed 880707 native on gfx1036): all 4 contain the same idiom, the shortest beingv_cmp_ge_u32_e64 vcc, v6, v1/v_mov_b32_e32 v5, vcc_hi/v_readfirstlane_b32 s8, v5. The description is updated to say so.Not tested: the game corpus and RDNA2 console hardware. AI-assisted (Claude Code)
@MynFriend on GitHub · 2026-11-24 19:53 UTC · original · edited 2026-11-24 19:57 UTC
Tested
68b964e42on an RTX 3080 with--wave64-emulate. A synthetic loop counting four set bits should return 4 in every lane. GPU readback returned 32 in four lanes and 2 in the other 60. A local change that converts the lane mask to a scalar word before entering the loop returned 4 in all 64 lanes. Both modules passed Vulkan 1.2 validation. AI-assisted test, no game files used.Local translator change. On entry to the scalar bit-scan loop,
s8represents the low half of a per-lane mask. On the back edge,s_mov_b32 s8, s14carries an ordinary scalar after clearing one bit. The analysis drops the mask classification at the join. The firsts_ff1_i32_b32then sees a different value across lanes. The local fix gathers the low 32 predicate bits into one uniform word at the entry zero-test, while the source is still known to be a mask (Gen.lane_mask_word). It stores that word in the SGPR and treats the register as scalar on both outgoing paths and at the loop header. The fix was tested on an experimental translator branch with single-wave, 64-thread compute groups.Reproduce on the PR head with Python only
From the repo root at
68b964e42, run the following Python. Each of the 64 output words should be 4. The interpreter printsCounter({2: 60, 32: 4}), matching the RTX 3080 readback.For the GPU check, the same
asmwas assembled withspirv-as --target-env vulkan1.2and validated withspirv-val --target-env vulkan1.2. The module was run withvk_compute_test scan.spv 1 inspectandVKC_DUMPset to an output file. All 64 little-endian uint32 values in the dump were counted.@thesubtleties on GitHub · 2026-11-24 22:35 UTC · original
Thanks @MynFriend, I reproduced this in the CPU interpreters at
68b964e42: wave64 native and emulated, and a wave32 version. Main82a2aabcgives the same wrong values, so it isn't a regression, but this PR doesn't fix it. It's a mask meeting plain data at a join, where the analysis drops the mask.While checking I found a straight-line relative:
s_xor_b32of a mask and plain data reads one lane's bit. I have a local prototype for that second case only (semantic suite clean, no GPU run yet). If you'd like to send your entry-test fix as its own PR, please do; I won't start on the loop case.CPU only. AI-assisted (Claude Code)
@thesubtleties on GitHub · 2026-11-24 23:50 UTC · original
Native RDNA2 (gfx1036,
tools/hw_oracle): all 21 programs left over in the description (15 hard, 6 with a hypothesis op) match the fuzzer's model, so those are translator bugs, not model errors. Four short versions of the idiom also match. The cause is still shown only for the short reductions.GPU suite on this head: the only failures are the two
tfefixtures fixed by #892. AI-assisted (Claude Code)@thesubtleties on GitHub · 2026-11-25 04:03 UTC · original
Rebased by merging main
bfef489c; two conflicts, both independent additions.test_slot67_operand_formsloses anexpectedFailurethat this fixes.Semantic suite: 488 files / 6,292 tests, 0 failed. GPU suite on the 3080 and gfx1036, native and emulated: per-test identical to main. Earlier approvals cover older heads. #1397 overlaps; I commented there. AI-assisted (Claude Code)
@ammonium231 on GitHub · 2026-11-26 01:56 UTC · original
RTX 3090 / 621.40, crosslane fuzz with maskdata, seed 309700: mismatches go 56+29 -> 12+9 (w32+w64) with this PR. Remaining are still mask-as-data, e.g. cs_xl32_30970929176 (native, group 50):
minimized repro
s14: expected 0x00000000; threads 0-31 got 0xfffeef3a, threads 32-49 got 0x0002ef3a.
@ammonium231 on GitHub · 2026-11-26 08:15 UTC · original
Fix for the remaining mismatches: https://github.com/ubiquitarianism/leonida/compare/thesubtleties:mask-as-data...ammonium231:fix-1043-number-moves (on top of this PR, 4 files, +123/-10). number_moves dropped a plain v_mov of a mask when a later v_readfirstlane / v_and read the copy, so inactive lanes leaked into the mask. RTX 3090 fuzz, 2000 programs/seed, --dpp --ext: 309700 984/12/4 + 989/9/2 -> 1000/1000 both waves; held-out 309900 (36 failing) and 310100 (29 failing) -> 0, no new failures. Semantic suite 6296/0.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.