rdna2spirv: route remaining 16-bit high-half readers through u16_half/i16_half (SHADER-HIGH-HALF-SHARED-READERS) #2366
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2366
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/high-half-shared-readers"
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?
Pull request successfully merged and closed
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).Independent verification on Linux (Python 3.15.2, CPU semantic interpreter, no game files), tested in a clean detached worktree at
main246791612with PR #2366 headb176c9f5a:git apply --check/git applyapplied cleanly with zero conflicts.main):python3 -I -m unittest discover -s tests/semantic -p test_high_half_shared_readers.py -v-> 6 tests run, 11 failures across all 7 op families (OpBitField{U,S}Extract %uint ... %c10 %c10still emitted).python3 -I -m unittest discover -s tests/semantic -p test_high_half_shared_readers.py -v-> 6/6 passed (Ran 6 tests).python3 -I scripts/run_semantic_tests.py tests/semantic-> 501 files, 6371 tests, 0 files failed in 99 s with 16 jobs.python3 -I tests/test_docs_links.py-> 17/17 passed.python3 -I tests/test_ci_registration.py-> 16/16 passed.python3 -I tests/test_text_write_line_endings.py-> 3/3 passed.python3 -m compileall -q make_game.py tools tests-> exit 0.python3 -I scripts/check_no_game_data.py docs/design.md tests/semantic/test_high_half_shared_readers.py tools/rdna2spirv.py-> exit 0.git diff --check-> clean.Code review notes: all 7 remaining high-half extract sites in
tools/rdna2spirv.pyroute cleanly throughGen.u16_half/Gen.i16_half(withGen.as_uint()added for signed->uint bitcasts), anddocs/design.mddocuments the contract update accurately as CPU-verified. No issues found.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
b176c9f5aaand its parent2467916120were bit-identical, and both matched the expected values.The compute cases exercised signed and unsigned high-half compares, SDWA
WORD_1with and without sign extension, packed arithmetic, multiply-add, SAD, and both masked and unmasked QSAD. The input high half varied by lane. All 8,064 output words per revision matched, including the signed multiply-add case where selecting the high half of the third operand zero-extends it.For D16 stores I used the project's
vk_store_testwith a scratch readback writer. Each dispatch wrote distinct low and high halfwords to four-channel float, unsigned and signed images. The comparison covered all three 8×8 images, including the untouched rows in wave32. Both revisions preserved negative zero in the float image and correctly extended the high halfwords in the integer images.All 10 generated modules per revision passed
spirv-val --target-env vulkan1.2. Every parent module contained an offset-16, width-16 bitfield extract and none of the PR modules did. This provides NVIDIA regression coverage. Reproducing the original AMD driver behavior still requires a gfx1036 Vulkan run.Approving b176c9f5a.
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/i16pair ops and the FSPX f16 reads) now go throughu16_half/i16_halflike the others, with one newas_uintbitcast 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.py6 passed (6 subtests). Merged ontomaind1dff7949together 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 failuresmainhas here (7 intest_fspx_dot4_op_sel_disasm,test_int32_to_f64), andtests/test_translate.pyonlymain's ownps_sdwa_f16_const.asm(an llvm-mc version difference in this environment). AI-assisted (Claude Code, Claude Opus 5.5).Verified head
b176c9f5a(vs parent246791612) on Windows 11 across both AMD Radeongfx1036(driver32.0.21030.2001/25.10.30.02, Vulkan SDK1.4.363.0Core + SyncVal) and NVIDIA RTX 5080 (616.64).Static & semantic checks:
v_cmp_*_u16/i16,sdwa_srcWORD_1unsigned &sext,v_pk_*,v_sad_u16,v_qsad_pk_u16_u8/v_mqsad_pk_u16_u8,v_mad_{u32_u16,i32_i16}, and D16image_store) throughu16_half/i16_halfeliminatesOpBitField{S,U}Extract ... 16 16while preserving signedness, packed component order, andv_mad_i32_i16third-operand zero-extension.tests/semantic/test_high_half_shared_readers.py— 6/6 OK.tests/semantic/test_image_store_d16.py— 5/5 OK.tests/test_u16_high_half.py— 33/33 cases PASS.Dual-GPU hardware checks (Vulkan SDK
1.4.363.0Core + SyncVal):ps_sdwa_dword_hi,ps_valu16_mad_sel,cs_pk_mul_lo_const): PASS (exit 0 under Core + SyncVal) on both AMD Radeongfx1036and RTX 5080.v_cmp_gt_u16/v_cmp_lt_i16op_sel:[1,1], SDWAWORD_1unsigned &sext,v_pk_{add_u16,sub_i16 clamp,mul_lo_u16,min_i16,max_u16,mad_i16},v_mad_{u32_u16,i32_i16}with0xffffthird-source high half,v_sad_u16,v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8, 512 readback words):246791612: 29OpBitField{S,U}Extract ... %c10 %c10sites in emitted SPIR-V; 0/512 mismatches on RTX 5080 andgfx1036driver32.0.21030.2001(note: the reported miscompile is on driver25.10.36, so this run provides additionalgfx1036+ Blackwell parity coverage rather than reproducing the25.10.36miscompile).b176c9f5a: 0OpBitField{S,U}Extract ... %c10 %c10sites; 0/512 mismatches on both AMD Radeongfx1036and RTX 5080 (0 VUIDs).No game data used. AI-assisted review (Codex static audit + Gemini dual-GPU verification).
#2366 | head
b176c9f5aafff117a49d22a84e54c64803aca632|python3 -m unittest discover -s tests/semantic -p test_high_half_shared_readers.py -v| red: 6 run, 11 failures | green: 6 passed | Red → greenBaseline failures included image_store_d16 high-half reads and the signed and unsigned SDWA WORD_1 cases.
Captured 15 distinct complete SPIR-V module(s) emitted while rerunning test_high_half_shared_readers.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.
Base
3bd936ecd98995bca3e1da83d5e28d2343001aefwas merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.Merged, thank you @ShotTechOp! This translator PR (rdna2spirv: route remaining 16-bit high-half readers through u16_half/i16_half (SHADER-HIGH-HALF-SHARED-READERS)) passed its own tests with main merged in during sodove's verification of this batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.