Shaders: saturate clamped 24-bit multiply and multiply-add #2924
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2926"
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 Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T00:16:15Z.
Summary
Lower the
clampforms ofv_mul_i32_i24,v_mul_u32_u24,v_mad_i32_i24, andv_mad_u32_u24. Saturate the complete product or multiply-add to the signed or unsigned 32-bit range. The unclamped forms still wrap.Only the clamped path computes a high word. Splitting each 24-bit operand into 16 low bits and 8 high bits keeps each partial product and intermediate sum in i32. For MAD, the carry and sign extension from the addend complete the high word before saturation. This needs only 32-bit DXIL integer operations. The forms are listed with
clampin the GFX1030 assembly reference, and integer saturation is described in section 6.5 of the RDNA 2 ISA.Verification
63bcca4, the same fixture is refused atv_mul_i32_i24withinteger output modifiers. On the patch, all 96 signed/unsigned MUL/MAD input and mode combinations match an exact wide-integer reference on app-local WARP SM 6.6 with DXIL validation.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:24:29Z.
Review: COMMENTED
Verified head
3b60f1bdcleanly onorigin/main(63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP +VICTORY_D3D12_DEBUG=1+ Windows SDK 10.0.26100.0dxil.dll).Numeric & File-Size Review
emit/lower/mul24.rs):low_product <= 65535^2 < u32::MAX,middle in [-16,776,960, 33,488,384],high in [-16,513, 65,535]even after MAD unsigned carry and signedx >> 31extension).high == 0, elseu32::MAX) and signed (high == (sum >>_arith 31), elsei32::MIN/i32::MAXbyhigh <_s 0), properly handling intermediate 48-bit products pulled back into 32-bit range by MAD.emit/lower/mul24.rsnet shrinksemit/lower.rsto519,362 B(4,926 Bbelow the 512 KiB policy limit).Local Verification (
VICTORY_D3D12_DEBUG=1,dxil.dll)mul_and_mad_i24+emit::lower::tests+emit::semantics_tests: 68/68 passed (1 pre-existing ignored) on both adapters.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features) &cargo xtask policy(192 files ok): clean.Looks clean and ready to merge.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T00:26:34Z.
Review: COMMENTED
Scoped review: moving the four *_u24/i24 ops into a dedicated module that saturates at the 24-bit boundary is the right shape — the old path sign/zero-extended and multiplied without the console's saturate behavior. The shared shl/shr sign-extension is preserved. LGTM.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:24:05Z.
Automated triage for the maintainers.
Merge candidate. Adds the
clampforms ofv_mul_{i,u}32_{i,u}24andv_mad_{i,u}32_{i,u}24, which main refused inwrite_i, inemit/lower/mul24.rs, leaving the unclamped forms unchanged.clamp_mul24checks out: the 16/8-bit split keeps partial products within 32 bits,middle_hifloors correctly for signed forms, the MAD carry and addend sign extension give the exact high word, and saturation is right. The test compares against an exact i64 reference, and the RDNA2 ISA integer-clamp rule is cited.CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:31:58Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):emit/lower/mul24.rsand saturating clampedv_mul_{i32_i24,u32_u24}andv_mad_{i32_i24,u32_u24}on the full wide result matches RDNA2 hardware semantics and keepslower.rswithin the file-size policy budget.cargo test -p victory-shader mul_and_mad_i24 -- --test-threads=1(RTX 5090): 1 passed, 0 failed.VICTORY_WARP=1 cargo test -p victory-shader mul_and_mad_i24 -- --test-threads=1(WARP): 1 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.