Repository navigation
rdna2spirv: route remaining 16-bit high-half readers through u16_half/i16_half (SHADER-HIGH-HALF-SHARED-READERS) - #2366
Conversation
…/i16_half (SHADER-HIGH-HALF-SHARED-READERS)
|
Independent verification on Linux (Python 3.15.2, CPU semantic interpreter, no game files), tested in a clean detached worktree at
Code review notes: all 7 remaining high-half extract sites in AI-assisted: yes (Antigravity) |
|
I ran synthetic shaders for all seven changed instruction families through Vulkan on a physical RTX 4090 (Windows 11, NVIDIA 616.64). Readbacks from
The compute cases exercised signed and unsigned high-half compares, SDWA For D16 stores I used the project's All 10 generated modules per revision passed |
lixonik
left a comment
There was a problem hiding this comment.
Windows 11: all 6 targeted high-half semantic tests passed, including the new shared-reader coverage. No findings.
AI-assisted.
wavehs
left a comment
There was a problem hiding this comment.
macOS arm64 check of #2366 (SHADER-HIGH-HALF-SHARED-READERS). The whole change is the translator plus one semantic test, so it runs fully here; the GPU part is MoltenVK/KosmicKrisp, not the gfx1036 the rule is about.
Tested head b176c9f5a merged onto main bdbc7e923 as merge 1f6268c23 (clean; git merge-tree clean too, the branch is 17 commits behind).
Environment: Apple M3 Pro, arm64 (subgroups 4..32), macOS 27.2.1, CPython 3.15.2, SPIRV-Tools v2026.4, llvm-mc 23.1.5, MoltenVK 1.4.0; KosmicKrisp and lavapipe = Mesa 26.3.0.
The new test passes, and its control bites
python -I tests/semantic/test_high_half_shared_readers.py:Ran 6 tests ... OKat the head and after merging ontobdbc7e923.- Negative control (test kept,
tools/rdna2spirv.pyput back tomain's):FAILED (failures=11)covering all six test methods. Every failure is the structural assert -OpBitFieldUExtract %uint %t1 %c10 %c10still emitted - and none is a valueassertEqual, which is the useful part: onspirv_mini_interpthe old and new modules evaluate to the same values, so this is a lowering change, asdocs/design.mdrow:532says, not a value change. - The author's listed suites also pass here:
test_image_cube_store_glc.py(OK, skipped=1),test_image_store_d16.py,test_alu_mad_u16.py,test_alu_sad.py,test_alu_qsad.py,test_valu_int16.py,test_vcmp16_opsel.py,test_mutations.py,test_negative_controls.py, plustests/test_pk16_diff.py.tests/test_u16_high_half.pyneeds pytest, which the system interpreter here does not have; I did not set up the venv for it, so it is unrun.
No regressions
- Semantic suite: 500 files / 6,367 tests / 0 files failed at
mainbdbc7e923; 501 files / 6,373 tests / 0 files failed at the merge (+1 file, +6 tests = the new file). - GPU fixtures (268): MoltenVK 195 PASS / 3 FAIL / 70 SKIP, KosmicKrisp 190 / 5 / 73, at both
mainand the merge; the PASS/FAIL/SKIP lines are identical once the per-run temp directory is normalised. The 3/5 failures are the pre-existingmainones (cs_fma_fused,cs_imgatomic_ext,ps_ssharpon MV;cs_bvh,cs_bvh32,cs_imgatomic_ext,ps_cndmask_sign_mods,ps_valu16_mad_selon KK). This is a driver check that the lowering keeps the values, not a check of the 25.10.36 gfx1036 miscompile.
Findings
- GPU coverage of the new rule is partial, and the doc row already says "not yet GPU-verified", which is accurate. Of the seven families,
runtime/test/shadersexercises onlyv_mad_u32_u16/v_mad_i32_i16(ps_valu16_mad.asm,ps_valu16_mad_sel.asm,cs_w32_misc_ext.asm), SDWAWORD_1(ps_sdwa_dword_hi.asm),v_pk_mul_lo_u16with a constant (cs_pk_mul_lo_const.asm), and a bufferd16store (cs_fmt_d16_xyz.asm, not theimage_store ... d16path). There is no fixture forv_cmp(x)_*_{u16,i16}withop_sel,v_sad_u16,v_qsad_pk_u16_u8/v_mqsad_pk_u16_u8,v_pk_{add,sub,min,max,mad}_{u16,i16}, orimage_store ... d16. A smallps_/cs_fixture for sad+qsad and one value-checkingimage_store d16would make the rule measurable on any GPU, instead of only on the CPU interpreter. - The new test does not run
spirv-val:translate_ps/translate_cscallrdna2spirv.translate()and inspect the text. Theimage_store d16case asserts only the absence of the extract and the two shift opcodes, with no value check (test_image_store_d16_uses_shared_high_half_shifts). A%int/%uinttype slip in that store path would pass it. The existingtests/semantic/test_image_store_d16.pydoes validate and passes, so the path is covered today, but routing the new cases through a validating helper (or asserting the operand types) would make the new test self-contained. - Scope note, not a defect: field extracts at offset 16 with a width other than 16 remain, e.g.
tools/rdna2spirv.py:11573(%c10 %c7, a wave control word) and:4278(%c10 %c14, a stride). The measured 25.10.36 report and this row are width-16 only, so that is consistent; if the driver's offset-mod-16 behaviour is not width-specific, the row should say so, because those sites are outside this rule.
python -I scripts/check_no_game_data.py on the three changed files: clean. git diff --check: clean.
No game files. AI-assisted.
tiguan26
left a comment
There was a problem hiding this comment.
Approving b176c9f.
The remaining readers of a 16-bit high half (the SDWA and op_sel compares, the 16-bit field reads, the packed accumulator, the v_*_u16/i16 pair ops and the FSPX f16 reads) now go through u16_half/i16_half like the others, with one new as_uint bitcast where a signed half feeds a uint slot; there is one definition of each helper in the merged file, so nothing shadows another.
test_high_half_shared_readers.py 6 passed (6 subtests). Merged onto main d1dff7949 together with #2397, #2416 and the other three of this series below (no conflicts), on Linux with Python 3.13. The full translator suite (run_semantic_tests.py tests/semantic) on that tree has only the 8 failures main has here (7 in test_fspx_dot4_op_sel_disasm, test_int32_to_f64), and tests/test_translate.py only main's own ps_sdwa_f16_const.asm (an llvm-mc version difference in this environment). AI-assisted (Claude Code, Claude Opus 5.5).
Item ID:
SHADER-HIGH-HALF-SHARED-READERSSummary
Routes all seven remaining 16-bit high-half readers in
tools/rdna2spirv.pythrough the sharedGen.u16_half/Gen.i16_halfhelpers, eliminating every remainingOpBitField{S,U}Extract ... 16 16across the translator (AMD Windows driver 25.10.36 on gfx1036 miscompiles offset-16 width-16 bitfield extracts by taking the offset mod 16 and reading the low half instead of the high half; seedocs/design.md"16-bit high-half reads", #1506 / SHADER-777):Gen.compare(v_cmp(x)_*_{u16,i16}withop_selhigh half)Gen.sdwa_src(src*_sel:WORD_1, both unsigned andsext())v_pk_{add,sub,mul_lo,mad,max,min}_{u16,i16}v_qsad_pk_u16_u8/v_mqsad_pk_u16_u8v_sad_u16v_mad_u32_u16/v_mad_i32_i16image_storewithd16Also adds
Gen.as_uint()alongsideGen.as_int()for clean%int->%uintbitcasts afteri16_half(), updates the "16-bit high-half reads" contract row indocs/design.md, and addstests/semantic/test_high_half_shared_readers.py. Does not touchv_pk_lshlrev/lshrrev/ashrrev_b16(covered separately by #1111).Verification
spirv_mini_interp; no local GPU/Vulkan/spirv-valinstalled)python -I tests/semantic/test_high_half_shared_readers.py -v-> 6/6 OK (structural + bit-exact semantic parity across all 7 families)test_image_cube_store_glc.py,test_image_store_d16.py,test_alu_mad_u16.py,test_alu_sad.py,test_alu_qsad.py,test_valu_int16.py,test_vcmp16_opsel.py,test_mutations.py,test_negative_controls.py-> all OKpython -I tests/test_text_write_line_endings.py-> 3/3 OKpython -m compileall -q tools/rdna2spirv.py tests/semantic/test_high_half_shared_readers.py-> exit 0python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_high_half_shared_readers.py docs/design.md-> exit 0git diff --check-> cleanorigin/main(tools/extracted fromorigin/main):tests/semantic/test_high_half_shared_readers.pyfails 6/6 tests (11 failures across every op family:OpBitField{U,S}Extract %uint ... %c10 %c10emitted at all 7 sites).