Shaders: emit the valid DXIL intrinsic for f64 FMA #202

Open
loyodea wants to merge 1 commit from upstream-pr/202 into main
loyodea commented 2026-11-25 21:33:45 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by loyodea on 2026-11-25T21:33:45Z.


Double-precision fused multiply-add emitted a declaration that DXIL validation rejects. Use the canonical dx.op.tertiary.f64 entry point for opcode 47 and retain the existing double-precision flags. The regression puts all operands and the destination in disjoint registers and includes cancellation that distinguishes one rounding from separate multiply and add operations.

Tested

  • Windows 11 Pro build 26300, Ryzen 7 5700X3D, Radeon RX 9060 XT driver 32.0.32029.2010, and WARP. Debug with Rust 1.100.0 GNU x64 and DXIL validator 1.9.2609.5.
  • cargo test --locked --jobs 4 -p victory-shader --lib v_fma_f64_rounds_once -- --test-threads=1 --show-output reproduced the validator error before the fix. With the fix all 12 result-word checks passed, six on hardware and six on WARP.
  • The full victory-shader package run reported 281 passed, 0 failed, and 7 ignored. Four compiler-dependent checks returned early because the optional compilers were unavailable.
  • git diff --check passed. The asset-policy check still flags lower.rs for exceeding the 512 KiB file limit, which it already exceeded at upstream base 4f62c2a.

Retail titles, frame rate, the pinned MSVC toolchain, and other GPU drivers remain unverified. The tests use original synthetic shaders.

AI use

OpenAI Codex with GPT-6.2 Sol (extra-high reasoning for the implementation and final checks) wrote the fix, verified the regression, and ran the tests.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5499544575 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/202). Originally posted by [loyodea](https://github.com/loyodea) on 2026-11-25T21:33:45Z. --- Double-precision fused multiply-add emitted a declaration that DXIL validation rejects. Use the canonical `dx.op.tertiary.f64` entry point for opcode 47 and retain the existing double-precision flags. The regression puts all operands and the destination in disjoint registers and includes cancellation that distinguishes one rounding from separate multiply and add operations. **Tested** - Windows 11 Pro build 26300, Ryzen 7 5700X3D, Radeon RX 9060 XT driver 32.0.32029.2010, and WARP. Debug with Rust 1.100.0 GNU x64 and DXIL validator 1.9.2609.5. - `cargo test --locked --jobs 4 -p victory-shader --lib v_fma_f64_rounds_once -- --test-threads=1 --show-output` reproduced the validator error before the fix. With the fix all 12 result-word checks passed, six on hardware and six on WARP. - The full `victory-shader` package run reported 281 passed, 0 failed, and 7 ignored. Four compiler-dependent checks returned early because the optional compilers were unavailable. - `git diff --check` passed. The asset-policy check still flags `lower.rs` for exceeding the 512 KiB file limit, which it already exceeded at upstream base `4f62c2a`. Retail titles, frame rate, the pinned MSVC toolchain, and other GPU drivers remain unverified. The tests use original synthetic shaders. **AI use** OpenAI Codex with GPT-6.2 Sol (extra-high reasoning for the implementation and final checks) wrote the fix, verified the regression, and ran the tests.
MamaLeVrai commented 2026-11-26 05:00:10 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by MamaLeVrai on 2026-11-26T05:00:10Z.


RDNA2 data point. This PR (3b26bce) merged on main 4f62c2a, cargo test --release -p victory-shader --lib on an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1):

  • main: 275 passed, 2 failed.
  • This PR: 276 passed, 2 failed, in 2 runs out of 2. The new test passes on the hardware adapter.

The 2 failures are the same as on main: the RDNA2 wave-size tests scalar_counted_in_a_divergent_loop_read_after_it and scalar_counted_in_nested_divergent_loops, fixed by #110 and #204. No regression here. Not run in the game.

harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7183090535 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/202#issuecomment-7183090535). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-26T05:00:10Z. --- RDNA2 data point. This PR (`3b26bce`) merged on `main` `4f62c2a`, `cargo test --release -p victory-shader --lib` on an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1): - `main`: 275 passed, 2 failed. - This PR: 276 passed, 2 failed, in 2 runs out of 2. The new test passes on the hardware adapter. The 2 failures are the same as on `main`: the RDNA2 wave-size tests `scalar_counted_in_a_divergent_loop_read_after_it` and `scalar_counted_in_nested_divergent_loops`, fixed by #110 and #204. No regression here. Not run in the game. harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300 AI-assisted (Claude Code); no game data.
loyodea commented 2026-11-26 18:53:05 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by loyodea on 2026-11-26T18:53:05Z.


