shader: decide v_dot4_i32_i8 and v_dot8_i32_i4 saturation in 32 bits #855
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/861"
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 romn4rch on 2026-11-23T14:27:15Z.
Change
v_dot4_i32_i8andv_dot8_i32_i4now add the product sum to the accumulator in 32 bits and decide signedclampfrom the accumulator and the wrapped result, instead of the emulated 64-bit pair (dot_i64_add/dot_i64_sat):The 4 × 8-bit product sum lies in [-65024, 65536] and the 8 × 4-bit sum in [-448, 512]. A signed overflow is therefore only possible for an accumulator of at least 2^30 or below -2^30, and there it flips the sign of the wrapped result.
v_dot2_i32_i16, whose sum can reach 2^31, keeps the 64-bit pair, as do the three unsigned forms.On an Intel UHD Graphics the pair form returned wrong
v_dot4_i32_i8results inside the fulldotprogram, while isolated probes of the same helper were exact (#736). As requested there,DOT_SETSkeeps the wrapped results, saturation endpoints and five mutation controls. It gains Set 5 and Set 6, which putv_dot2_i32_i16,v_dot4_i32_i8andv_dot8_i32_i4one step insideINT32_MAXandINT32_MINwithout saturation.docs/experiments.mdnow describes the two forms and the six sets.Fixes #736
Verification
The hardware runs used
34d03c7with exactly this change totools/pixel_aot.pyandtests/pixel_aot_check.py, on one host. This branch is based on58da18a. There the dot helpers,DOT_BODYandDOT_SETSare unchanged, and the translateddotshader is byte-identical to the tested one (checked offline).With
XBOX2WINDOWS_ADAPTERset toIntelorNVIDIA:check_dot_draw['pass', 'mismatch', 'mismatch', 'mismatch']check_dot_draw: HLSL SHA-2560d9b896dd5ac5083b7c962cccd2eac0d29a3f564cb82840e25474fd387082c84as translated, CSO SHA-256f4a67ad94bb23d463aa0698be2b913604a8db12d49e41dbde847d96c73c4a99e(Windows SDK DXC 1.9.2602.17). Before the change:54b6fae3…andc76adeee….draw-corechecks on Intel, each wrapped so the run continues: without the change onlycheck_dot_drawfails; with it all 15 pass.dotprogram with six sets: exact on all three adapters, Intel in 2 of 2 runs. All five mutation controls are detected.v_dot4_i32_i8andv_dot8_i32_i4, with and withoutclamp, 11 inputs each: exact on all three adapters.clampcases.Full tables, probe inputs and the first mismatch: https://github.com/R0Y00/Xbox2Windows/issues/736#issuecomment-7103969347
Environment: Windows 11 build 26300.10075, MSVC 19.44.35230, Windows SDK 10.0.26100, CMake 4.5.1, Python 3.14.7. Intel UHD Graphics
8086:468B, driver 32.0.101.7092; NVIDIA GeForce RTX 3050 6GB Laptop GPU10DE:25EC, driver 32.0.16.2114; WARP 10.0.26100.10068. Debug layer unavailable on all three (Graphics Tools not installed).Not run here:
pixel_aot_check.py binary(needs LLVM with gfx1030; thedotfixture body is unchanged) and other GPU vendors.Evidence and follow-up
Sets 5 and 6 pass with both helpers, so they add no failure of their own. A clamp that fires one step early would change channel 1 (
v_dot2_i32_i16) or channel 2 (v_dot4_i32_i8) in both sets. The two sets are two more cases in the existing--check-pixel-batchlaunch. The cause of the Intel mismatch stays a hypothesis (#736).Checklist
AI-assisted.