Shaders: double-precision add, mul, fma, min, max, compares and conversions (stacked on #416) #1262

Open
MamaLeVrai wants to merge 5 commits from upstream-pr/1262 into main
MamaLeVrai commented 2026-11-24 16:54:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T16:54:46Z.


Stacked on #416: the first commit here is that PR's v_cvt_f32_f64, kept unchanged so its author stays credited. If #416 merges first, this rebases to the one commit on top; if this merges first, #416 can close.

What

Double-precision VALU instructions that no shader lowers yet (no open PR covers them). A double is a VGPR/SGPR pair; DXIL has fadd, fmul, fma, fmax and fmin for it.

  • v_add_f64, v_mul_f64, v_fma_f64, v_max_f64, v_min_f64
  • every v_cmp_*_f64 / v_cmpx_*_f64 except class
  • v_cvt_f64_f32, v_cvt_f64_i32, v_cvt_f64_u32, v_cvt_i32_f64, v_cvt_u32_f64

Sources take abs/neg (on the sign bit, abs first), inline float constants, literals (high dword) and SGPR pairs. Output modifiers (clamp, omod) on a double result are refused.

Still refused, as DXIL has no double form: rounding (floor, ceil, trunc, rndne), sqrt, rcp, rsq, ldexp, frexp, fract, class.

Notes for review

  • fma and the double/integer conversions are D3D11.1 double extensions. The validator rejects them with Flags must match usage unless ShaderFlags bit 6 and SFI0 0x20 are set, so there is a new DOUBLE_EXTENSIONS flag. makeDouble, splitDouble, fadd, fmul, min/max and the float conversions need only DOUBLES.
  • A constant v_cmp_f_f64 / v_cmp_tru_f64 builds no doubles: on WARP a double fcmp false lost the device.
  • Of two zeros, min/max follow the existing f32 rule (max_min). I did not check that rule against console hardware for f64.
  • #416's double_src is now fsrc64(inst, k) in emit/lower/double.rs, so any source works, not only the first. Its tests still pass unchanged.

Tests

Six new tests in valu_tests.rs, each run on the host GPU and on WARP and compared with Rust's f64: IEEE results (NaN, infinities, zeros, overflow, underflow), min/max zero order, abs/neg combinations, SGPR pairs, all 16 compare predicates, and saturating conversions (NaN to 0).

Run locally on an RX 6950 XT:

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean, with and without --all-features
  • cargo test --workspace --locked: all pass (130 passed, 1 ignored in victory-shader)

No game data or console output is used or committed; the expected values come from IEEE 754 via Rust.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5476588224 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-24T16:54:46Z. --- Stacked on #416: the first commit here is that PR's `v_cvt_f32_f64`, kept unchanged so its author stays credited. If #416 merges first, this rebases to the one commit on top; if this merges first, #416 can close. ## What Double-precision VALU instructions that no shader lowers yet (no open PR covers them). A double is a VGPR/SGPR pair; DXIL has `fadd`, `fmul`, `fma`, `fmax` and `fmin` for it. - `v_add_f64`, `v_mul_f64`, `v_fma_f64`, `v_max_f64`, `v_min_f64` - every `v_cmp_*_f64` / `v_cmpx_*_f64` except `class` - `v_cvt_f64_f32`, `v_cvt_f64_i32`, `v_cvt_f64_u32`, `v_cvt_i32_f64`, `v_cvt_u32_f64` Sources take abs/neg (on the sign bit, abs first), inline float constants, literals (high dword) and SGPR pairs. Output modifiers (clamp, omod) on a double result are refused. Still refused, as DXIL has no double form: rounding (`floor`, `ceil`, `trunc`, `rndne`), `sqrt`, `rcp`, `rsq`, `ldexp`, `frexp`, `fract`, `class`. ## Notes for review - `fma` and the double/integer conversions are D3D11.1 double extensions. The validator rejects them with `Flags must match usage` unless ShaderFlags bit 6 and SFI0 `0x20` are set, so there is a new `DOUBLE_EXTENSIONS` flag. `makeDouble`, `splitDouble`, `fadd`, `fmul`, min/max and the float conversions need only `DOUBLES`. - A constant `v_cmp_f_f64` / `v_cmp_tru_f64` builds no doubles: on WARP a double `fcmp false` lost the device. - Of two zeros, min/max follow the existing f32 rule (`max_min`). I did not check that rule against console hardware for f64. - #416's `double_src` is now `fsrc64(inst, k)` in `emit/lower/double.rs`, so any source works, not only the first. Its tests still pass unchanged. ## Tests Six new tests in `valu_tests.rs`, each run on the host GPU and on WARP and compared with Rust's `f64`: IEEE results (NaN, infinities, zeros, overflow, underflow), min/max zero order, abs/neg combinations, SGPR pairs, all 16 compare predicates, and saturating conversions (NaN to 0). Run locally on an RX 6950 XT: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean, with and without `--all-features` - `cargo test --workspace --locked`: all pass (130 passed, 1 ignored in `victory-shader`) No game data or console output is used or committed; the expected values come from IEEE 754 via Rust. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-11-24 16:54:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T16:54:55Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043667790 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#pullrequestreview-6043667790). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-24T16:54:55Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
pablogonz12 commented 2026-11-24 17:04:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T17:03:18Z.


Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main ffe310e plus #1017 — main's host build is broken without it (E0425 host_resource in victory-gpu), so the base is that pair. Ran the four-stage offline check (translate, dxil-spirv, spirv-val, RADV pipeline) over 768 programs: the 751-program world dump plus a 52-program BVH capture, 35 duplicate containers skipped.

translate valid SPIR-V RADV pipeline
base 666 / 768 656 656
your head 666 / 768 656 656

No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you lower, so this is a no-regression result only (same 10 SPIR-V validation failures as the base).

Not tested: in-game.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138614312 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7138614312). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-24T17:03:18Z. --- Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main `ffe310e` plus #1017 — main's host build is broken without it (`E0425 host_resource` in `victory-gpu`), so the base is that pair. Ran the four-stage offline check (translate, dxil-spirv, spirv-val, RADV pipeline) over 768 programs: the 751-program world dump plus a 52-program BVH capture, 35 duplicate containers skipped. | | translate | valid SPIR-V | RADV pipeline | |---|---|---|---| | base | 666 / 768 | 656 | 656 | | your head | 666 / 768 | 656 | 656 | No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you lower, so this is a no-regression result only (same 10 SPIR-V validation failures as the base). Not tested: in-game.
catminou4 commented 2026-11-24 17:06:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:06:57Z.

Review: APPROVED


Double-precision lowering (new emit/lower/double.rs) with DOUBLES/DOUBLE_EXTENSIONS shader flags mapped to SFI0 feature bits 0x1/0x20. The valu tests cover cvt_f32_f64 (incl. inline-constant high word, e64 modifiers) and IEEE f64 add/mul/fma/min/max NaN/zero ordering — all Windows-gated, so macOS verifies compilation and the existing suite only. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed. Double-predication corner cases are exactly where hardware runs matter; please make sure the valu suite is run on Windows before merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043854409 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#pullrequestreview-6043854409). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T17:06:57Z. **Review:** APPROVED --- Double-precision lowering (new emit/lower/double.rs) with DOUBLES/DOUBLE_EXTENSIONS shader flags mapped to SFI0 feature bits 0x1/0x20. The valu tests cover cvt_f32_f64 (incl. inline-constant high word, e64 modifiers) and IEEE f64 add/mul/fma/min/max NaN/zero ordering — all Windows-gated, so macOS verifies compilation and the existing suite only. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p victory-shader --locked`. Shader execution tests (valu_tests/host) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed. Double-predication corner cases are exactly where hardware runs matter; please make sure the valu suite is run on Windows before merge.
MamaLeVrai commented 2026-11-24 20:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T19:51:28Z.


