shader: lower packed halfword dot products in direct compute #3061
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3061"
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 RonLogic on 2026-11-27T13:21:13Z.
Change
Refs #2935. Add
v_dot2_i32_i16andv_dot2_u32_u16to the direct C++ compute frontend. At801f4c3b, canonical source-built requests for both opcodes were refused at+0x38withdirect ALU operand modifiers. #3036 covers the separate HLSL frontend.Each 16×16 product fits in a 32-bit word. The ordinary form wraps. The clamped form adds the carries from both additions and the signed extensions to track the upper word of the exact sum. Saturation happens after the accumulator is added, so an intermediate overflow can cancel. This requires only 32-bit DXIL arithmetic.
Verification
Tested
edede1ff472be772c86f96e9f2831515b7aaf349ondb28a796with Windows 11 build 26300.10075, MSVC 19.52, SDK 10.0.26100 and DXC 1.9.2602.17.32.0.16.2124, SM 6.6 / wave32, debug layer off): both full and sparse EXEC dispatches matched 2,048 result words and 16 guards. The signed2^30 + 2^30 - 2^31case returned zero. The no-clamp replay matched wrapping and differed from the clamped reference at 376 words.10.0.26100.10068, debug layer enabled for the adjacent HLSL checks): related readbacks passed. Native replay requires wave32 and is inapplicable to this 4-lane WARP adapter.git diff --checkpassed.Evidence and follow-up
The source-built fixture uses synthetic instructions and a Python integer oracle. It covers both signed overflow directions, unsigned double carry, the exact saturation bounds, and inactive lanes. The branch trial-merges cleanly with main, cpp-migration, #3058 and #3060. Native readback on AMD remains unverified.
Checklist
I used Codex to prepare the change and ran verification locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T13:54:13Z.
Review: APPROVED
Independent review of the exact head integrated over
main36d2cbeb, #2871 and #3060 (tree8b3f4eb5d58ccd10535336aa03034a164b0fe8bc). The two carries and sign extensions implement the exact upper word through the accumulation, before saturation. An independent CPU arithmetic check matched an unbounded integer reference for 202,662 signed and unsigned inputs, including cancellation and both saturation directions.Built
compile_dxil native_store_replay. Debug and Release/O2each passed 12/12 with zero skips usingctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_(packed_dot[24]|int16_ternary|perm_lerp|absdiff)_.+|native_dxil_llvm_ident_controls|startup_gfx2hlsl_v_dot8_controls)$'. Both packed dot fixtures matched 2,048 result words and 16 guards for each full and sparse EXEC case. Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK DXC 10.0.26100, replay debug layer off. Native replay needs wave32 and has no WARP case; the PR author reports the adjacent HLSL WARP runs.