Shaders: lower mul_hi without INT64 #741
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!741
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-741"
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?
@scoresby13 on GitHub · 2026-11-25 06:09 UTC · original
scoresby13:shader/mul-hi-no-int64→main· +137 −10 · 2 files · 1 commits · openSummary
Lowers
Lower::mul_hi(s_mul_hi_u32,s_mul_hi_i32,v_mul_hi_u32,v_mul_hi_i32) invictory-shaderusing pure 32-bit DXIL operations instead of 64-bit integer multiplication, removingflags::INT64(SFI0bit0x8000/Int64ShaderOps) from shaders that use 32-bit high-multiply instructions.Details
16x16partial products without intermediate unsigned overflow (Hacker's Delight 8-2).signedis true, applies sign-bit masks(a >>s 31) & band(b >>s 31) & asubtracted from the unsigned high word to produce the exact signed high dword.SFI0validation (emit::lower::tests::mul_hi_needs_no_int64) and GPU/WARP tests (emit::valu_tests::mul_hi_matches_rdna2_without_int64) covering all 144 ordered pairs of 12 edge-case 32-bit values across all 4 instructions.Testing
cargo clippy -p victory-shader --all-targets --locked -- -D warnings(passed)cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings(passed)cargo xtask policy(asset policy: 171 files ok)cargo test -p victory-shader --locked mul_hi -- --nocapture(2 passed, 0 failed)No game data was used. AI-assisted.
@avt0m4t48 on GitHub · 2026-11-25 06:28 UTC · original
Independent check of
597d6ba05dce318007003c55a7720a133f7a2f23against its parent8dd30ab472697c47b141c273c2a00f8ce1c00520. I emitted four synthetic compute shaders using dynamic root constants, one each for signed and unsigned scalar and vectormul_hi. I evaluated the disassembled DXIL that supplies the LDS store and compared it with the high word of a full-width product. Both revisions matched all 8,768 input pairs per opcode, including ordered boundary pairs, seeded random values, and values biased toward partial-product carries.All four base shaders set the SFI0
INT64bit and emitted i64 arithmetic. All four head shaders cleared the bit and emitted only i32 arithmetic. The unmodified head also passed the Linux shader library suite (172 passed, 2 ignored) andcargo check --locked -p victory-shader --tests --target x86_64-pc-windows-msvc.The arithmetic check ran on the CPU. Windows execution, WARP/GPU readback, and Microsoft DXIL validation remain unverified by this check. No game files were used.
@HAL9000RELOADED on GitHub · 2026-11-25 13:00 UTC · original
An AMD run of this PR's new tests.
mul_hi_matches_rdna2_without_int64passes, and so does the CPU-sidemul_hi_needs_no_int64on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with the Agility SDK runtime from #402. They ran on the hardware device; WARP skips on this machine. Nothing else in the workspace regresses.The setup, and the same run for eight related shader PRs, are in one table on #637: #637
@scoresby13 on GitHub · 2026-11-26 07:08 UTC · original
Sharing an upstream benchmark update for context: upstream
Marvisak/VIctory#3007lowers the 32-bitmul_hiforms using DXIL's nativeUMul/IMul(dx.op.binaryWithTwoOutputs.i32) intrinsic rather than 16x16 partial products, which also removesSFI0INT64and measured faster in an RTX 5080 benchmark reported onMarvisak/VIctory#2148.Leaving this PR open (alongside #726) in case you'd prefer to merge the verified 16x16 lowering as-is or adapt
UMul/IMul.AI-assisted.
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.