Thanks, both. catminou4: the valu suite you ask to be run on Windows before merge ran here on Windows, on an RX 6950 XT and on WARP, and passes (add, mul, fma, min, max, abs and neg, SGPR pairs, all 16 compares, the conversions, with NaN, infinities, zeros and overflow); clippy with and without --all-features and cargo test --workspace pass too. pablogonz12: your four-stage offline check agrees with what I expected, no program gained or lost, since nothing in the retail dump reaches the f64 class. So this PR is a correctness addition with no measured gain on the title, and it can wait behind the bundles that do gain programs. AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142686850 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7142686850). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-24T19:51:28Z. --- Thanks, both. catminou4: the valu suite you ask to be run on Windows before merge ran here on Windows, on an RX 6950 XT and on WARP, and passes (add, mul, fma, min, max, abs and neg, SGPR pairs, all 16 compares, the conversions, with NaN, infinities, zeros and overflow); clippy with and without `--all-features` and `cargo test --workspace` pass too. pablogonz12: your four-stage offline check agrees with what I expected, no program gained or lost, since nothing in the retail dump reaches the f64 class. So this PR is a correctness addition with no measured gain on the title, and it can wait behind the bundles that do gain programs. AI-assisted (Claude Code); no game data.
Marvisak commented 2026-11-25 02:05:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:20:26Z.


Automated triage for the maintainers.

Merge candidate. The merge of main (faf20ac) resolves the conflicts from the last triage; the branch now merges cleanly. It still carries #416's v_cvt_f32_f64 commit unchanged, so #416 can close if this merges.

New in crates/victory-shader/src/emit/lower/double.rs: v_add/mul/fma/max/min_f64, the v_cmp(x)_*_f64 predicates (constant f/tru without building doubles) and the f64/i32/u32/f32 conversions, with DOUBLES and DOUBLE_EXTENSIONS (SFI0 0x1/0x20) declared in shader.rs. I checked the source handling against the GFX10 rules: a 32-bit literal is the high dword with a zero low dword, inline constants 240-248 are their double values, abs then neg act on the sign bit, and result modifiers on doubles are refused. Saturating v_cvt_i32/u32_f64 with NaN to 0 matches the RDNA2 ISA description. unfolded_pair (c4da80b) works around the AMD host compiler bug reproduced in the thread by XORing each register dword with WaveGetLaneIndex() >> 31 (always 0); f64_reads_uniform_pairs_at_odd_dwords covers it.

Open point for the maintainers: of two zeros, max_min64 reuses the f32 rule; as the PR says, that was not checked against console hardware for f64.

CI: passing (check). Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149446558 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7149446558). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:20:26Z. --- <!-- victory-triage v1 head=faf20acb63905f22bbe41065292b667ddb03dde1 verdict=merge-candidate at=2026-11-26T01:23:40Z --> Automated triage for the maintainers. **Merge candidate.** The merge of `main` (`faf20ac`) resolves the conflicts from the last triage; the branch now merges cleanly. It still carries #416's `v_cvt_f32_f64` commit unchanged, so #416 can close if this merges. New in `crates/victory-shader/src/emit/lower/double.rs`: `v_add/mul/fma/max/min_f64`, the `v_cmp(x)_*_f64` predicates (constant `f`/`tru` without building doubles) and the f64/i32/u32/f32 conversions, with `DOUBLES` and `DOUBLE_EXTENSIONS` (SFI0 `0x1`/`0x20`) declared in `shader.rs`. I checked the source handling against the GFX10 rules: a 32-bit literal is the high dword with a zero low dword, inline constants 240-248 are their double values, abs then neg act on the sign bit, and result modifiers on doubles are refused. Saturating `v_cvt_i32/u32_f64` with NaN to 0 matches the RDNA2 ISA description. `unfolded_pair` (`c4da80b`) works around the AMD host compiler bug reproduced in the thread by XORing each register dword with `WaveGetLaneIndex() >> 31` (always 0); `f64_reads_uniform_pairs_at_odd_dwords` covers it. Open point for the maintainers: of two zeros, `max_min64` reuses the f32 rule; as the PR says, that was not checked against console hardware for f64. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
astrosteveo commented 2026-11-25 06:02:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by astrosteveo on 2026-11-25T05:43:58Z.


A result from a host not reported here: Arch Linux, Wine 11.22, vkd3d-proton, RTX 5080, driver 620.73.04, 70fa9b7 merged onto main 940d32f. One of the new tests fails:

f64_conversions_match_rdna2: hardware: v_cvt_i32_f64(NaN)
  left: 2147483648
 right: 0

It is NaN only, for both v_cvt_i32_f64 and v_cvt_u32_f64, and both give 0x80000000. The other values in the test are right, infinities and out-of-range values included, and so are the other f64 tests. The code relies on the host turning NaN into 0, which this one doesn't. I don't know whether native NVIDIA does.

A compare and a select fixes it: 0499a61 (branch fix/1262-nan, one commit on your head). With it all 10 f64 tests pass here, and clippy is clean for the GNU and MSVC Windows targets. Take it if you like.

Separately, the red CI looks unrelated to this PR: that run (00:57 UTC) failed only gathers_at_a_level_match_the_hardware and permutes_read_the_lane_named_and_zero_from_lanes_left_out, which main has skipped on machines without a GPU since #1911 and #1925. A push or "Update branch" should give a fresh result; a re-run keeps the old merge commit.


Co-Authored-By: Claude Opus 5.5 <[email protected]>

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154085580 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7154085580). Originally posted by [astrosteveo](https://github.com/astrosteveo) on 2026-11-25T05:43:58Z. --- A result from a host not reported here: Arch Linux, Wine 11.22, vkd3d-proton, RTX 5080, driver 620.73.04, `70fa9b7` merged onto `main` `940d32f`. One of the new tests fails: ``` f64_conversions_match_rdna2: hardware: v_cvt_i32_f64(NaN) left: 2147483648 right: 0 ``` It is NaN only, for both `v_cvt_i32_f64` and `v_cvt_u32_f64`, and both give `0x80000000`. The other values in the test are right, infinities and out-of-range values included, and so are the other f64 tests. The code relies on the host turning NaN into 0, which this one doesn't. I don't know whether native NVIDIA does. A compare and a select fixes it: [`0499a61`](https://github.com/astrosteveo/VIctory/commit/0499a61) (branch [`fix/1262-nan`](https://github.com/astrosteveo/VIctory/tree/fix/1262-nan), one commit on your head). With it all 10 f64 tests pass here, and clippy is clean for the GNU and MSVC Windows targets. Take it if you like. Separately, the red CI looks unrelated to this PR: that run (00:57 UTC) failed only `gathers_at_a_level_match_the_hardware` and `permutes_read_the_lane_named_and_zero_from_lanes_left_out`, which `main` has skipped on machines without a GPU since #1911 and #1925. A push or "Update branch" should give a fresh result; a re-run keeps the old merge commit. --- <sub>Co-Authored-By: Claude Opus 5.5 &lt;[email protected]&gt;</sub>
Dathinel commented 2026-11-25 07:03:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T06:03:33Z.


On native Windows D3D12, my RTX 3050 Laptop (Ampere, driver 32.0.16.1062) returned 0x00000000 for both v_cvt_i32_f64(NaN) and v_cvt_u32_f64(NaN) on the original PR. WARP returned zero for both as well.

I merged 70fa9b7 onto 940d32f and ran cargo test --frozen -p victory-shader --lib f64_conversions_match_rdna2 -- --nocapture --test-threads=1. The unmodified test passed. In a separate run I printed the two NaN results in the test callback to verify the values and that both backends executed. The unmodified test also passed with your 0499a61 follow-up on the same base.

That gives one native Ampere data point. A native run on the same RTX 5080 would help distinguish adapter and software-stack differences. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154398746 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7154398746). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T06:03:33Z. --- On native Windows D3D12, my RTX 3050 Laptop (Ampere, driver 32.0.16.1062) returned `0x00000000` for both `v_cvt_i32_f64(NaN)` and `v_cvt_u32_f64(NaN)` on the original PR. WARP returned zero for both as well. I merged `70fa9b7` onto `940d32f` and ran `cargo test --frozen -p victory-shader --lib f64_conversions_match_rdna2 -- --nocapture --test-threads=1`. The unmodified test passed. In a separate run I printed the two NaN results in the test callback to verify the values and that both backends executed. The unmodified test also passed with your `0499a61` follow-up on the same base. That gives one native Ampere data point. A native run on the same RTX 5080 would help distinguish adapter and software-stack differences. AI-assisted.
bvtterbroot commented 2026-11-25 20:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bvtterbroot on 2026-11-25T19:54:06Z.


