Keep the legacy multiply-add zero product positive on AMD #308

Manually merged
github merged 5 commits from github-bot/gh-308 into gh-pr/308/base 2026-11-27 16:44:45 +00:00 AGit
Owner

@⁠Fibrak on GitHub · 2026-11-27 15:22 UTC · original
Fibrak:fix/legacy-mad-signed-zero → main · +10 −2 · 2 files · 5 commits · merged 2026-11-27 16:38 UTC

v_mad_legacy_f32 and v_mac_legacy_f32 treat a zero factor's product as +0, so 0 × -1 + (-0) must give +0. On an RX 6900 XT (RDNA2, driver 32.0.21045.29003) the hardware backend of legacy_multiply_adds_fuse_their_product_and_flush_their_sources returned -0 for case 4. WARP and CI pass, so this only shows on an AMD card.

The zero-factor path formed the result as an fadd of +0 and the accumulator, and the AMD driver returned -0 for +0 + -0 there. The lowering now selects the +0 bit pattern when the flushed accumulator is -0. NaN, infinity and subnormal flushing behave as before, and nonzero factors keep the fused path, so cases 0–3 are unchanged. The test expectations are unchanged.

v_mul_legacy_f32 passes its test on the same card and is left as it is.

TRANSLATOR_VERSION goes to 9: with the fix at version 8, victory shaders translated the title's 25,790 cached shaders again and 162 came out different.

Testing on the RX 6900 XT

  • cargo test --locked -p victory-shader --lib: 325 passed, 0 failed (was 324 passed, 1 failed).
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.
  • cargo test --workspace --locked --no-fail-fast: one failure in victory-gpu, shadow::loose_allocation_tests::exact_eviction_keeps_held_entries_and_uses_publish_time_tick. It passed 5 times alone and in 3 full victory-gpu runs, so it looks flaky and is unrelated to this change.
  • In game, Series S profile with VICTORY_RELAY=0 (relay modes 1 and 2 reset this card, #138): 4.3 minutes in the world, median 8.6 rendered FPS at about 4,500 draws a frame, no errors, no warning kinds absent from a main run on the same settings, clean exit. Checked by eye while playing, with no visible problems; not recorded.

🤖 Generated with Claude Code

**@⁠Fibrak** on GitHub · 2026-11-27 15:22 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/308) `Fibrak:fix/legacy-mad-signed-zero` → `main` · +10 −2 · 2 files · 5 commits · merged 2026-11-27 16:38 UTC `v_mad_legacy_f32` and `v_mac_legacy_f32` treat a zero factor's product as +0, so `0 × -1 + (-0)` must give +0. On an RX 6900 XT (RDNA2, driver 32.0.21045.29003) the hardware backend of `legacy_multiply_adds_fuse_their_product_and_flush_their_sources` returned -0 for case 4. WARP and CI pass, so this only shows on an AMD card. The zero-factor path formed the result as an `fadd` of +0 and the accumulator, and the AMD driver returned -0 for `+0 + -0` there. The lowering now selects the +0 bit pattern when the flushed accumulator is -0. NaN, infinity and subnormal flushing behave as before, and nonzero factors keep the fused path, so cases 0–3 are unchanged. The test expectations are unchanged. `v_mul_legacy_f32` passes its test on the same card and is left as it is. `TRANSLATOR_VERSION` goes to 9: with the fix at version 8, `victory shaders` translated the title's 25,790 cached shaders again and 162 came out different. **Testing on the RX 6900 XT** - `cargo test --locked -p victory-shader --lib`: 325 passed, 0 failed (was 324 passed, 1 failed). - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test --workspace --locked --no-fail-fast`: one failure in `victory-gpu`, `shadow::loose_allocation_tests::exact_eviction_keeps_held_entries_and_uses_publish_time_tick`. It passed 5 times alone and in 3 full `victory-gpu` runs, so it looks flaky and is unrelated to this change. - In game, Series S profile with `VICTORY_RELAY=0` (relay modes 1 and 2 reset this card, #138): 4.3 minutes in the world, median 8.6 rendered FPS at about 4,500 draws a frame, no errors, no warning kinds absent from a `main` run on the same settings, clean exit. Checked by eye while playing, with no visible problems; not recorded. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
v_mad_legacy_f32 and v_mac_legacy_f32 take a zero factor's product as
+0, so +0 times anything plus -0 must give +0. The zero-factor path
formed that sum as an fadd of +0 and the accumulator, which the AMD
driver returned as -0 on an RX 6900 XT (the hardware case 4 of
legacy_multiply_adds_fuse_their_product_and_flush_their_sources).
Select the +0 bits when the flushed accumulator is -0; NaN, infinity
and flushing behave as before, and nonzero factors keep the fused path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The +0 select changes the DXIL of 162 of the title's 25,790 cached
shaders (victory shaders, same version), so cached translations must
be made again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 15:29:55 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 15:32 UTC · original

@⁠Fibrak The hardware signed-zero test is the right regression for this change. The 162 changed translations also make the cache bump necessary. #300 fixes the shared-clock test that failed in your workspace run. Current main has moved past translator version 9, so the signed-zero build needs a new cache version on its updated base.

**@⁠TaynanGT** on GitHub · 2026-11-27 15:32 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/308#issuecomment-7222173220) @⁠Fibrak The hardware signed-zero test is the right regression for this change. The 162 changed translations also make the cache bump necessary. #300 fixes the shared-clock test that failed in your workspace run. Current main has moved past translator version 9, so the signed-zero build needs a new cache version on its updated base.
Bring the signed-zero fix onto main before assigning its new cache version.
Use translator version 15 with the signed-zero lowering on current main. The RX 6900 XT test is recorded on the original pull request.
github-bot changed target branch from main to gh-pr/308/base 2026-11-27 16:44:43 +00:00
github manually merged commit a76472836e into gh-pr/308/base 2026-11-27 16:44:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.