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

Open
github-bot wants to merge 5 commits from github-bot/gh-1262 into main AGit
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 16:54 UTC · original
MamaLeVrai:f64-alu → main · +901 −7 · 5 files · 5 commits · open

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

**@⁠MamaLeVrai** on GitHub · 2026-11-24 16:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262) `MamaLeVrai:f64-alu` → `main` · +901 −7 · 5 files · 5 commits · open 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)
Builds on the double type and makeDouble of #416 (v_cvt_f32_f64), which
this commit includes below it. A double is a VGPR or SGPR pair; DXIL has
fadd, fmul, fma, fmax and fmin for it.

Lowered: v_add_f64, v_mul_f64, v_fma_f64, v_max_f64, v_min_f64, every
v_cmp_*_f64 and v_cmpx_*_f64 except class, v_cvt_f64_f32, v_cvt_f64_i32,
v_cvt_f64_u32, v_cvt_i32_f64 and v_cvt_u32_f64. Sources take the abs and
neg modifiers on the sign bit, inline float constants, literals (the high
dword) and SGPR pairs; output modifiers on a double result are refused.

fma and the double/integer conversions are D3D11.1 double extensions, so
they set the new DOUBLE_EXTENSIONS flag (ShaderFlags bit 6, SFI0 0x20),
which the validator checks. Of two zeros, min and max follow the f32 rule.
A constant v_cmp_f/v_cmp_tru builds no doubles: WARP loses the device on a
double `fcmp false`.

The new code is in emit/lower/double.rs; #416's double_src there becomes
fsrc64 (any source, not only the first).

Tests (valu_tests.rs) run each instruction on the host GPU and WARP and
compare with Rust's f64: IEEE results with NaN, infinities, zeros and
overflow, min/max zero order, abs/neg, SGPR pairs, all 16 compare
predicates, and saturating conversions. Checked on an RX 6950 XT: clippy
(both CI runs) is clean and cargo test --workspace passes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
valu_tests.rs: both sides append tests at two places, each ending in the same closing lines;
both kept.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
On AMD's D3D12 compiler (RX 6950 XT, driver 32.0.21045.29003; also
reported on RDNA3 and a gfx1036 iGPU), a double built from dwords 1 and 2
of one uniform 4-dword load (the root constants here) reads its low dword
as both halves, alone or when two sources share a dword. WARP and NVIDIA
are right.

Each dword of a register-pair f64 source is now XORed with the lane index
shifted right by 31, a zero the compiler cannot fold. With it the doubles
come out right on the RX 6950 XT and WARP. Inline constants and literals
are unchanged. Cost: one lane index and one shift per program, one XOR
per dword of a register-pair source.

New test f64_reads_uniform_pairs_at_odd_dwords, 4 inputs: add, mul, fma,
max, min, cvt_f32/i32/u32_f64 and two compares on v[2:3] and on sources
sharing a dword; a disjoint-pair add and v_cvt_f64_f32 as controls; and
64-bit integer shifts and v_mad_u64_u32 on v[2:3], which were right on
AMD without the change. Without the lowering change it fails with 45
wrong hardware results (WARP none); with it, it passes on both backends.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:25:32 +00:00
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 17:03 UTC · original

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.

**@⁠pablogonz12** on GitHub · 2026-11-24 17:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7138614312) 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.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 19:51 UTC · original

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.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 19:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7142686850) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:20 UTC · original · edited 2026-11-26 01:23 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7149446558) · edited 2026-11-26 01:23 UTC <!-- 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)_
Author
Owner

@⁠astrosteveo on GitHub · 2026-11-25 05:43 UTC · original

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]>

**@⁠astrosteveo** on GitHub · 2026-11-25 05:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7154085580) 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>
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 06:03 UTC · original

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.

**@⁠Dathinel** on GitHub · 2026-11-25 06:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7154398746) 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.
Author
Owner

@⁠bvtterbroot on GitHub · 2026-11-25 19:54 UTC · original

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

**@⁠bvtterbroot** on GitHub · 2026-11-25 19:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7172918903) 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)._
Author
Owner

@⁠bvtterbroot on GitHub · 2026-11-25 20:11 UTC · original

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

**@⁠bvtterbroot** on GitHub · 2026-11-25 20:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7173308799) 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)._
Author
Owner

@⁠JoeY54 on GitHub · 2026-11-25 21:39 UTC · original

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

**@⁠JoeY54** on GitHub · 2026-11-25 21:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7175377173) 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).
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 00:16 UTC · original

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** on GitHub · 2026-11-26 00:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7178578496) 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.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 00:26 UTC · original

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.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 00:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7178751670) 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.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 01:58 UTC · original

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.

**@⁠steven-seagull27** on GitHub · 2026-11-26 01:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#issuecomment-7180339099) 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.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-24 16:54 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-24 16:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#pullrequestreview-6043667790) · **reviewed** 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.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 17:06 UTC · original · approved these changes

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.

**@⁠catminou4** on GitHub · 2026-11-24 17:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#pullrequestreview-6043854409) · **approved these changes** 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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 17:39 UTC · original · requested changes

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 17:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1262#pullrequestreview-6078507194) · **requested changes** 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.
This pull request can be merged automatically.
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/1262/head:github-bot/gh-1262'
git switch 'github-bot/gh-1262'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1262'
git switch 'github-bot/gh-1262'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1262'
git switch 'github-bot/gh-1262'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1262'
git switch 'main'
git merge --squash 'github-bot/gh-1262'
git switch 'main'
git merge --ff-only 'github-bot/gh-1262'
git switch 'main'
git merge 'github-bot/gh-1262'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1262
No description provided.