shader: lower SDWA forms of exact f32 arithmetic in pixel_aot #329
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/334"
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 Its3rr0rsWRLD on 2026-11-21T22:32:01Z.
Depends on #329. This branch contains #329's commit, so please review it after #329. Once #329 merges, only the second commit remains.
Change
This lowers the SDWA forms of the exact binary32 arithmetic that
pixel_aotalready handles in e32/e64 form. On gfx1013 that isv_add,v_sub,v_subrev,v_mul,v_mul_legacy,v_max,v_min,v_floor,v_ceil,v_fractandv_trunc(_f32_sdwa).ALUtemplate, with source modifiers, inline constants andclamp.sdwa_dest:dst_selbyte, word or dword, withUNUSED_PADorUNUSED_PRESERVE.src0_sel:DWORDandsrc1_sel:DWORD. A byte or word source would reach the arithmetic as a zero-extended, usually subnormal binary32. Scarlett's binary32 denormal mode is not measured, so those forms stay refused.mul:2,div:2) and asrc1_selon a one-operand instruction.v_rcp,v_sqrt,v_rsq,v_logandv_exp. They are approximations on the GPU, and this change only covers what can be compared bitwise.Verification
Commit
b860dd5plus #329 and this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.pixel_aot_hardware: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.pixel_aot_warp: Passed on WARP 10.0.26100.9818.b860dd5and 58 with #329 alone; the four extra draws are the four programs below. Every draw reportsdebug_errors=0andmax_absolute_error=0.tests/pixel_aot_check.py binarypasses with the four programs in the binary fixtures: LLVM 15.0.6llvm-mcandllvm-objcopy, disassembled throughlibLLVM-17.soandlibLLVM-18.soon Linux. The controls,tests/docs_links_check.pyandtests/bidi_controls_check.pypass.Evidence and follow-up
The fixtures are synthetic. Programs 0 to 2 draw each of the eleven operations once. Together they cover:
clampon a result of 5.25;BYTE_3.Program 3 keeps a product's low word in
WORD_0and a floor result's low byte inBYTE_2of 1.0 underUNUSED_PRESERVE. It reads both back exactly. It also pads the low word of a product intoWORD_1.The reference is Python binary32 arithmetic on the constant words, and every value is exact in binary32 and after the half export. Sixteen wrong references, one per channel, each report
pixel_mismatch. One of them caught my own first draft, which expecteddst_sel:WORD_1to keep the high word. Both adapters wrote the low word, as the LLVM equivalencev_lshlrev_b32 16⇔dst_sel:WORD_1says. The reference now uses the low word, and the high-word reading is kept as a wrong reference.This branch merges cleanly with #288, #293 and #324.
Checklist
AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.
🤖 Generated with Claude Code
https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T23:11:40Z.
Rebased onto the updated #329 (
e99c9bc). The SDWA arithmetic branch now uses the strictersdwa_destfor partialUNUSED_PRESERVEresults instead of its own destination check, with controls forv0,v8andv20(ceaa756). The only rebase conflict was thecheck_controlsblock, and both sets of controls are kept.Rerun on Windows 10 Enterprise 26H2 build 26300.9974 with
ctest --preset dev --no-tests=error -R '^pixel_aot_' -V, merged with current main (bc24dfd):pixel_aot_hardware(RTX 4070 Ti, driver 32.0.16.1088) andpixel_aot_warp(WARP 10.0.26100.9818) pass with 63 draws each against 55 on main. Every draw reportsdebug_errors=0andmax_absolute_error=0.tests/pixel_aot_check.py binarypasses on Linux with LLVM 15.0.6 tools and libLLVM 17 and 18.AI-assisted: yes. Claude Opus 5.5 replying from this account.