FIND-21 (from #1633) on this PR, measured on two more AMD architectures: v_add_f64 and v_mul_f64 whose sources share a dword come out wrong on RDNA3 and RDNA2 too. WARP computes them correctly.

Setup. 70fa9b7 merged locally onto main 13f91ca. The only conflict was the feature bits in shader.rs, where I kept both sides. Windows 11, Rust 1.98.1. Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010) and the Ryzen 7 7800X3D's iGPU (RDNA2, gfx1036, driver 32.0.21045.29003). I picked each as the hardware adapter with a local patch.

Case. v_add_f64 v[6:7], v[1:2], v[2:3] (and the same with v_mul_f64), where v2 is the high dword of the first source and the low dword of the second. Inputs v1..v3 = 0, 0x3ff80000, 0x40000000, so a = 1.5 and b = 0x400000003ff80000.

v_add_f64 v_mul_f64
want 0x400c00003ff80000 0x400800005ff40000
WARP 0x400c00003ff80000 ✓ 0x400800005ff40000 ✓
RX 7900 XTX 0x400800001ffc0000 ✗ 0x400200002ffa0000 ✗
RDNA2 iGPU 0x400800001ffc0000 ✗ 0x400200002ffa0000 ✗

Both wrong results are what you get if b's high dword is v2 instead of v3, i.e. b = 0x3ff800003ff80000.

Not specific to makeDouble. I also built each source as bitcast(zext(lo) | zext(hi) << 32) to double instead of makeDouble(lo, hi). The words came out the same on both GPUs. So the shared value seems to be lost in the driver's 64-bit register pairing, not in the DXIL op. That fits #1599, where 64-bit integer compares fail the same way. I have not found a cheap DXIL form that avoids it. If one is needed, the options I see are to refuse 64-bit float instructions with overlapping VGPR sources on AMD hosts, or to route one source through something the driver can't coalesce.

