Repository navigation
shader: lower s_pack_ll_b32_b16, s_pack_lh_b32_b16 and s_absdiff_i32 in gfx2hlsl (continues #2086, Part of #1723) - #2512
Conversation
…in gfx2hlsl Part of R0Y00#1723. s_absdiff_i32 subtracts the smaller signed source from the larger, so an overflowing difference wraps like the hardware. SCC is unchanged by the pack forms and is result != 0 for s_absdiff_i32.
…uator HLSL abs of a uint is the identity, so an s_absdiff_i32 lowering that dropped asint would still have passed the evaluator. Assert that abs gets a signed value. AI-assisted.
…ython checks Add it to the Linux CI Python list and the AGENTS.md list next to startup_gfx2hlsl_sop2_complement_check, whose helpers it imports. AI-assisted.
tedin7
left a comment
There was a problem hiding this comment.
Review of head e2b7dca against origin/main (8 behind, mergeable).
Code: looks correct.
s_pack_ll_b32_b16,s_pack_lh_b32_b16: expressions match the ISA meaning, SCC untouched.s_absdiff_i32:asuint(abs(asint(a - b)))keeps the wrapped INT_MIN case, SCC =D != 0.- Lane-mask and descriptor sources are refused for all four forms (no stale SCC).
- No other open or merged PR covers this slice (only the paused #2086, which this continues).
Missing before merge: a real D3D12 WARP readback test.
tests/startup_gfx2hlsl_pack_absdiff_check.py runs the emitted lines on a Python integer evaluator. That is a good model check, but it does not compile the HLSL or run it on a GPU. For a shader/math lowering we need a WARP GPU readback compared with a CPU reference. Please extend an existing WARP suite with these three ops over the edge values (include 0x80000000 - 1 and a == b for absdiff, and the << 16 / & 0xffff0000 edges for the packs).
Commands run (Linux, in a clean worktree of this head)
python3 tests/startup_gfx2hlsl_pack_absdiff_check.py-> okpython3 tests/docs_links_check.py-> ok;python3 tests/bidi_controls_check.py-> ok;git diff --check origin/main...HEAD-> clean- Mutations, each makes the new test fail: dropping
asintin absdiff (evaluator assert), dropping the absdiff SCC (s_absdiff_i32 value and SCC), changing<< 16to<< 15in pack_ll (s_pack_ll_b32_b16 value and SCC). - No Windows run was done by this review.
AI-assisted; commands listed were executed locally.
|
Win2025 WARP receipt for head 79927a5 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
|
Win2025 WARP receipt for head 79927a5 after updating with main (focused run on the PR test and sibling gfx2hlsl checks). Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
…hardware (#2523) Review request on #2512: compile the HLSL that gfx2hlsl emits for each op into one cs_6_0 shader with DXC and run it through offscreen_check --raw-uav-dump. The sources are loaded from the UAV fill pattern and XORed, so DXC cannot fold them; D and, for s_absdiff_i32, SCC are stored and compared with the integer references. Cases: absdiff (0x80000000, 1) and its reverse, (0x7fffffff, 0x80000000) and its reverse, equal sources, 0 and 0xffffffff; packs with the <<16 and 0xffff0000 edges, both orders. The operand region must come back unchanged. Registered as startup_gfx2hlsl_pack_absdiff_dispatch_warp and _hardware (skip 77). AI-assisted. Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>
Continues #2086 by @tedin7 (paused to keep the Windows test queue short; takeover note). Part of #1723.
The first two commits are tedin7's, rebased on main
851a140with his authorship:s_pack_ll_b32_b16ands_pack_lh_b32_b16join the existings_pack_hh_b32_b16lowering. SCC is unchanged.s_absdiff_i32:D = |wrap32(S0 - S1)|(INT_MIN stays INT_MIN),SCC = D != 0.s_absdiff_i32it is "scc from descriptor data", since its SCC would be left stale.Rebase. The cherry-pick of the two commits onto
adf4e3bconflicted with main'sscc_effectlines inStage.scalar. I resolved it as #2086's own merge commit does. The normalized diff is identical to #2086's. Rebasing onto851a140was clean: #2459'slane_complementis only true for the complement forms, so pack and absdiff are still refused on lane masks.Two commits of mine on top
startup_gfx2hlsl_bit_alu_check.pynow asserts thatabsgets a signed value. HLSLabsof auintis the identity, so ans_absdiff_i32lowering withoutasintused to pass.startup_gfx2hlsl_sop2_complement_check.py, whose helpers it imports.Why now. In a local first-refusal census of captured start-up requests at main
dbab543,s_pack_ll_b32_b16is the first refusal for 59 requests. The inputs are private; these are counts only.Tests. Run on Windows 11 with Python 3.14 at this branch's head, all passing:
tests/startup_gfx2hlsl_pack_absdiff_check.py;startup_gfx2hlsl_bit_alu_check.py;startup_gfx2hlsl_sop2_complement_check.py;startup_gfx2hlsl_scalar_arity_check.py;startup_gfx2hlsl_operand_count_check.py.Mutation checks, run by hand.
startup_gfx2hlsl_pack_absdiff_check.pyfails on each:s_pack_llshifting S1 by 8;s_pack_lhwith its sources swapped;s_absdiff_i32without its SCC;s_absdiff_i32;s_absdiff_i32;s_absdiff_i32withoutasint(caught by the new evaluator assertion).No GPU run: the check evaluates the emitted lines with the integer evaluator.
AI-assisted.