Thanks for running this twice on the RX 6950 XT. Both runs passed the new fused-rounding regression and reproduced the same two baseline wave-size failures tracked in #110 and #204.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7200957627 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/202#issuecomment-7200957627). Originally posted by [loyodea](https://github.com/loyodea) on 2026-11-26T18:53:05Z. --- Thanks for running this twice on the RX 6950 XT. Both runs passed the new fused-rounding regression and reproduced the same two baseline wave-size failures tracked in #110 and #204.
adrianmjim commented 2026-11-26 19:48:18 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by adrianmjim on 2026-11-26T19:48:18Z.


Tested on a different GPU, plus a full-title shader run.

Setup: Windows 11 26300, RX 7900 XT (RDNA3), driver 32.0.32029.2010, Rust 1.98.1. Head 3b26bce on base 4f62c2a.

  • v_fma_f64_rounds_once with the fix: all 12 checks pass, 6 on the RX 7900 XT and 6 on WARP. Without the fix on 4f62c2a it fails DXIL validation with the same 'dx.op.fma.f64' is not a DXILOpFuncition for DXILOpcode 'Fma' error.
  • cargo test -p victory-shader --lib -- --test-threads=1: 278 passed, 0 failed, 6 ignored. 4f62c2a gives 277/0/6, so the only difference is the new test.
  • translate --validate --host-lanes 32-64 over the full GTA VI shaders.rpf (26084 programs): the output is identical to 4f62c2a. All 25623 per-program DXIL hashes match, and so do the validation counts, the refusals and the IR instruction total.
  • The reason is that the archive contains no v_fma_f64. shader-info --disasm finds only two f64 VALU instructions: v_add_f64 (5 programs) and v_cvt_f32_f64 (5 programs).

So on RDNA3 the new declaration passes validation and gives single-rounding results, but it has no effect on this game's shaders. Not tested: other titles, in-game rendering, and the tests outside --lib.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7201978660 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/202#issuecomment-7201978660). Originally posted by [adrianmjim](https://github.com/adrianmjim) on 2026-11-26T19:48:18Z. --- Tested on a different GPU, plus a full-title shader run. Setup: Windows 11 26300, RX 7900 XT (RDNA3), driver 32.0.32029.2010, Rust 1.98.1. Head 3b26bce on base 4f62c2a. - `v_fma_f64_rounds_once` with the fix: all 12 checks pass, 6 on the RX 7900 XT and 6 on WARP. Without the fix on 4f62c2a it fails DXIL validation with the same `'dx.op.fma.f64' is not a DXILOpFuncition for DXILOpcode 'Fma'` error. - `cargo test -p victory-shader --lib -- --test-threads=1`: 278 passed, 0 failed, 6 ignored. 4f62c2a gives 277/0/6, so the only difference is the new test. - `translate --validate --host-lanes 32-64` over the full GTA VI `shaders.rpf` (26084 programs): the output is identical to 4f62c2a. All 25623 per-program DXIL hashes match, and so do the validation counts, the refusals and the IR instruction total. - The reason is that the archive contains no `v_fma_f64`. `shader-info --disasm` finds only two f64 VALU instructions: `v_add_f64` (5 programs) and `v_cvt_f32_f64` (5 programs). So on RDNA3 the new declaration passes validation and gives single-rounding results, but it has no effect on this game's shaders. Not tested: other titles, in-game rendering, and the tests outside `--lib`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/202:upstream-pr/202'
git switch 'upstream-pr/202'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/202'
git switch 'upstream-pr/202'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/202'
git switch 'upstream-pr/202'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/202'
git switch 'main'
git merge --squash 'upstream-pr/202'
git switch 'main'
git merge --ff-only 'upstream-pr/202'
git switch 'main'
git merge 'upstream-pr/202'
git push origin 'main'
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
Belobug/VIctory-Belobug-AMD!202
No description provided.