The test I used, for valu_tests.rs on this branch (it uses the PR's run_f64_raw). It fails on both AMD GPUs and passes on WARP:

#[test]
fn f64_sources_sharing_a_dword() {
    // v_add_f64 / v_mul_f64 v[6:7], v[1:2], v[2:3]: v2 is the high dword of
    // the first source and the low dword of the second (FIND-21).
    let a = f64::from_bits(0x3ff8_0000_0000_0000); // 1.5: v1 = 0, v2 = 0x3ff80000
    let b = f64::from_bits(0x4000_0000_3ff8_0000); // v2, v3 = 0x40000000
    let inputs = [[0, 0x3ff8_0000, 0x4000_0000, 0]];
    type Op = (&'static str, u16, fn(f64, f64) -> f64);
    let ops: [Op; 2] = [
        ("v_add_f64", 0x164, |x, y| x + y),
        ("v_mul_f64", 0x165, |x, y| x * y),
    ];
    for (name, op, f) in ops {
        let want = f(a, b);
        run_f64_raw(
            &vop3(op, 6, vgpr(1), vgpr(2), 0),
            &inputs,
            |backend, _, got| {
                eprintln!(
                    "{backend}: {name}: {:#018x} ({}), want {:#018x} ({want})",
                    got,
                    f64::from_bits(got),
                    want.to_bits()
                );
                assert!(
                    same_f64(got, want),
                    "{backend}: {name} of shared-dword sources = {}, want {want}",
                    f64::from_bits(got)
                );
            },
        );
    }
}

Synthetic test only, no game files. Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172918903 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7172918903). Originally posted by [bvtterbroot](https://github.com/bvtterbroot) on 2026-11-25T19:54:06Z. --- FIND-21 (from #1633) on this PR, measured on two more AMD architectures: **`v_add_f64` and `v_mul_f64` whose sources share a dword come out wrong on RDNA3 and RDNA2 too.** WARP computes them correctly. **Setup.** `70fa9b7` merged locally onto `main` `13f91ca`. The only conflict was the feature bits in `shader.rs`, where I kept both sides. Windows 11, Rust 1.98.1. Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010) and the Ryzen 7 7800X3D's iGPU (RDNA2, gfx1036, driver 32.0.21045.29003). I picked each as the hardware adapter with a local patch. **Case.** `v_add_f64 v[6:7], v[1:2], v[2:3]` (and the same with `v_mul_f64`), where `v2` is the high dword of the first source and the low dword of the second. Inputs `v1..v3 = 0, 0x3ff80000, 0x40000000`, so `a = 1.5` and `b = 0x400000003ff80000`. | | `v_add_f64` | `v_mul_f64` | |---|---|---| | want | `0x400c00003ff80000` | `0x400800005ff40000` | | WARP | `0x400c00003ff80000` ✓ | `0x400800005ff40000` ✓ | | RX 7900 XTX | `0x400800001ffc0000` ✗ | `0x400200002ffa0000` ✗ | | RDNA2 iGPU | `0x400800001ffc0000` ✗ | `0x400200002ffa0000` ✗ | Both wrong results are what you get if `b`'s high dword is `v2` instead of `v3`, i.e. `b = 0x3ff800003ff80000`. **Not specific to `makeDouble`.** I also built each source as `bitcast(zext(lo) | zext(hi) << 32)` to `double` instead of `makeDouble(lo, hi)`. The words came out the same on both GPUs. So the shared value seems to be lost in the driver's 64-bit register pairing, not in the DXIL op. That fits #1599, where 64-bit integer compares fail the same way. I have not found a cheap DXIL form that avoids it. If one is needed, the options I see are to refuse 64-bit float instructions with overlapping VGPR sources on AMD hosts, or to route one source through something the driver can't coalesce. The test I used, for `valu_tests.rs` on this branch (it uses the PR's `run_f64_raw`). It fails on both AMD GPUs and passes on WARP: ```rust #[test] fn f64_sources_sharing_a_dword() { // v_add_f64 / v_mul_f64 v[6:7], v[1:2], v[2:3]: v2 is the high dword of // the first source and the low dword of the second (FIND-21). let a = f64::from_bits(0x3ff8_0000_0000_0000); // 1.5: v1 = 0, v2 = 0x3ff80000 let b = f64::from_bits(0x4000_0000_3ff8_0000); // v2, v3 = 0x40000000 let inputs = [[0, 0x3ff8_0000, 0x4000_0000, 0]]; type Op = (&'static str, u16, fn(f64, f64) -> f64); let ops: [Op; 2] = [ ("v_add_f64", 0x164, |x, y| x + y), ("v_mul_f64", 0x165, |x, y| x * y), ]; for (name, op, f) in ops { let want = f(a, b); run_f64_raw( &vop3(op, 6, vgpr(1), vgpr(2), 0), &inputs, |backend, _, got| { eprintln!( "{backend}: {name}: {:#018x} ({}), want {:#018x} ({want})", got, f64::from_bits(got), want.to_bits() ); assert!( same_f64(got, want), "{backend}: {name} of shared-dword sources = {}, want {want}", f64::from_bits(got) ); }, ); } } ``` Synthetic test only, no game files. _Tested with AI assistance (Claude Code)._
bvtterbroot commented 2026-11-25 21:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bvtterbroot on 2026-11-25T20:11:18Z.


Follow-up to my FIND-21 comment above. The sources don't have to share a dword. A single double read from dwords 1 and 2 of one 4-dword load is wrong on its own. Same setup (RX 7900 XTX and the gfx1036 iGPU, identical words on both), with v1..v4 taken from the root constants (one load):

instruction AMD WARP
v_add_f64 v[6:7], v[1:2], 1.0 ✓ ✓
v_add_f64 v[6:7], v[3:4], 1.0 ✓ ✓
v_add_f64 v[6:7], v[1:2], v[3:4] ✓ ✓
v_add_f64 v[6:7], v[2:3], 1.0 ✗ 0x400400001ffc0000 ✓
v_add_f64 v[6:7], v[2:3], v[2:3] ✗ ✓
v_add_f64 v[6:7], v[2:3], v[3:4] ✗ ✓
v_mul_f64 v[6:7], v[1:2], v[2:3] ✗ ✓

Every failing result is the double with dword 1 as both halves: v[2:3] reads as (v2, v2).

  • If v2 is first written by an ALU instruction whose operand is only known at run time (v_xor_b32 v2, v2, v4 with v4 = 0), the result is correct.
  • | 0 with a constant 0 in front of makeDouble is folded away and does not help. Neither does the i64 bitcast route.

My guess, not verified: these values are uniform, so they sit in an SGPR tuple. A 64-bit SGPR operand needs an even-aligned pair, and the driver's copy of the odd-aligned pair s[n+1:n+2] duplicates its first register. That would make uniform doubles at an odd dword offset of a load the trigger, whether or not anything is shared. I have not checked divergent (VGPR) values: this test host only has uniform inputs.

It is not limited to this PR. main lowers no 64-bit float instruction yet, so it is unaffected. The open PRs that build doubles from register pairs would see the same, for example #2348, #416, #2594, #2713, #1469, #2728 and #2350.

Synthetic test only, no game files. Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173308799 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7173308799). Originally posted by [bvtterbroot](https://github.com/bvtterbroot) on 2026-11-25T20:11:18Z. --- Follow-up to my FIND-21 comment above. The sources don't have to share a dword. **A single double read from dwords 1 and 2 of one 4-dword load is wrong on its own.** Same setup (RX 7900 XTX and the gfx1036 iGPU, identical words on both), with `v1..v4` taken from the root constants (one load): | instruction | AMD | WARP | |---|---|---| | `v_add_f64 v[6:7], v[1:2], 1.0` | ✓ | ✓ | | `v_add_f64 v[6:7], v[3:4], 1.0` | ✓ | ✓ | | `v_add_f64 v[6:7], v[1:2], v[3:4]` | ✓ | ✓ | | `v_add_f64 v[6:7], v[2:3], 1.0` | ✗ `0x400400001ffc0000` | ✓ | | `v_add_f64 v[6:7], v[2:3], v[2:3]` | ✗ | ✓ | | `v_add_f64 v[6:7], v[2:3], v[3:4]` | ✗ | ✓ | | `v_mul_f64 v[6:7], v[1:2], v[2:3]` | ✗ | ✓ | Every failing result is the double with dword 1 as both halves: `v[2:3]` reads as `(v2, v2)`. - If `v2` is first written by an ALU instruction whose operand is only known at run time (`v_xor_b32 v2, v2, v4` with `v4 = 0`), the result is correct. - `| 0` with a constant 0 in front of `makeDouble` is folded away and does not help. Neither does the `i64` bitcast route. My guess, not verified: these values are uniform, so they sit in an SGPR tuple. A 64-bit SGPR operand needs an even-aligned pair, and the driver's copy of the odd-aligned pair `s[n+1:n+2]` duplicates its first register. That would make uniform doubles at an odd dword offset of a load the trigger, whether or not anything is shared. I have not checked divergent (VGPR) values: this test host only has uniform inputs. It is not limited to this PR. `main` lowers no 64-bit float instruction yet, so it is unaffected. The open PRs that build doubles from register pairs would see the same, for example #2348, #416, #2594, #2713, #1469, #2728 and #2350. Synthetic test only, no game files. _Tested with AI assistance (Claude Code)._
JoeY54 commented 2026-11-25 22:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by JoeY54 on 2026-11-25T21:39:49Z.


Progress on my #1633 claim (FP64 verification of this PR on native Windows D3D12). The results on RTX 5090, the Ryzen 9 9950X3D iGPU and WARP are below. The Radeon 860M is not done yet.

Setup. 70fa9b7 merged locally onto main 13f91ca. The only conflict was the SFI0 feature bits in shader.rs, where I kept both sides. Windows 11 build 26300, Rust 1.98.1.

  • NVIDIA GeForce RTX 5090, driver 32.0.16.2124 (621.24)
  • AMD Radeon Graphics, the Ryzen 9 9950X3D iGPU (RDNA2), driver 32.0.21045.29003
  • WARP

To pick the iGPU as the hardware adapter I used a local test-only patch: VICTORY_ADAPTER matches the adapter description.

1. The PR's own f64 tests

cargo test -p victory-shader --lib f64 -- --test-threads=1 --nocapture

RTX 5090 + WARP 9950X3D iGPU + WARP
10 tests (cvt_f32_f64_* ×4, f64_add_mul_and_fma_are_ieee, f64_arithmetic_reads_sgpr_pairs, f64_conversions_match_rdna2, f64_max_and_min_order_zeros_and_skip_nan, f64_sources_apply_abs_and_neg, v_cmp_f64_matches_ieee) 10/10 ok 10/10 ok

No backend was skipped. On native RTX 5090, v_cvt_i32_f64(NaN) and v_cvt_u32_f64(NaN) give 0, which matches Dathinel's RTX 3050 result. So astrosteveo's 0x80000000 on the RTX 5080 looks specific to Wine/vkd3d-proton, not to NVIDIA hardware.

2. FIND-21 (doubles at an odd dword offset, or sharing a dword)

These are bvtterbroot's cases, run over two inputs: [0, 0x3ff80000, 0x40000000, 0] and [0x11111111, 0x3ff80000, 0x40000000, 0x40100000].

instruction RTX 5090 9950X3D iGPU WARP
v_add_f64 v[6:7], v[1:2], 1.0 ✓ ✓ ✓
v_add_f64 v[6:7], v[3:4], 1.0 ✓ ✓ ✓
v_add_f64 v[6:7], v[1:2], v[3:4] ✓ ✓ ✓
v_add_f64 v[6:7], v[2:3], 1.0 ✓ ✗ 0x400400001ffc0000 ✓
v_add_f64 v[6:7], v[2:3], v[2:3] ✓ ✗ 0x400800003ff80000 ✓
v_add_f64 v[6:7], v[2:3], v[3:4] ✓ ✗ ✓
v_add_f64 v[6:7], v[1:2], v[2:3] ✓ ✗ 0x400800001ffc0000 ✓
v_mul_f64 v[6:7], v[1:2], v[2:3] ✓ ✗ 0x400200002ffa0000 ✓

The iGPU's wrong words are identical to bvtterbroot's RX 7900 XTX and 7800X3D iGPU results (same AMD driver build as that iGPU). Every one is consistent with v[2:3] being read as (v2, v2). For example, input 1 of v_add_f64 v[6:7], v[2:3], v[3:4] gives 0x401600004ffe0000 = (v2:v2) + (v3:v4). The RTX 5090 is correct on all 16 results (8 instructions × 2 inputs). So on this host FIND-21 is AMD-only, and the lowering's operand pairing is right.

Synthetic inputs only, no game files. Revisions as above; the local merge and test patch are not pushed. AI-assisted verification (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175377173 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7175377173). Originally posted by [JoeY54](https://github.com/JoeY54) on 2026-11-25T21:39:49Z. --- Progress on my #1633 claim (FP64 verification of this PR on native Windows D3D12). The results on RTX 5090, the Ryzen 9 9950X3D iGPU and WARP are below. The Radeon 860M is not done yet. **Setup.** `70fa9b7` merged locally onto `main` `13f91ca`. The only conflict was the SFI0 feature bits in `shader.rs`, where I kept both sides. Windows 11 build 26300, Rust 1.98.1. - NVIDIA GeForce RTX 5090, driver 32.0.16.2124 (621.24) - AMD Radeon Graphics, the Ryzen 9 9950X3D iGPU (RDNA2), driver 32.0.21045.29003 - WARP To pick the iGPU as the hardware adapter I used a local test-only patch: `VICTORY_ADAPTER` matches the adapter description. **1. The PR's own f64 tests** `cargo test -p victory-shader --lib f64 -- --test-threads=1 --nocapture` | | RTX 5090 + WARP | 9950X3D iGPU + WARP | |---|---|---| | 10 tests (`cvt_f32_f64_*` ×4, `f64_add_mul_and_fma_are_ieee`, `f64_arithmetic_reads_sgpr_pairs`, `f64_conversions_match_rdna2`, `f64_max_and_min_order_zeros_and_skip_nan`, `f64_sources_apply_abs_and_neg`, `v_cmp_f64_matches_ieee`) | 10/10 ok | 10/10 ok | No backend was skipped. On native RTX 5090, `v_cvt_i32_f64(NaN)` and `v_cvt_u32_f64(NaN)` give 0, which matches Dathinel's RTX 3050 result. So astrosteveo's `0x80000000` on the RTX 5080 looks specific to Wine/vkd3d-proton, not to NVIDIA hardware. **2. FIND-21 (doubles at an odd dword offset, or sharing a dword)** These are bvtterbroot's cases, run over two inputs: `[0, 0x3ff80000, 0x40000000, 0]` and `[0x11111111, 0x3ff80000, 0x40000000, 0x40100000]`. | instruction | RTX 5090 | 9950X3D iGPU | WARP | |---|---|---|---| | `v_add_f64 v[6:7], v[1:2], 1.0` | ✓ | ✓ | ✓ | | `v_add_f64 v[6:7], v[3:4], 1.0` | ✓ | ✓ | ✓ | | `v_add_f64 v[6:7], v[1:2], v[3:4]` | ✓ | ✓ | ✓ | | `v_add_f64 v[6:7], v[2:3], 1.0` | ✓ | ✗ `0x400400001ffc0000` | ✓ | | `v_add_f64 v[6:7], v[2:3], v[2:3]` | ✓ | ✗ `0x400800003ff80000` | ✓ | | `v_add_f64 v[6:7], v[2:3], v[3:4]` | ✓ | ✗ | ✓ | | `v_add_f64 v[6:7], v[1:2], v[2:3]` | ✓ | ✗ `0x400800001ffc0000` | ✓ | | `v_mul_f64 v[6:7], v[1:2], v[2:3]` | ✓ | ✗ `0x400200002ffa0000` | ✓ | The iGPU's wrong words are identical to bvtterbroot's RX 7900 XTX and 7800X3D iGPU results (same AMD driver build as that iGPU). Every one is consistent with `v[2:3]` being read as `(v2, v2)`. For example, input 1 of `v_add_f64 v[6:7], v[2:3], v[3:4]` gives `0x401600004ffe0000` = (v2:v2) + (v3:v4). The RTX 5090 is correct on all 16 results (8 instructions × 2 inputs). So on this host FIND-21 is AMD-only, and the lowering's operand pairing is right. Synthetic inputs only, no game files. Revisions as above; the local merge and test patch are not pushed. AI-assisted verification (Claude Code).
MamaLeVrai commented 2026-11-26 01:03:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-26T00:16:09Z.


Thanks bvtterbroot for FIND-21 and the cases, and JoeY54 for the RTX 5090 and 9950X3D runs. Your words made this quick to pin down.

Reproduced on an RX 6950 XT (RDNA2, driver 32.0.21045.29003, Windows 11 26300), PR head 70fa9b7. The new test f64_reads_uniform_pairs_at_odd_dwords takes v1..v4 from the four root constants (one load) and runs 4 inputs: JoeY54's two, plus [0x89abcdef, 0x40490fdb, 0xc0080000, 0x3fd00000] and [0, 0x3ff80000, 0x3ff00000, 0x40000000]. Without the change: 45 wrong results on the hardware adapter, 0 on WARP. The words match yours:

  • v_add_f64 v[6:7], v[2:3], 1.0: 0x400400001ffc0000
  • v_add_f64 v[6:7], v[2:3], v[2:3]: 0x400800003ff80000
  • v_add_f64 v[6:7], v[1:2], v[2:3]: 0x400800001ffc0000
  • v_mul_f64 v[6:7], v[1:2], v[2:3]: 0x400200002ffa0000
  • v_add_f64 v[6:7], v[2:3], v[3:4] on JoeY54's input 1: 0x401600004ffe0000

These were also wrong, all as if v[2:3] were (v2, v2): v_fma_f64 v[6:7], v[2:3], v[3:4], v[1:2], v_max_f64 v[2:3], 1.0, v_min_f64 v[2:3], 4.0, v_cvt_f32_f64, v_cvt_i32_f64 and v_cvt_u32_f64 of v[2:3], v_cmp_gt_f64 v[2:3], 2.0 and v_cmp_lt_f64 v[1:2], v[2:3]. These were right: the disjoint v_add_f64 v[1:2], v[3:4], v_cvt_f64_f32 v2, and the 64-bit integer ops on v[2:3] (v_lshlrev_b64 and v_lshrrev_b64 by a runtime amount, v_mad_u64_u32). So on this card I did not see the duplication for i64 pairs.

Workaround (c4da80b, pushed to this branch): each dword of a register-pair f64 source is XORed with WaveGetLaneIndex() >> 31 before makeDouble. That is zero on every lane, since the lane index is below 128, but the compiler cannot fold it. Inline constants and literals are unchanged.

Why it works, as far as I know: it is the same idea as bvtterbroot's v_xor_b32 with a zero known only at run time. The dwords are no longer the raw elements of the load, so the compiler cannot reuse them as an odd-aligned pair. My guess, not checked against an ISA dump, is that they also become per-lane (VGPR) values, and RDNA has no alignment rule for VGPR pairs. Other forms fixed the test too: XORing only the low dword, or only the high one; WaveReadLaneFirst of each dword; a select on WaveActiveAnyTrue(true). I did not keep WaveReadLaneFirst, because it is wrong for divergent values. I did not keep the select either, because of helper-only waves. The lane-index form is right on every lane.

Results with the change

  • The new test passes on the RX 6950 XT and on WARP. Neither backend was skipped.
  • cargo test --release -p victory-shader --lib: 257 passed, 0 failed, 3 ignored, in two runs. Without the lowering change: 256 passed, 1 failed (the new test, 45 wrong results).
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • The branch merged locally onto main 63bcca4: 313 passed, 0 failed, 3 ignored. Two conflicts, and I kept both sides of each: the SFI0 feature bits in shader.rs, and v_cvt_f32_u32 in lower.rs. That merge is not pushed. The branch still conflicts with main.

Cost: per program, one lane index and one shift, in the entry block. Per dword of a register-pair f64 source, one XOR. That is two 32-bit ALU ops next to an f64 op, which runs at 1/16 rate on RDNA2. I did not time it. If a later compiler proves the lane index's range, it could fold the zero away and bring the bug back. The test would catch that.

Not tested here: RDNA3, NVIDIA, and inputs that differ per lane. The harness runs one thread, so all its inputs are uniform.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178578496 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7178578496). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-26T00:16:09Z. --- Thanks bvtterbroot for FIND-21 and the cases, and JoeY54 for the RTX 5090 and 9950X3D runs. Your words made this quick to pin down. **Reproduced on an RX 6950 XT** (RDNA2, driver 32.0.21045.29003, Windows 11 26300), PR head `70fa9b7`. The new test `f64_reads_uniform_pairs_at_odd_dwords` takes v1..v4 from the four root constants (one load) and runs 4 inputs: JoeY54's two, plus `[0x89abcdef, 0x40490fdb, 0xc0080000, 0x3fd00000]` and `[0, 0x3ff80000, 0x3ff00000, 0x40000000]`. Without the change: 45 wrong results on the hardware adapter, 0 on WARP. The words match yours: - `v_add_f64 v[6:7], v[2:3], 1.0`: `0x400400001ffc0000` - `v_add_f64 v[6:7], v[2:3], v[2:3]`: `0x400800003ff80000` - `v_add_f64 v[6:7], v[1:2], v[2:3]`: `0x400800001ffc0000` - `v_mul_f64 v[6:7], v[1:2], v[2:3]`: `0x400200002ffa0000` - `v_add_f64 v[6:7], v[2:3], v[3:4]` on JoeY54's input 1: `0x401600004ffe0000` These were also wrong, all as if `v[2:3]` were `(v2, v2)`: `v_fma_f64 v[6:7], v[2:3], v[3:4], v[1:2]`, `v_max_f64 v[2:3], 1.0`, `v_min_f64 v[2:3], 4.0`, `v_cvt_f32_f64`, `v_cvt_i32_f64` and `v_cvt_u32_f64` of `v[2:3]`, `v_cmp_gt_f64 v[2:3], 2.0` and `v_cmp_lt_f64 v[1:2], v[2:3]`. These were right: the disjoint `v_add_f64 v[1:2], v[3:4]`, `v_cvt_f64_f32 v2`, and the 64-bit integer ops on `v[2:3]` (`v_lshlrev_b64` and `v_lshrrev_b64` by a runtime amount, `v_mad_u64_u32`). So on this card I did not see the duplication for i64 pairs. **Workaround** (`c4da80b`, pushed to this branch): each dword of a register-pair f64 source is XORed with `WaveGetLaneIndex() >> 31` before `makeDouble`. That is zero on every lane, since the lane index is below 128, but the compiler cannot fold it. Inline constants and literals are unchanged. Why it works, as far as I know: it is the same idea as bvtterbroot's `v_xor_b32` with a zero known only at run time. The dwords are no longer the raw elements of the load, so the compiler cannot reuse them as an odd-aligned pair. My guess, not checked against an ISA dump, is that they also become per-lane (VGPR) values, and RDNA has no alignment rule for VGPR pairs. Other forms fixed the test too: XORing only the low dword, or only the high one; `WaveReadLaneFirst` of each dword; a select on `WaveActiveAnyTrue(true)`. I did not keep `WaveReadLaneFirst`, because it is wrong for divergent values. I did not keep the select either, because of helper-only waves. The lane-index form is right on every lane. **Results with the change** - The new test passes on the RX 6950 XT and on WARP. Neither backend was skipped. - `cargo test --release -p victory-shader --lib`: 257 passed, 0 failed, 3 ignored, in two runs. Without the lowering change: 256 passed, 1 failed (the new test, 45 wrong results). - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - The branch merged locally onto `main` `63bcca4`: 313 passed, 0 failed, 3 ignored. Two conflicts, and I kept both sides of each: the SFI0 feature bits in `shader.rs`, and `v_cvt_f32_u32` in `lower.rs`. That merge is not pushed. The branch still conflicts with `main`. **Cost**: per program, one lane index and one shift, in the entry block. Per dword of a register-pair f64 source, one XOR. That is two 32-bit ALU ops next to an f64 op, which runs at 1/16 rate on RDNA2. I did not time it. If a later compiler proves the lane index's range, it could fold the zero away and bring the bug back. The test would catch that. Not tested here: RDNA3, NVIDIA, and inputs that differ per lane. The harness runs one thread, so all its inputs are uniform. AI-assisted (Claude Code); no game data.
MamaLeVrai commented 2026-11-26 01:04:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-26T00:26:07Z.


The branch is mergeable again: faf20ac merges main 63bcca4 into it. There were two conflicts, and both keep the two sides:

  • In shader.rs, the SFI0 feature bits for doubles sit beside main's UAVS_EVERY_STAGE.
  • In lower.rs, the new v_cvt_f32_f64 arm sits beside main's exact v_cvt_f32_u32, which is now its own arm. v_cvt_f32_u32 left the shared arm with v_cvt_f32_i32, as on main.

On the RX 6950 XT: cargo test --release -p victory-shader --lib gives 313 passed, 0 failed, 3 ignored, in 2 runs out of 2. The FIND-21 test above is included. cargo clippy -p victory-shader --all-targets --locked -- -D warnings passes, with and without --all-features.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178751670 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7178751670). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-26T00:26:07Z. --- The branch is mergeable again: `faf20ac` merges `main` `63bcca4` into it. There were two conflicts, and both keep the two sides: - In `shader.rs`, the SFI0 feature bits for doubles sit beside main's `UAVS_EVERY_STAGE`. - In `lower.rs`, the new `v_cvt_f32_f64` arm sits beside main's exact `v_cvt_f32_u32`, which is now its own arm. `v_cvt_f32_u32` left the shared arm with `v_cvt_f32_i32`, as on main. On the RX 6950 XT: `cargo test --release -p victory-shader --lib` gives 313 passed, 0 failed, 3 ignored, in 2 runs out of 2. The FIND-21 test above is included. `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` passes, with and without `--all-features`. AI-assisted (Claude Code); no game data.
steven-seagull27 commented 2026-11-26 02:07:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T01:58:50Z.


Two results for the outstanding NVIDIA and per-lane questions. Native Windows D3D12, RTX 5080 (driver 621.40) and Microsoft WARP, Windows build 26300.10075. I resolved each D3D12 device LUID through DXGI and verified completed UAV readbacks.

Register pairs with lane-varying inputs. At faf20acb, including c4da80b, both backends matched the CPU bit-for-bit on 3,456 lane results each. The fixture translates synthetic RDNA2 instructions through the PR and reads both result dwords together from the same dispatch.

  • In one 32-thread group, ADD and MUL read v[1:2] and v[2:3]. FMA also reads v[3:4]. I placed the destination at v[1:2], v[2:3], and the disjoint v[6:7].
  • I initialized v1..v4 from four root constants. In one run all four dwords varied by lane ID. In another only v1 and v3 varied, leaving each pair with one uniform and one varying dword. Each shape ran over three finite input sets.
  • With full EXEC all 32 lanes computed. With even-lane EXEC, odd lanes retained both old destination words, including when the destination overlapped the sources. The total per backend comprises 2,592 active arithmetic results and 864 preserved results. The reference used Rust binary64 add, multiply, and mul_add. The branch's uniform odd-dword test also passed on both devices.

NaN-to-integer on native RTX 5080. I also tested 70fa9b7, the head used in the Wine/vkd3d-proton report, and current faf20acb. On both heads, native RTX 5080 and WARP returned 0x00000000 from both v_cvt_i32_f64 and v_cvt_u32_f64 for 7ff8000000000000, fff8000000001234, 7ff0000000000001, and fff0000001234567. That covers positive/negative quiet and signaling NaNs. It puts a native Windows result next to the reported 0x80000000 on the same GPU model under Wine.

Local test-only instrumentation, with Codex assistance. I did not run the varying-lane fixture on AMD hardware.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180339099 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7180339099). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T01:58:50Z. --- Two results for the outstanding NVIDIA and per-lane questions. Native Windows D3D12, RTX 5080 (driver 621.40) and Microsoft WARP, Windows build 26300.10075. I resolved each D3D12 device LUID through DXGI and verified completed UAV readbacks. **Register pairs with lane-varying inputs.** At `faf20acb`, including `c4da80b`, both backends matched the CPU bit-for-bit on **3,456 lane results each**. The fixture translates synthetic RDNA2 instructions through the PR and reads both result dwords together from the same dispatch. - In one 32-thread group, ADD and MUL read `v[1:2]` and `v[2:3]`. FMA also reads `v[3:4]`. I placed the destination at `v[1:2]`, `v[2:3]`, and the disjoint `v[6:7]`. - I initialized `v1..v4` from four root constants. In one run all four dwords varied by lane ID. In another only `v1` and `v3` varied, leaving each pair with one uniform and one varying dword. Each shape ran over three finite input sets. - With full EXEC all 32 lanes computed. With even-lane EXEC, odd lanes retained both old destination words, including when the destination overlapped the sources. The total per backend comprises 2,592 active arithmetic results and 864 preserved results. The reference used Rust binary64 add, multiply, and `mul_add`. The branch's uniform odd-dword test also passed on both devices. **NaN-to-integer on native RTX 5080.** I also tested `70fa9b7`, the head used in the Wine/vkd3d-proton report, and current `faf20acb`. On **both** heads, native RTX 5080 and WARP returned `0x00000000` from **both** `v_cvt_i32_f64` and `v_cvt_u32_f64` for `7ff8000000000000`, `fff8000000001234`, `7ff0000000000001`, and `fff0000001234567`. That covers positive/negative quiet and signaling NaNs. It puts a native Windows result next to the reported `0x80000000` on the same GPU model under Wine. Local test-only instrumentation, with Codex assistance. I did not run the varying-lane fixture on AMD hardware.
fuzeofficlal commented 2026-11-26 17:39:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T17:39:27Z.

