Repository navigation
Shaders: preserve SCC on signed scalar add and subtract - #1421
Conversation
Port the 32-bit overflow calculation from ESAT586’s Marvisak/VIctory#1095 (d25783b8d87dea346cccd4f8aff90d6dd75f9258). A separately assembled compute fixture compares both the result and SCC against a scalar reference, with an unsigned carry control. Co-authored-by: ESAT <esatgani_41@hotmail.com> (cherry picked from commit 6b4bb25)
6b4bb25 to
9790ba0
Compare
|
Tested on Ampere: RTX 3070 (
Ampere reproduces the refusal on main, and the PR fixes it. With the PR, the 3070 matches all 55 signed words (11 input pairs x 5 words) and the unsigned control. On main's code, the same test is refused with the description's error, at the same offset. No case gives a wrong value instead of a refusal. The test
The test needs no Unlike most There is a silent pass: if no SM 6.6 hardware device opens, Adapters seen I added a temporary
Values (PR merged) All 6 runs gave the same values, and every row matches the test's Word 0 is the packed SCC (bit 0
The Negative control: main's
3 runs by default and 3 with
This is a refusal at lowering, the same in every run and on both adapters. No case returned a wrong value. The offset and text match the description's fixture-only baseline. The offset 132 is not an SCC reader. On main,
The PR adds no compiler warnings. The one warning in both builds, unused CI
Overlap
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
A smoke test in play: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. A release build of this PR merged onto main
Tested with an AI assistant (Claude Code); results are from this PC. |
AMD defines SCC for
S_ADD_I32,S_ADDK_I32, andS_SUB_I32as signed 32-bit overflow. The translator emits the arithmetic result but leaves SCC missing, so a laterS_CSELECT_B32can cause lowering to returnUnsupported.This ports the 32-bit sign-bit overflow calculation from ESAT586’s Marvisak/VIctory#1095. It uses the existing sign-extended SOPK immediate and retains the unsigned carry and borrow rules. AMD RDNA 2 ISA reference, sections 12.1 and 12.3
The regression uses LLVM MC gfx1030 assembly. It dispatches an unsigned carry control, then compares four signed arithmetic results and their packed SCC flags with Rust’s
overflowing_addandoverflowing_sub. An independent Python checker derives the same result from unbounded arithmetic and signed range checks.32ecacfae73fplus the identical test fixture returned[1, 0]forUINT_MAX + 1, then rejected the signed shader withUnsupported { offset: 132, what: "the carry of a scalar operation" }.6b4bb259aec8returned the same unsigned control and matched all 55 signed UAV words across 11 input pairs on an RTX 5070, driver 620.73.04, through Proton Experimental and VKD3D-Proton30b0eb9bc12dc9f. ForINT_MAX, 1the readback was[00000005, 80000000, 7ffffffe, 80000000, 7ffffffe]. ForINT_MIN, 1it was[0000000a, 80000001, 7fffffff, 80000001, 7fffffff].spirv-val --target-env vulkan1.3.Run the exact regression on an SM 6.6 D3D12 hardware adapter:
The fixture and resources are synthetic. Validation covers the NVIDIA hardware path through Proton.
Validation on current main
923e38cc8c92cd1c42090076382138538f2bb487as9790ba0c8e425b3a7d3ec64e9202f0a3244cc4e5. The measured original head6b4bb259aec85cdedf13554746d98764993785b0and its evidence were saved.99f0b329ddd019761a7a7f7f48ac4eda09468bfareproducedUnsupportedat byte offset 132 after the physical unsigned[1, 0]control. The new head again returned[1, 0]and all 55 signed words on the RTX 5070. The independent checker matched all 11 rows.