Repository navigation
rdna2spirv: s_bfm_b64 in wave32 code is 64-bit data, not a lane mask - #6809
Conversation
958 compute programs of the pipeline library (docs/shader_library.md) have a kind-0 dispatch state that says wave32, and 905 of them use *_saveexec_b32. The translator refused all of them with "FSPX wave32 dispatch state contradicts wave64 code", and in every one the only wave64 marker is s_bfm_b64. They use it to build an S# in place: s_bfm_b64 s[88:89], 2, 54 and s_mov_b64 s[90:91], 0x18500000, then image_sample with s[88:91] as the sampler (3,342 of the 3,475 are `2, 54`; the rest are `1, 63`, `32, 8`, `32, 32` and `32, 0`). A 32-lane wave has no 64-bit lane masks, so there: * translate: D = ((1 << (S0 & 63)) - 1) << (S1 & 63) goes to the SGPR pair as data, through mov64, so the S# words stay known constants (literal samplers). A run-time operand is Unsupported (none is seen). * lane_masks.step/analyse take wave64 (default True, so other callers are unchanged) and leave the result data in wave32. Without that it was a per-lane mask, which read a sampler word as 0 or ~0. * The FSPX wave32 check doesn't count s_bfm_b64. Every other marker still refuses, and the FSSM checks and the no-header heuristic are unchanged. tests/semantic/test_wave32_bfm64_data.py runs the value in every invocation for nine (size, offset) pairs, the constant sampler word, and the refusals. Its value cases fail without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Checked |
|
Tested 5341416 merged onto main b4adb75 on NVIDIA GeForce RTX 3060 12 GB (Ampere), driver 610.88, Windows 11 Pro 26300, MSVC (VS 2022 Build Tools), llvm-mc 23.1.6, runtime built with
Adds an NVIDIA/Windows run to the RDNA4/RADV one above. No game files. AI-assisted (Claude). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
In tools/rdna2spirv.py, wave32 s_bfm_b64 with constant operands now emits mov64 of ((1 << (S0 & 63)) - 1) << (S1 & 63); run-time operands raise Unsupported. translate() tracks the marker set so s_bfm_b64 no longer contradicts an FSPX wave32 dispatch state. tools/lane_masks.py:step()/analyse() take a wave64 flag and leave the result as data in wave32. New test_wave32_bfm64_data.py and a docs/design.md row cover the rule.
Why merge
Unblocks 958 pipeline-library wave32 compute programs that were wrongly refused as "wave64 code", and produces the constant sampler words actually used to build their S# in place rather than per-lane masks. Direct static-recompilation coverage gain.
Verdict: Approve
SummaryIn Why mergeUnblocks 958 pipeline-library wave32 compute programs that were wrongly refused as "wave64 code", and produces the constant sampler words actually used to build their S# in place rather than per-lane masks. Direct static-recompilation coverage gain. Verdict: Approve |
Claimed in #5781 (comment).
Problem
958 compute programs of the pipeline library (docs/shader_library.md) have a kind-0 dispatch state that says wave32 (word 4 bit 20), and 905 of them use
*_saveexec_b32.translate()refuses all of them with "FSPX wave32 dispatch state contradicts wave64 code". In every one, the only wave64 marker iss_bfm_b64.They use
s_bfm_b64to build an S# in place:3,342 of the 3,475 uses are
2, 54; the rest are1, 63,32, 8,32, 32and32, 0.Dropping the check alone would be wrong. The translator always treats
s_bfm_b64as a per-lane mask, so each invocation would hold 0 or ~0 in the sampler words, and the module would still passspirv-val.Change
A 32-lane wave has no 64-bit lane masks, so in wave32 code:
((1 << (S0 & 63)) - 1) << (S1 & 63)goes to the SGPR pair as data, throughmov64, so the S# words stay known constants and the literal-sampler path still sees them. A run-time operand isUnsupported; none occurs.lane_masks.stepandanalysetakewave64(defaultTrue, so other callers are unchanged) and leave the result as data in wave32.s_bfm_b64. Every other marker still refuses, and the FSSM header checks and the no-header heuristic are unchanged.Wave64 behaviour is unchanged.
Effect (counts only)
The 958 programs, disassembled with llvm-mc 23.1.5 for
gfx1013:main561b65a8spirv-valMost of the rest stop at the next problem: 585 at "v_cmp destination", which is
v_cmp_*_e64 vcc_hiin wave32 code. That keeps a 32-bit lane mask invcc_hi, which the translator models only as half of wave64vcc; it is a separate change. The others are alit(...)operand (68, #6808), "mask destination" (59), ands_loadwith avccbase (38).Tests (CPU, no game data)
tests/semantic/test_wave32_bfm64_data.py(new) uses the FSPX sidecar withwave32: true, the real case:image_sample;s_bfm_b64no longer refused, while another wave64 marker still is;lane_masks.stepwith and withoutwave64.The value cases fail on
main.Related suites pass:
test_lane_masks,test_salu_bfm64_add_i32,test_wave64_halves,test_wave64_halves_soundness,test_fspx_rules,test_salu_diffandtest_crosslane_fuzz. That is 288 passed, 2 skipped.With rdna2spirv: write the compute thread-group SGPR (TG_SIZE_EN) #6446, shader_ir: read LLVM 23's lit(V) operand as the constant V #6808 (
lit(V)) and this one merged locally:tests/semantic,tests/test_lane_masks.pyandtests/test_shader_ir.pygive 6,210 passed, 1 skipped, 1 xfailed, no failures.docs/design.md: the "Wave64 handling" row.Not GPU-verified. AI-assisted (Claude Code). Windows 11, Python 3.12, no GPU used.
🤖 Generated with Claude Code