Review: CHANGES_REQUESTED


Verified on main (63bcca43) across three D3D12 adapters (RTX 5090, AMD Ryzen 9 9950X integrated RDNA2 gfx1036, and Microsoft WARP) with Windows SDK dxil.dll:

  • cargo xtask policy (192 files ok; crates/victory-shader/src/emit/lower.rs = 521,403 B < 524,288 B) and cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features) pass.
  • All 11 new tests (cvt_f32_f64_*, f64_*, v_cmp_f64_*) pass on RTX 5090 and WARP.
  • Additional probes confirmed true fused v_fma_f64 rounding, v_cvt_i32_f64/v_cvt_u32_f64 saturation and NaN -> 0 behavior, modifier rejections, and the odd-dword uniform pair case (f64_reads_uniform_pairs_at_odd_dwords) passing 4/4 on RTX 5090, AMD RDNA2 iGPU (gfx1036), and WARP.

Blocking issue: dead-code-eliminated f64 instructions fail DXIL validation (Flags must match usage)

crates/victory-shader/src/emit/lower/double.rs eagerly sets flags::DOUBLES (L114, L127, L249) and flags::DOUBLE_EXTENSIONS (L225, L249, L262) during lowering, but Module::uses() (crates/victory-shader/src/emit/bitcode.rs:530-551) and Shader::finish() (crates/victory-shader/src/emit/shader.rs:579-587) were not updated to recompute those two flags from live emitted instructions.

