Skip to content

wave64_halves: a buffer access without idxen through a literal V# with ADD_TID_ENABLE reads by lane (SHADER-833) - #4655

Open
tedin7 wants to merge 2 commits into
ItsNotRexed:mainfrom
tedin7:shader-833
Open

tedin7 wants to merge 2 commits into
ItsNotRexed:mainfrom
tedin7:shader-833

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

Claimed in the coordination issue as: SHADER-833 (#4571 (comment))

What and why

Finding by @shdann (#4571): tools/wave64_halves.py gave tier A to a buffer_load without idxen through a V# with ADD_TID_ENABLE. Without idxen that bit adds the wave lane to the index (idxen ignores it, docs/design.md "Swizzled buffer addressing"), so the loaded value depends on how the wave is cut: lane 40 reads index 40 in a wave64 and index 8 in a half.

  • tools/wave64_halves.py: a MUBUF/MTBUF access with no idxen whose V# word3 is a literal (written earlier in the block by the same scalar folds rdna2spirv records in sgpr_imm: s_mov_b32/s_mov_b64 (word3 as the high half of a pair), s_movk_i32, s_pack_*, s_bfm_b32, s_not_b32, s_and/lshl/lshr_b32, s_mul_i32; mirrored in Analysis.literal_sgpr because the analysis runs before the translator emits a block, so its sgpr_imm cannot be imported or read) with bit 23 set gets the raw lane-id taint: the load result, a store's address and an atomic's address. Reason is the existing lane-id, so no new reason code. A literal with the bit clear, and every access with idxen, are unchanged.
  • docs/design.md, SHADER-10 row: the run-time V# assumption (tiers A and B take ADD_TID_ENABLE as 0 without idxen through a run-time V#), credit to @shdann, and the follow-up (count bound V#s with bit 23 at run time, needs the game).

Tested with numbers

RunPod pod only. test_wave64_halves.py, test_wave64_halves_soundness.py, test_wave64_halves_fixtures.py, test_wave64_graphics_scan.py together:

  • before (origin/main + the new tests): 160 passed, 3 failed (the ones that must fail). First fix commit with the new tests: the s_mov_b64 case fails.
  • after (this commit): 165 passed, 18 subtests passed, 0 failed.

New class AddTidBuffer (8 tests, incl. s_mov_b64 / s_pack / s_bfm word3 and offen, tbuffer load, buffer_store_format with bit set -> C, clear -> A): literal with bit set is tier C lane-id (buffer_load_dword, buffer_load_format_x); bit clear is tier A; idxen with the bit set is tier A; literal copied through another SGPR; store and atomic with bit set are C, with bit clear A; a run-time V# stays A (the documented assumption).

Not covered

  • Classification only: the wave interpreter on main cannot load from a physical-storage-buffer pointer (OpLoad of a "psb" access chain is unhandled), so there is no 64 against 2x32 run of a buffer load. wave64_halves: a buffer_load with idxen at a wave-uniform address gives a wave-uniform VGPR (new SHADER item) #4630 (read-only memory in spirv_wave_interp.py) would allow that test as a follow-up.

  • Run-time V# with the bit set: undecidable from the code, documented as an assumption.

  • Folds rdna2spirv has that are not mirrored (s_abs, s_sext, s_min/max, s_add/sub, s_xor/andn2 family, s_bfe, s_absdiff, s_lshlN_add): such a word3 counts as run-time. The bit counts even with SWIZZLE_ENABLE clear (conservative).

  • Corpus census not re-measured with this rule (needs the game); the census numbers in design.md predate it and may change.

  • Reviewed by an independent model (DeepSeek) before opening: it found that word3 literals built with s_mov_b64, s_pack_* or s_bfm_* were missed; fixed and pinned.

AI-assisted (Claude Code). No game files.

…dxen through a literal V# with ADD_TID_ENABLE (SHADER-833)
…s_pack, s_bfm, ...), pin offen/tbuffer/store_format (SHADER-833)
@Kev-Ball

Copy link
Copy Markdown

Tested f502d1fc on an NVIDIA GeForce RTX 3080 Ti (32-lane subgroups), driver 620.73.04, CachyOS Linux 7.3.5-2-cachyos. I rebuilt the Vulkan harnesses from this revision and selected the NVIDIA device explicitly.

The 8 AddTidBuffer classification tests passed. On the GPU, scripts/run_gpu_tests.py --filter cs_buf_swizzle --require-pass validated and passed: the no-idxen literal ADD_TID store left out[6:8] = [0xbeef0000, 0xbeef0001], as expected for lanes 0 and 1. The graphics regression run (build.py, then w64_graphics.py) validated 242/242 modules and reported 15 tier-A/B fixtures OK, 12 tier-C skips. This covers the 32-lane side; no native wave64 reference was available on this card.

AI-assisted verification with synthetic inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants