shader: saturate clamped unsigned integer sums and differences (#365) #366
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/366"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by tiagonogueiraa-bit on 2026-11-27T14:16:53Z.
Refs #365
Shape.
write_irefused every integer result with the clamp bit as "integer output modifiers". In the title, all 8 such compute shaders in my corpus usev_sub_nc_u32 vN, vA, vB clamp, with the result going to LDS.Change. In
Lower::integer, the clamp bit onv_add_nc_u32,v_sub_nc_u32andv_subrev_nc_u32(SATURATING) is unsigned saturation:r <u a) gives0xffffffff;a <u b) gives0.LLVM's AMDGPU backend selects
uaddsatandusubsatto exactly these instructions with clamp.write_ilets the clamp through for those three only. Clamp on other integer operations (signed_i32,v_mad_u32_u24and others) andomodstay refused, and unclamped instructions are unchanged.By-output corpus sweep. 12,020 containers from my own boot-to-menus run (Series S), native host options, main
905e7aaagainst this head:Gained:
0752fed8675075be,284a5f5796ba7abc,3229462a630a0353,35b422c6b9bd5693,b9dfec7f657e3196,bbe7ce7f482f36ab,f056aa31512ea1eb,f539346687541f48.Test.
split_wave_tests::clamped_unsigned_sums_and_differences_saturate(victory-gpu, on Metal with MSC 4.0 beta 3). Over 32 lanes:istoresi - 5clamped at 0;0xfffffff0 + iclamped at0xffffffff.On main it fails at translation.
Checks.
cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 955 passed, 0 failed, 10 ignored.-D warnings: clean.cargo xtask policy: ok.docs/native-host.mdhas a short section ("Clamped integer sums and differences"). @Olima34, for the board.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:05:13Z.
Merged in
be7dc1b5with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. Thanks.