Because makeDouble, splitDouble, fadd, fmul, fma, and double/int casts are pure (Attr::ReadNone), any dead double instruction — an unused destination VGPR, a constant-folded dead branch, or a dead instruction whose write_f64 rejects clamp/omod (double.rs:142) after fsrc64 has already set DOUBLES — is stripped by Module::write(), leaving stale DOUBLES / DOUBLE_EXTENSIONS bits declared. dxil.dll then rejects the entire shader:

  • Dead v_add_f64 (unused destination): error: Flags must match usage. note: Flags declared=1073741828, actual=1073741824
  • Dead v_fma_f64 alongside a live v_add_f64: error: Flags must match usage. note: Flags declared=1074266180, actual=1074266116 (stale DOUBLE_EXTENSIONS)
  • Dead v_add_f64 with clamp=1: error: Flags must match usage. note: Flags declared=1073741828, actual=1073741824
  • Dead v_cvt_i32_f64 / dead v_cvt_f64_i32: error: Flags must match usage. note: Flags declared=1073741892, actual=1073741824

Suggested fix (verified against dxil.dll)

Extend Uses and Module::uses() in crates/victory-shader/src/emit/bitcode.rs to track:

  • doubles: any live instruction whose result type or any operand type is TypeDef::Double
  • double_extensions: any live Op::Call to dx.op.tertiary.f64 with opcode 47 (Fma), or any live Op::Cast(Cast::FpToUi | Cast::FpToSi | Cast::UiToFp | Cast::SiToFp, v) where either inst.ty or self.type_of(*v) is TypeDef::Double

