Repository navigation
shader: preserve signed zero in plain, packed and SDWA binary16 multiplication - #2779
Conversation
Refs R0Y00#2746. AI-assisted with Codex (GPT-6.2 Astra, xhigh).
tedin7
left a comment
There was a problem hiding this comment.
Review of head 3fdbaa4 (0 commits behind main).
Verdict: sound, no blocking findings.
What I checked
mul16(precise float product = a * b) is emitted once in the shared helper prelude (gfx2hlsl.pynearfma16o), and all three multiply paths go through it: plainv_mul_f16(VEC_H, also used by the SDWA path) andv_pk_mul_f16. No other binary16 multiply site was left on a plain*.- Binary16 operands widened to binary32 give an exact product, so
preciseonly changes the sign of zero results; the existingf16rnrounding after it is unchanged. - Cache key bump 24 -> 25 (graphics and
cs) is mirrored in the tests and docs that pin it. - Overlap: no other open PR touches this multiply line. Open #2741 (VOPC compares) and #2754 (interp pair) are different slices; merged #2738/#2739 added the packed and SDWA forms this PR fixes. The next PR that edits the same VEC_H row or bumps the key to 25 will need a trivial conflict resolution.
- Test: the draw check reads back on the GPU (the author reports
e000abcdon three adapters with FXC and DXC, and a control that gives6000abcd); the added Linux controls check the qualifier and call count for the plain, packed and SDWA forms.
Commands run locally (Linux)
- Python checks, all rc=0:
startup_gfx2hlsl_f16_alu_check,startup_gfx2hlsl_f16_alu_draw_check,startup_shader_cache_key_check,startup_gfx2hlsl_fract_check,startup_gfx2hlsl_buffer_store_check,startup_gfx2hlsl_const_copy_join_check,startup_compute_request_offline_check,startup_packed_position_provenance_check tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main...HEAD: clean- Mutation 1: remove
precisefrommul16->startup_gfx2hlsl_f16_alu_draw_checkfails (plain, packed and SDWA controls). - Mutation 2: revert
v_pk_mul_f16to{0} * {1}-> the same check fails (packed control).
Windows WARP run and the real-GPU run are separate and will be reported in a receipt comment.
AI-assisted; commands listed were executed locally.
|
Win2025 WARP receipt for head 3fdbaa4 (focused tests: the PR's own f16 ALU, draw, cache-key and sibling checks; WARP draw and hardware draw both ran, not skipped). Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
|
Post-merge receipt on the merged head Measurements only. The Environment
CommandsThe same hardware entry was also run on Observed on
|
Refs #2746. This covers the packed and SDWA half-multiply cases in the RX 9070 XT report. The shared binary16 multiplication expression also serves plain
v_mul_f16.Widening binary16 operands makes their finite product exact in binary32, but an ordinary HLSL multiply lets the compiler disregard the sign of zero. Apply
preciseto the product before the existing binary16 rounding. The existing per-lane comparisons still cover the selected half, sign modifiers, and the preserved half of the destination. The portable test checks the precision qualifier and the emitted calls for the plain, packed and SDWA paths. After merging main at96a7b4fb, cached shaders advance to 25/25cs.The focused SDWA case (set 0, lane 2) read back
e000abcdon WARP, Intel UHD 770 and RTX 4060 with both FXC and DXC. The complete draw suite passed on all three at the initial implementation, with 220 calls per adapter including the existing wrong-value controls. For the packed and SDWA pixel fixtures I also compiled a copy with just the qualifier removed. DXC changes the relevantfmul floattofmul fast float; FXC drops[precise]from the correspondingmul.Repeated the complete FXC/DXC draw suite on
3cc0d4b8on all three adapters. On3fdbaa40the SDWA case again gavee000abcdin all six compiler/adapter combinations. A compiled control that clears the product's sign exactly when its magnitude is zero gave6000abcdand exited 1 in all six. Locally ran the two binary16 Python checks, LLVM 15 gfx1013 reassembly, both cache-key checks, offline compute request, packed-position, buffer-store, const-copy-join and fract checks. An independently compiled C++ FNV calculation for the final graphics keys givesdf78b28cb80d4c5aand466483d084260802. Windows 11 build 26100.9711, DXC 1.9.2609.5, FXC ps_5_1, UHD 770 driver 32.0.101.5973, RTX 4060 driver 32.0.15.9579, WARP 10.0.26100.9711. Debug layer unavailable.For the reporter's RDNA 4 retest on this exact candidate:
AI-assisted with Codex (GPT-6.2 Astra, xhigh).