Repository navigation
fix(rdna2spirv): lower s_bitreplicate_b64_b32 to EXEC and wave64 VCC (SHADER-1289) - #8842
Cryptoteep wants to merge 1 commit into
Conversation
…(SHADER-1289) Lower s_bitreplicate_b64_b32 destination writes to EXEC and wave64 VCC in compute shaders, deriving each lane's bit from scalar source bit L // 2. In compute shaders, each lane L in [0..63] evaluates: (s0 >> (lane_id // 2)) & 1 and stores to %active (for EXEC) or %vcc (for VCC), preserving SCC. Also recognize s_bitreplicate_b64_b32 on EXEC/VCC as a wave64 marker in code_w64 and mark VCC mask state in lane_masks.py. Contract: docs/design.md row for s_quadmask / s_bitreplicate. Verified with synthetic tests in tests/semantic/test_salu_b32_lane_masks.py.
|
Tested
No game files. AI-assisted (Devin). |
Grimkaaah
left a comment
There was a problem hiding this comment.
Independent Linux CPU review (74859f4d)
What changed: rdna2spirv lowers s_bitreplicate_b64_b32 to EXEC and wave64 VCC (SHADER-1289).
Checked: focused tests 10 OK.
Looks correct; no game files. Note other open rdna2spirv.py PRs may need rebase order.
|
Linux Vulkan validation of the new wave64 EXEC and VCC paths at
For each dispatch I compared the entire 128-word output from Every module assembled as SPIR-V 1.5 and passed Synthetic inputs only. AI-assisted (Codex). |
|
AMD Windows wave64 GPU and silicon check of 74859f4, merged with current The test shader is a wave64 compute shader (group 64,1,1, run with
This adds the AMD proprietary Windows driver to the RADV check above. I didn't re-check SCC preservation here; the PR's CPU tests and the RADV run cover it. Windows 10 22H2, AMD Radeon iGPU gfx1036 (driver 32.0.13036.4), Vulkan SDK 1.4.363. The RTX 5070 Ti has no 64-wide subgroup, so it can't run the wave64 path. Synthetic values only, no game files. AI-assisted (Claude Code). |
|
Independent GPU validation of the NEW EXEC/VCC destination paths at 74859f4: pass. Bazzite 45, RTX 3070 (Ampere, 32-wide physical subgroups), NVIDIA 620.73.04, Python 3.15.2, LLVM 23.1.6, SPIRV-Tools 2026.4. Khronos core/synchronization validation enabled. Synthetic fixtures only. I assembled two compute fixtures with llvm-mc gfx1013 +wavefrontsize64, one writing EXEC and one writing VCC with s_bitreplicate_b64_b32. Both take the source word and initial SCC selector from runtime user SGPRs. They write a result for all 64 logical lanes and a second 64-word array recording SCC. The EXEC fixture initializes its result before masking and restores EXEC before storing both arrays; the VCC fixture observes the result through v_cndmask. 608 GPU dispatches, 77,824 output words, zero mismatches:
The per-lane reference was (word >> (lane // 2)) & 1, with SCC unchanged, matching AMD's RDNA2 ISA, bit-wise/SOP1 instruction tables. Negative control: main 867d922 refuses both special-destination fixtures; this is not merely another run of cs_w32_new_ops, which does not cover these destinations. Full semantic suite: 447 files / 5,959 tests; only test_image_atomics_guard and test_image_store_d16 fail, matching the known main baseline. Focused semantic checks: test_salu_b32_lane_masks.py 10/10, test_salu_quadmask_bitreplicate.py 7/7. This is translated Vulkan behavior on NVIDIA, not a new native AMD measurement. AI-assisted with Codex. |
|
Hardware GPU verification: AMD Radeon RX 6800 (gfx1030), Windows 11, AMD 26.11.2, Vulkan 1.4.363 Head
AI-assisted run (Claude Code). |
|
macOS arm64 verification (Apple M3 Pro) — Tested PR head Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2.
+2 tests over the baseline (the two new methods), no new failures; the two ( The Found: a The new branch accepts if d["t"] == "exec":
self.set_exec(bit)
else:
self.emit(f"OpStore %vcc {bit}")
Reproduced through the test file's own helpers: asm = ["s_mov_b64 vcc, -1", # VCC = 1 in all 64 lanes
"s_bitreplicate_b64_b32 vcc_lo, s4", # write VCC_LO only
"v_cndmask_b32 v4, 0, 1, vcc", # read VCC back as a mask
...store v4 per lane...]
spv = translate_cs("w64_bitreplicate_vcc_lo", asm, 64)
run_cs(spv, 64, s4=0)
So a shader that writes VCC_LO and later uses VCC as a mask would silently drop every pixel/thread in the upper half. This is precisely the class of bug the PR is trying to fix for Verified fix. Use the existing half-aware writer instead of the bare store: if d["t"] == "exec":
self.set_exec(bit)
else:
self.put_mask(d, bit, "lo" if self.wave64 else "")I patched that in and ran both widths: wave64 gives Why the tests miss it: they cover Two smaller points: No game files. AI-assisted. |
|
@wavehs, about the
So SDST 106 on a 64-bit op is printed The bare AI-assisted (Claude Code). Synthetic values only. |
|
Tested 74859f4 on Windows 11, CPU-only (no game data, no GPU): the VCC-destination path has a correctness bug, and both the EXEC and VCC paths share a scope gap with #8526. VCC write stores a raw 0/1 bit instead of the project's mask representation. Every lane-mask value elsewhere in this translator ( Repro ( Expected: lanes 0-1 -> 0, lanes 2-63 -> 1 (bit 0 of the source replicates to lanes 0 and 1; NOT flips every lane). Got on this head: all 64 lanes -> 1. #8714's No AI-assisted review. |
|
GPU and silicon confirmation of @CreaCloudz's VCC finding. This also corrects my last comment: the The test is a wave64 compute shader (group 64,
So on AMD Windows hardware, a NOT after the VCC write keeps lanes 0 and 1 on. Through an SGPR pair it's right, because that path already goes through the mask form. My earlier 12/12 VCC run only read VCC straight back with Storing Windows 10 22H2, AMD Radeon iGPU gfx1036 (driver 32.0.13036.4), Vulkan SDK 1.4.363. Synthetic values only. AI-assisted (Claude Code). |
|
Thanks for this! #8714 fixes the same |
Coordination claim
Item: SHADER-1289
Depends on: #8526
What changed
Translate
s_bitreplicate_b64_b32destination writes to EXEC and wave64 VCC in compute shaders:(word >> (lane // 2)) & 1).%active(for EXEC) or%vcc(for VCC), preserving SCC as required by the RDNA2 ISA specification.tools/lane_masks.pyto recordMASKstate onvccfors_bitreplicate_b64_b32.tools/rdna2spirv.py:16505to recognizes_bitreplicate_b64_b32onexec/vccas a wave64 marker incode_w64.docs/design.md.Verification
tests/semantic/test_salu_b32_lane_masks.py:test_bitreplicate_writes_exec_and_keeps_scc: verified all 64 lanes and SCC preservation for words0,0x80000001,0x0f0f0f0f,0x55555555,0xAAAAAAAA, and0xFFFFFFFF.test_bitreplicate_writes_wave64_vcc_and_keeps_scc: verified all 64 lanes viav_cndmask_b32and SCC preservation for the same patterns.tests/semantic/test_salu_b32_lane_masks.pypassed.tests/semantic/test_salu_quadmask_bitreplicate.pypassed.scripts/check_no_game_data.py.