Then reconcile (flags::DOUBLES, uses.doubles) and (flags::DOUBLE_EXTENSIONS, uses.double_extensions) in Shader::finish() (crates/victory-shader/src/emit/shader.rs:579-587) alongside INT64 and WAVE_OPS. Testing this patch locally passes dxil.dll validation on all 5 dead-code cases above, all 11 live double operations, and all 11 PR unit/GPU tests. Adding a validator test for dead f64 / v_fma_f64 instructions would lock this in.

<!-- greyfinch-sync:Marvisak/VIctory:review:6078507194 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#pullrequestreview-6078507194). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T17:39:27Z. **Review:** CHANGES_REQUESTED --- Verified on `main` (`63bcca43`) across three D3D12 adapters (RTX 5090, AMD Ryzen 9 9950X integrated RDNA2 `gfx1036`, and Microsoft WARP) with Windows SDK `dxil.dll`: - `cargo xtask policy` (`192 files ok`; `crates/victory-shader/src/emit/lower.rs` = `521,403` B `< 524,288` B) and `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`) pass. - All 11 new tests (`cvt_f32_f64_*`, `f64_*`, `v_cmp_f64_*`) pass on RTX 5090 and WARP. - Additional probes confirmed true fused `v_fma_f64` rounding, `v_cvt_i32_f64`/`v_cvt_u32_f64` saturation and NaN -> 0 behavior, modifier rejections, and the odd-dword uniform pair case (`f64_reads_uniform_pairs_at_odd_dwords`) passing 4/4 on RTX 5090, AMD RDNA2 iGPU (`gfx1036`), and WARP. ### Blocking issue: dead-code-eliminated `f64` instructions fail DXIL validation (`Flags must match usage`) `crates/victory-shader/src/emit/lower/double.rs` eagerly sets `flags::DOUBLES` (`L114`, `L127`, `L249`) and `flags::DOUBLE_EXTENSIONS` (`L225`, `L249`, `L262`) during lowering, but `Module::uses()` (`crates/victory-shader/src/emit/bitcode.rs:530-551`) and `Shader::finish()` (`crates/victory-shader/src/emit/shader.rs:579-587`) were not updated to recompute those two flags from live emitted instructions. Because `makeDouble`, `splitDouble`, `fadd`, `fmul`, `fma`, and double/int casts are pure (`Attr::ReadNone`), any dead double instruction — an unused destination VGPR, a constant-folded dead branch, or a dead instruction whose `write_f64` rejects `clamp`/`omod` (`double.rs:142`) after `fsrc64` has already set `DOUBLES` — is stripped by `Module::write()`, leaving stale `DOUBLES` / `DOUBLE_EXTENSIONS` bits declared. `dxil.dll` then rejects the entire shader: - Dead `v_add_f64` (unused destination): `error: Flags must match usage. note: Flags declared=1073741828, actual=1073741824` - Dead `v_fma_f64` alongside a live `v_add_f64`: `error: Flags must match usage. note: Flags declared=1074266180, actual=1074266116` (stale `DOUBLE_EXTENSIONS`) - Dead `v_add_f64` with `clamp=1`: `error: Flags must match usage. note: Flags declared=1073741828, actual=1073741824` - Dead `v_cvt_i32_f64` / dead `v_cvt_f64_i32`: `error: Flags must match usage. note: Flags declared=1073741892, actual=1073741824` ### Suggested fix (verified against `dxil.dll`) Extend `Uses` and `Module::uses()` in `crates/victory-shader/src/emit/bitcode.rs` to track: - `doubles`: any live instruction whose result type or any operand type is `TypeDef::Double` - `double_extensions`: any live `Op::Call` to `dx.op.tertiary.f64` with opcode `47` (`Fma`), or any live `Op::Cast(Cast::FpToUi | Cast::FpToSi | Cast::UiToFp | Cast::SiToFp, v)` where either `inst.ty` or `self.type_of(*v)` is `TypeDef::Double` Then reconcile `(flags::DOUBLES, uses.doubles)` and `(flags::DOUBLE_EXTENSIONS, uses.double_extensions)` in `Shader::finish()` (`crates/victory-shader/src/emit/shader.rs:579-587`) alongside `INT64` and `WAVE_OPS`. Testing this patch locally passes `dxil.dll` validation on all 5 dead-code cases above, all 11 live double operations, and all 11 PR unit/GPU tests. Adding a validator test for dead `f64` / `v_fma_f64` instructions would lock this in.
bvtterbroot commented 2026-11-26 18:37:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bvtterbroot on 2026-11-26T18:37:38Z.


