Shader tests: the legacy multiply-add's rounding case takes either rounding #1335

Open
github-bot wants to merge 1 commit from github-bot/gh-1335 into main AGit
Owner

@⁠bihanikeshav on GitHub · 2026-11-26 15:56 UTC · original
bihanikeshav:legacy-mad-test-either-rounding → main · +24 −6 · 2 files · 1 commits · open

Problem

legacy_mad_fuses_its_product_and_flushes_its_sources fails on my RTX 5060 Laptop (Blackwell, driver 610.62):

hardware: case 0
  left: 0
 right: 2826960896

Case 0 checks that v_mad_legacy_f32 rounds once. We lower it to DXIL FMad, and DXIL leaves fusing that op up to the driver. NVIDIA's Ada driver fuses it (#961 ran into that from the other side). This card's driver doesn't, so the product gets rounded to 1.0 before the add and the result is +0 instead of -2^-46. WARP does the same thing, which is why the test already skipped case 0 there. #1026 was only run on WARP, so the hardware branch of that assertion never saw a card like this one.

Every other case passed here. Flushing subnormal sources and the zero-factor rule both work, and those are the parts that fixed the water reflections.

Change

  • Case 0 now takes either correct answer on any device: fused (0xa8800000) or product rounded first (0x00000000). It prints which one it got. Any other value still fails.
  • The other three cases are unchanged and stay exact on hardware and WARP.
  • The doc comment on legacy_fmad in lower.rs now says the fusing is asked for, not promised.

No change to the translator's output.

I didn't try to force a single rounding (doing the add in f64 with round-to-odd would work). It costs several double ops per instruction, doubles are slow on consumer NVIDIA cards, and I haven't seen this last-bit difference cause anything visible. Happy to look at it if someone has a case where it matters.

Tests

On the RTX 5060 Laptop, Windows 11:

  • cargo test -p victory-shader --locked: 222 passed, 0 failed, 4 ignored. Before this change: 221 passed, 1 failed.
  • The test with --nocapture prints hardware: FMad not fused by this host (product rounded first) and the same for warp.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings and the --all-features run are both clean.

🤖 Generated with Claude Code

**@⁠bihanikeshav** on GitHub · 2026-11-26 15:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/1335) `bihanikeshav:legacy-mad-test-either-rounding` → `main` · +24 −6 · 2 files · 1 commits · open ## Problem `legacy_mad_fuses_its_product_and_flushes_its_sources` fails on my RTX 5060 Laptop (Blackwell, driver 610.62): ``` hardware: case 0 left: 0 right: 2826960896 ``` Case 0 checks that `v_mad_legacy_f32` rounds once. We lower it to DXIL `FMad`, and DXIL leaves fusing that op up to the driver. NVIDIA's Ada driver fuses it (#961 ran into that from the other side). This card's driver doesn't, so the product gets rounded to 1.0 before the add and the result is +0 instead of -2^-46. WARP does the same thing, which is why the test already skipped case 0 there. #1026 was only run on WARP, so the hardware branch of that assertion never saw a card like this one. Every other case passed here. Flushing subnormal sources and the zero-factor rule both work, and those are the parts that fixed the water reflections. ## Change - Case 0 now takes either correct answer on any device: fused (`0xa8800000`) or product rounded first (`0x00000000`). It prints which one it got. Any other value still fails. - The other three cases are unchanged and stay exact on hardware and WARP. - The doc comment on `legacy_fmad` in `lower.rs` now says the fusing is asked for, not promised. No change to the translator's output. I didn't try to force a single rounding (doing the add in f64 with round-to-odd would work). It costs several double ops per instruction, doubles are slow on consumer NVIDIA cards, and I haven't seen this last-bit difference cause anything visible. Happy to look at it if someone has a case where it matters. ## Tests On the RTX 5060 Laptop, Windows 11: - `cargo test -p victory-shader --locked`: 222 passed, 0 failed, 4 ignored. Before this change: 221 passed, 1 failed. - The test with `--nocapture` prints `hardware: FMad not fused by this host (product rounded first)` and the same for warp. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` and the `--all-features` run are both clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`legacy_mad_fuses_its_product_and_flushes_its_sources` asserted a single
rounding on every hardware adapter. The instruction is lowered to DXIL
`FMad`, whose fusing is the driver's choice: NVIDIA's Ada driver fuses it
(pull request #961), but an RTX 5060 Laptop (Blackwell, driver 610.62)
rounds the product first, as WARP does, and the test failed there
(case 0: got 0x00000000, want 0xa8800000), turning `cargo test --workspace`
red on that card.

Case 0 now takes either correct answer (fused, or product rounded first)
on every device and says which it got; any other value still fails. The
flushing and zero-factor cases stay exact everywhere. The doc of
`legacy_fmad` says the fusing is asked for, not promised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:57:24 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1335/head:github-bot/gh-1335'
git switch 'github-bot/gh-1335'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1335'
git switch 'github-bot/gh-1335'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1335'
git switch 'github-bot/gh-1335'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1335'
git switch 'main'
git merge --squash 'github-bot/gh-1335'
git switch 'main'
git merge --ff-only 'github-bot/gh-1335'
git switch 'main'
git merge 'github-bot/gh-1335'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.