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

Merged
Fibrak merged 5 commits from upstream-pr/308 into main 2026-11-27 16:38:51 +00:00
Fibrak commented 2026-11-27 15:22:55 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Fibrak on 2026-11-27T15:22:55Z.


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

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5529065438 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/308). Originally posted by [Fibrak](https://github.com/Fibrak) on 2026-11-27T15:22:55Z. --- `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)
TaynanGT commented 2026-11-27 15:32:03 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T15:32:03Z.


@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.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7222173220 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/308#issuecomment-7222173220). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T15:32:03Z. --- @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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
TaynanGT/Vice-Tay!308
No description provided.