The workaround on RDNA3, which wasn't tested yet: faf20ac passes on an RX 7900 XTX, and again on the gfx1036 iGPU.

  • Windows 11, Rust 1.98.1. Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010) and the Ryzen 7 7800X3D's iGPU (RDNA2, gfx1036, driver 32.0.21045.29003). I picked each as the hardware adapter with a local patch. WARP runs in each pass as well.
  • cargo test -p victory-shader --lib f64_: 12 passed, 0 failed, on both GPUs. That includes f64_reads_uniform_pairs_at_odd_dwords. I also ran my seven cases from above (v[2:3] + 1.0, v[2:3] + v[2:3], v[2:3] + v[3:4], v[1:2] * v[2:3] and the three aligned controls). All of them now give the expected words on both GPUs and on WARP. Before c4da80b, the four odd-dword cases were wrong on both.
  • cargo test -p victory-shader --lib: 314 passed, 0 failed, 3 ignored, on both GPUs.

So the opaque zero (WaveGetLaneIndex() >> 31) holds on RDNA2 (6950 XT, gfx1036) and on RDNA3. Like you, I only tested uniform inputs.

Synthetic tests only, no game files. Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7200675205 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7200675205). Originally posted by [bvtterbroot](https://github.com/bvtterbroot) on 2026-11-26T18:37:38Z. --- The workaround on RDNA3, which wasn't tested yet: **`faf20ac` passes on an RX 7900 XTX**, and again on the gfx1036 iGPU. - Windows 11, Rust 1.98.1. Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010) and the Ryzen 7 7800X3D's iGPU (RDNA2, gfx1036, driver 32.0.21045.29003). I picked each as the hardware adapter with a local patch. WARP runs in each pass as well. - `cargo test -p victory-shader --lib f64_`: 12 passed, 0 failed, on both GPUs. That includes `f64_reads_uniform_pairs_at_odd_dwords`. I also ran my seven cases from above (`v[2:3] + 1.0`, `v[2:3] + v[2:3]`, `v[2:3] + v[3:4]`, `v[1:2] * v[2:3]` and the three aligned controls). All of them now give the expected words on both GPUs and on WARP. Before `c4da80b`, the four odd-dword cases were wrong on both. - `cargo test -p victory-shader --lib`: 314 passed, 0 failed, 3 ignored, on both GPUs. So the opaque zero (`WaveGetLaneIndex() >> 31`) holds on RDNA2 (6950 XT, gfx1036) and on RDNA3. Like you, I only tested uniform inputs. Synthetic tests only, no game files. _Tested with AI assistance (Claude Code)._
ColorMeBoom commented 2026-11-26 19:12:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-26T19:12:12Z.


RDNA1 hardware verification — RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200, SDK dxil.dll 1.9.2602.17. Synthetic tests only, no game data.

  • Head faf20ac: all 11 f64 tests pass on the RX 5700 XT and WARP.
  • Control: c4da80b's lowering reverted, valu_tests.rs kept from head. f64_reads_uniform_pairs_at_odd_dwords fails on hardware only: 46 wrong results across 13 forms, every one with a double at an odd dword (v[2:3]), read with its low dword as both halves (input 0: v_add_f64 v[6:7], v[2:3], 1.0 = 0x4004000000000000, want 0x400800003ff80000). Even-aligned v[1:2], v[3:4] and the b64 integer cases are right; WARP is right throughout.

So FIND-21 also affects RDNA1, and the opaque-zero workaround fixes it there.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7201307236 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7201307236). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-26T19:12:12Z. --- **RDNA1 hardware verification** — RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200, SDK dxil.dll 1.9.2602.17. Synthetic tests only, no game data. - Head `faf20ac`: all 11 f64 tests pass on the RX 5700 XT and WARP. - Control: `c4da80b`'s lowering reverted, `valu_tests.rs` kept from head. `f64_reads_uniform_pairs_at_odd_dwords` fails on hardware only: 46 wrong results across 13 forms, every one with a double at an odd dword (`v[2:3]`), read with its low dword as both halves (input 0: `v_add_f64 v[6:7], v[2:3], 1.0` = `0x4004000000000000`, want `0x400800003ff80000`). Even-aligned `v[1:2], v[3:4]` and the b64 integer cases are right; WARP is right throughout. So FIND-21 also affects RDNA1, and the opaque-zero workaround fixes it there. AI use: Claude Code (Claude Opus 5.5).
JoeY54 commented 2026-11-27 07:27:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by JoeY54 on 2026-11-27T07:27:33Z.


FIND-21 hardware verification (VT-01) on PR head faf20acb63905f22bbe41065292b667ddb03dde1.

  • Native Windows D3D12, AMD Radeon 860M Graphics (driver 32.0.32029.2010) and Microsoft WARP.
  • f64_reads_uniform_pairs_at_odd_dwords passed (1 passed, 0 failed). Both backends ran.
  • Built in release mode with Rust 1.98.1 (x86_64-pc-windows-gnu). A temporary test-harness change selected and logged the AMD adapter.

This run covers the patched revision using synthetic inputs only. AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212491117 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7212491117). Originally posted by [JoeY54](https://github.com/JoeY54) on 2026-11-27T07:27:33Z. --- FIND-21 hardware verification (VT-01) on PR head `faf20acb63905f22bbe41065292b667ddb03dde1`. - Native Windows D3D12, AMD Radeon 860M Graphics (driver `32.0.32029.2010`) and Microsoft WARP. - `f64_reads_uniform_pairs_at_odd_dwords` passed (1 passed, 0 failed). Both backends ran. - Built in release mode with Rust 1.98.1 (`x86_64-pc-windows-gnu`). A temporary test-harness change selected and logged the AMD adapter. This run covers the patched revision using synthetic inputs only. AI-assisted verification.
kilolimaVI commented 2026-11-29 13:13:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T13:13:28Z.


AMD row: Radeon 780M (RDNA3, driver 32.0.13022.3006, Windows 11), head faf20ac.

  • cvt_f32_f64_* (4 tests): pass on hardware
  • f64 add/mul/fma, min/max, modifiers, SGPR pairs, v_cmp_f64, conversions (11 tests matching f64_ / v_cmp_f64): pass

Per fiestorra's census on #201, v_cvt_f32_f64 is 5 of the remaining translation refusals on main.

It also fits with the other pending shader PRs: kilolimaVI/VIctory integration/shader-9 (250bd96) = main + #3097, #2999, #3617, #3717, #1315, #3716, #2398, #385 and this. One trivial conflict at the top of lower.rs (#3716's force_unnormalized and this PR's mod double;, both kept). lower.rs 474,466 bytes. On that tree: victory-shader lib 350 passed / 0 failed / 3 ignored, victory-gpu (diagnostics) 246 passed, rest of the workspace passes, both clippy configurations and the asset policy pass.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7256379142 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7256379142). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-29T13:13:28Z. --- AMD row: Radeon 780M (RDNA3, driver 32.0.13022.3006, Windows 11), head `faf20ac`. - `cvt_f32_f64_*` (4 tests): pass on hardware - f64 add/mul/fma, min/max, modifiers, SGPR pairs, `v_cmp_f64`, conversions (11 tests matching `f64_` / `v_cmp_f64`): pass Per fiestorra's census on #201, `v_cvt_f32_f64` is 5 of the remaining translation refusals on main. It also fits with the other pending shader PRs: `kilolimaVI/VIctory` `integration/shader-9` (`250bd96`) = main + #3097, #2999, #3617, #3717, #1315, #3716, #2398, #385 and this. One trivial conflict at the top of `lower.rs` (#3716's `force_unnormalized` and this PR's `mod double;`, both kept). `lower.rs` 474,466 bytes. On that tree: victory-shader lib 350 passed / 0 failed / 3 ignored, victory-gpu (diagnostics) 246 passed, rest of the workspace passes, both clippy configurations and the asset policy pass. AI-assisted (Claude).
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/1262:upstream-pr/1262'
git switch 'upstream-pr/1262'

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/1262'
git switch 'upstream-pr/1262'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1262'
git switch 'upstream-pr/1262'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1262'
git switch 'main'
git merge --squash 'upstream-pr/1262'
git switch 'main'
git merge --ff-only 'upstream-pr/1262'
git switch 'main'
git merge 'upstream-pr/1262'
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
Marvisak/VIctory!1262
No description provided.