shader: lower gfx1013 24-bit integer multiplies in pixel_aot #536
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/542"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-22T10:11:32Z.
Change
Lower gfx1013 24-bit vector integer multiplies in
tools/pixel_aot.py, covering both VOP2 (_e32) and VOP3 (_e64) encodings (+8 forms in bothgfx1013.tsvandrdna2.tsv):v_mul_u32_u24(_e32,_e64): unsigned 24-bit multiply(S0[23:0] * S1[23:0])low 32 bits viamul24_u32.v_mul_i32_i24(_e32,_e64): signed 24-bit multiply(sext24(S0) * sext24(S1))low 32 bits viamul24_i32(unsigned multiply of sign-extended operands to avoid signed overflow UB).v_mul_hi_u32_u24(_e32,_e64): unsigned 48-bit product shifted right by 32 viamul24_hi_u32using 12-bit partial products in pure 32-bituintarithmetic.v_mul_hi_i32_i24(_e32,_e64): signed 48-bit product arithmetic-shifted right by 32 viamul24_hi_i32(pulling inmul24_hi_u32automatically in dependency order, with exact two's-complement carry whenlo == 0).All four helpers are emitted lazily via
SALU_HELPERSusing pure SM 6.0 32-bit integer arithmetic (no 64-bit integer shader capability required), keeping existing shader outputs unchanged byte for byte. Float source modifiers,clamp, SDWA forms, out-of-range VGPRs (v256+), WQM blocks and pending-load or pending-sample hazards are rejected. Added LLVM assemble/disassemble coverage, batched draw tests (--check-pixel-batch) across five constant sets with six wrong-mode controls and a mutated-shader control (v_mul_hi_i32_i24_e32->v_mul_hi_u32_u24_e32), form-coverage assertions intests/form_coverage_check.py, and documentation indocs/experiments.md.Verification
Tested on Linux x64 at commit
1430530(based on914d241) with Python 3 (requirements-dev.txtinstalled) and LLVM 23.1.4 (llvm-mc,llvm-objcopy,/usr/lib/libLLVM.so):python -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy /usr/lib/libLLVM.so: passed.python -B tests/form_coverage_check.py: passed (verifies all 8VOP2/VOP3forms ingfx1013.tsvandrdna2.tsv).python -B tests/pso_readiness_check.py: passed.LLVM_LIB=/usr/lib/libLLVM.so LLVM_MC=llvm-mc LLVM_OBJCOPY=llvm-objcopy python -B tests/rdna2_tools_check.py: passed (33 tests, OK).python -B tests/docs_links_check.py: passed (10 Markdown files, 112 links).python -B tests/bidi_controls_check.py: passed (506 tracked files).Could not run DXC / D3D12 WARP or hardware draws locally on Linux (missing Windows SDK, DXC and D3D12 runtime); Windows CI runs
pixel_aot_blend_scalar_warpandpixel_aot_blend_scalar_hardware.Evidence and follow-up
All fixtures are synthetic gfx1013 assembly programs written directly in
tests/pixel_aot_check.py(MIT). Because the upper byte (bits [31:24]) is ignored by hardware and signed negative products withlo == 0(such as-2^23 * 512 = -2^32) require adding 1 to~hi, the draw batch includes nonzero upper bytes on every constant set and explicit negative controls for unmasked 32-bit operands, signed/unsigned swaps and missing low-zero carry. Follow-up work can lowerv_mad_i32_i24/v_mad_u32_u24andv_mul_lo_u32/v_mul_hi_{i32,u32}.Checklist
AI-assisted: yes.