Shaders: lower v_dot2_f32_f16 and v_dot2c_f32_f16 #465

Open
github-bot wants to merge 4 commits from github-bot/gh-465 into main AGit
Owner

@⁠Baconzido on GitHub · 2026-11-24 03:45 UTC · original
Baconzido:shaders/v-dot2-f32-f16 → main · +324 −0 · 3 files · 4 commits · open

Two VALU instructions the translator refused (Unsupported { what: "v_dot2_f32_f16" }), so any shader using one dropped its draws or dispatches:

  • v_dot2_f32_f16 (VOP3P): S0.f16[0] * S1.f16[0] + S0.f16[1] * S1.f16[1] + S2.f32, with op_sel/op_sel_hi choosing each source's half per product, neg_lo/neg_hi negating them (neg_lo bit 2 negates the f32 addend) and clamp saturating the result;
  • v_dot2c_f32_f16 (VOP2): the same sum with the destination as the addend, read like v_fmac_f32 reads its accumulator.

Each f16 goes through legacyF16ToF32 as packed16 does, so the halves and their products are exact in f32 (65504 * 65504 does not overflow as it would in f16). The two products and the addend are summed with one rounding, as RDNA2 does (measured on gfx1036 in this PR's comments): Boldo and Melquiond's correctly rounded sum of three, two TwoSums whose errors are added with rounding to odd, then one rounded add. Shortcut, noted in the code: f32 denormals along the way follow the shader's denormal mode. Modifiers the lowering does not model (neg_hi bit 2, SDWA, VOP3-encoded v_dot2c with abs/neg/op_sel, omod) are refused.

This complements #157, which lowers the integer dot products (v_dot2_i32_i16 … v_dot8_u32_u4); there is no overlap.

Tests (new, in emit/valu_tests.rs, all failing before this change with the Unsupported above):

  • v_dot2_f32_f16_sums_f16_products_in_f32: exact cases, mixed signs, 65504², infinity;
  • v_dot2_f32_f16_applies_op_sel_and_negation_per_half: swapped halves of src0 and negation on both halves;
  • v_dot2_f32_f16_clamps_to_zero_one;
  • v_dot2c_f32_f16_accumulates_into_its_destination;
  • v_dot2_f32_f16_rounds_the_exact_sum_once and v_dot2c_f32_f16_rounds_the_exact_sum_once: sums where rounding the products' sum first gives another f32 (these fail with a two-rounding sum).

Expected values come from an independent model of the ISA definition, not from the lowering.

Run on Windows 11 (26300), both backends of run_cases: AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, with dxil.dll from SDK 10.0.26100 validating every shader: 6/6 pass, on main ffe310e. cargo test --workspace: 348 passed, 1 failed (victory-hle display::sdr_and_display_deferrals, which also fails on main here because the run is over SSH with no desktop). cargo clippy -p victory-shader --all-targets is clean; cargo fmt adds nothing in the changed lines; cargo xtask policy --staged: ok.

AI-assisted (Claude Code wrote the lowering and tests and ran them over SSH); every run is on my machine. No game files.

**@⁠Baconzido** on GitHub · 2026-11-24 03:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/465) `Baconzido:shaders/v-dot2-f32-f16` → `main` · +324 −0 · 3 files · 4 commits · open Two VALU instructions the translator refused (`Unsupported { what: "v_dot2_f32_f16" }`), so any shader using one dropped its draws or dispatches: - `v_dot2_f32_f16` (VOP3P): `S0.f16[0] * S1.f16[0] + S0.f16[1] * S1.f16[1] + S2.f32`, with `op_sel`/`op_sel_hi` choosing each source's half per product, `neg_lo`/`neg_hi` negating them (`neg_lo` bit 2 negates the f32 addend) and `clamp` saturating the result; - `v_dot2c_f32_f16` (VOP2): the same sum with the destination as the addend, read like `v_fmac_f32` reads its accumulator. Each f16 goes through `legacyF16ToF32` as `packed16` does, so the halves and their products are exact in f32 (65504 * 65504 does not overflow as it would in f16). The two products and the addend are summed with one rounding, as RDNA2 does (measured on gfx1036 in this PR's comments): Boldo and Melquiond's correctly rounded sum of three, two TwoSums whose errors are added with rounding to odd, then one rounded add. Shortcut, noted in the code: f32 denormals along the way follow the shader's denormal mode. Modifiers the lowering does not model (`neg_hi` bit 2, SDWA, VOP3-encoded `v_dot2c` with abs/neg/op_sel, omod) are refused. This complements #157, which lowers the integer dot products (`v_dot2_i32_i16` … `v_dot8_u32_u4`); there is no overlap. Tests (new, in `emit/valu_tests.rs`, all failing before this change with the `Unsupported` above): - `v_dot2_f32_f16_sums_f16_products_in_f32`: exact cases, mixed signs, 65504², infinity; - `v_dot2_f32_f16_applies_op_sel_and_negation_per_half`: swapped halves of src0 and negation on both halves; - `v_dot2_f32_f16_clamps_to_zero_one`; - `v_dot2c_f32_f16_accumulates_into_its_destination`; - `v_dot2_f32_f16_rounds_the_exact_sum_once` and `v_dot2c_f32_f16_rounds_the_exact_sum_once`: sums where rounding the products' sum first gives another f32 (these fail with a two-rounding sum). Expected values come from an independent model of the ISA definition, not from the lowering. Run on Windows 11 (26300), both backends of `run_cases`: AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, with `dxil.dll` from SDK 10.0.26100 validating every shader: 6/6 pass, on `main` `ffe310e`. `cargo test --workspace`: 348 passed, 1 failed (`victory-hle` `display::sdr_and_display_deferrals`, which also fails on `main` here because the run is over SSH with no desktop). `cargo clippy -p victory-shader --all-targets` is clean; `cargo fmt` adds nothing in the changed lines; `cargo xtask policy --staged`: ok. AI-assisted (Claude Code wrote the lowering and tests and ran them over SSH); every run is on my machine. No game files.
The two products of f16 halves, exact in f32, summed with the f32 addend (v_dot2c: the destination). VOP3P op_sel/op_sel_hi pick each half, neg_lo/neg_hi negate them and clamp saturates; modifiers not modelled are refused. Tests run each case on the host GPU and WARP.
RDNA2 rounds the exact sum of the two f16 products and the f32 addend
once (measured on gfx1036 in #465), where summing the products first
rounds twice: (1, 2^-12) . (1, 2^-12) - 1 gives 2^-24 on the hardware
and 0 that way.

The sum is now Boldo and Melquiond's correctly rounded sum of three:
two TwoSums, their errors added with rounding to odd, then one final
rounded add. A zero tail keeps the sign of an all-negative-zero sum,
and an infinite or NaN term gives the plain sum.
lower.rs is close to the policy's 512 KiB file limit, and the dot2
lowering with its sum-of-three helpers took it past. Move them to a
submodule, as lower/bvh.rs does; valu_op keeps a one-line arm. No
behavior change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:05:02 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 03:51 UTC · original

Verified aa55c55 on Arch Linux x86_64 (rustc 1.98.1, cargo test -p victory-shader): 56 passed, 0 failed, 0 ignored.

Not covered: the dot products executed on a real GPU (no SM 6.6 device here) and title shaders (no game data).

**@⁠DaviTostes** on GitHub · 2026-11-24 03:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7121479993) Verified `aa55c55` on **Arch Linux x86_64** (rustc 1.98.1, `cargo test -p victory-shader`): **56 passed, 0 failed, 0 ignored**. Not covered: the dot products executed on a real GPU (no SM 6.6 device here) and title shaders (no game data).
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 05:15 UTC · original

Ran 1d20123 merged onto main d2a4bae (clean) on NVIDIA. valu_tests runs each case on the hardware device and on WARP.

  • NVIDIA GeForce RTX 5070 12 GB (32-lane waves), driver 621.24; Windows 11 Pro 26300; Rust 1.98.1 (pinned) x86_64-pc-windows-msvc, debug
  • the four new tests (v_dot2_f32_f16_sums_f16_products_in_f32, …_applies_op_sel_and_negation_per_half, …_clamps_to_zero_one, v_dot2c_f32_f16_accumulates_into_its_destination): ok on both
  • cargo test -p victory-shader --lib -- --test-threads=1: 73 passed, 0 failed
  • cargo test --workspace -- --test-threads=1: 268 passed, 0 failed, 4 ignored
**@⁠marquezinii** on GitHub · 2026-11-24 05:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7122783365) Ran `1d20123` merged onto `main` `d2a4bae` (clean) on NVIDIA. `valu_tests` runs each case on the hardware device and on WARP. - NVIDIA GeForce RTX 5070 12 GB (32-lane waves), driver 621.24; Windows 11 Pro 26300; Rust 1.98.1 (pinned) `x86_64-pc-windows-msvc`, debug - the four new tests (`v_dot2_f32_f16_sums_f16_products_in_f32`, `…_applies_op_sel_and_negation_per_half`, `…_clamps_to_zero_one`, `v_dot2c_f32_f16_accumulates_into_its_destination`): ok on both - `cargo test -p victory-shader --lib -- --test-threads=1`: 73 passed, 0 failed - `cargo test --workspace -- --test-threads=1`: 268 passed, 0 failed, 4 ignored
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 06:22 UTC · original

RDNA2 hardware measurement of the shortcut:: the hardware rounds once. v_dot2_f32_f16 and v_dot2c_f32_f16 are fused, so the two-rounding sum is not what RDNA2 does.

Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 404 operand sets: 400 random halves in ±4 with an f32 addend chosen close to minus the dot product (so the final rounding is sensitive), plus four built cases. v_dot2c_f32_f16 takes the addend from the destination.

Model v_dot2_f32_f16 v_dot2c_f32_f16
one rounding of a0*b0 + a1*b1 + c (exact) 404/404 404/404
(a0*b0 + a1*b1) rounded, then + c (this PR's order) 353/404 353/404
(a0*b0 + c) rounded, then + a1*b1 336/404 336/404
a0*b0 + (a1*b1 + c) rounded 328/404 328/404

For example, halves 1.0 · 1.0 + 2^-12 · 2^-12 with c = -1.0 gives 0x33800000 (2^-24) on the hardware. Summing the products first rounds 1 + 2^-24 to 1.0 and gives 0.

The products of two halves are exact in f32, as you note, so the hardware result is those three exact terms rounded once. Matching it needs the sum formed without an intermediate rounding before the final one, for example an error-free TwoSum on the f32 terms. A plain f64 sum is not always enough when the terms' exponents are far apart.

AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.

**@⁠Lyrnc** on GitHub · 2026-11-24 06:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7123868450) RDNA2 hardware measurement of the `shortcut:`: **the hardware rounds once.** `v_dot2_f32_f16` and `v_dot2c_f32_f16` are fused, so the two-rounding sum is not what RDNA2 does. **Setup.** AMD Radeon iGPU of a Ryzen 7 9800X3D, **gfx1036 (RDNA2)**, AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 404 operand sets: 400 random halves in ±4 with an f32 addend chosen close to minus the dot product (so the final rounding is sensitive), plus four built cases. `v_dot2c_f32_f16` takes the addend from the destination. | Model | `v_dot2_f32_f16` | `v_dot2c_f32_f16` | |---|---|---| | **one rounding** of `a0*b0 + a1*b1 + c` (exact) | **404/404** | **404/404** | | `(a0*b0 + a1*b1)` rounded, then `+ c` (this PR's order) | 353/404 | 353/404 | | `(a0*b0 + c)` rounded, then `+ a1*b1` | 336/404 | 336/404 | | `a0*b0 + (a1*b1 + c)` rounded | 328/404 | 328/404 | For example, halves `1.0 · 1.0 + 2^-12 · 2^-12` with `c = -1.0` gives `0x33800000` (2^-24) on the hardware. Summing the products first rounds `1 + 2^-24` to 1.0 and gives 0. The products of two halves are exact in f32, as you note, so the hardware result is those three exact terms rounded once. Matching it needs the sum formed without an intermediate rounding before the final one, for example an error-free TwoSum on the f32 terms. A plain f64 sum is not always enough when the terms' exponents are far apart. AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:16 UTC · original

AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of run_cases (local adapter-selection patch, not part of this PR); cargo test -p victory-shader --release valu_tests at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept.

  • With this PR, all four v_dot2* tests pass on both AMD GPUs.
  • Negative control: all four fail on both GPUs without the fix, so the tests do catch the change on AMD hardware.
**@⁠slint6614-dev** on GitHub · 2026-11-24 10:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7128559380) AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of `run_cases` (local adapter-selection patch, not part of this PR); `cargo test -p victory-shader --release valu_tests` at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept. - With this PR, all four `v_dot2*` tests pass on both AMD GPUs. - Negative control: all four fail on both GPUs without the fix, so the tests do catch the change on AMD hardware.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:42 UTC · original

Corpus run note: merged locally with current main (c7a5f49), this PR no longer compiles:

error[E0061]: this method takes 4 arguments but 3 arguments were supplied
    --> crates\victory-shader\src\emit\lower.rs:3817:34
3817 |   self.packed_src(inst, k, high)?
     |        ^^^^^^^^^^---------------- argument #4 of type `bool` is missing

packed_src gained a fourth argument on main, so this PR needs a rebase. At its own head it builds, and its GPU tests pass on AMD (see my earlier comment).

**@⁠slint6614-dev** on GitHub · 2026-11-24 10:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7129136024) Corpus run note: merged locally with current main (c7a5f49), this PR no longer compiles: ``` error[E0061]: this method takes 4 arguments but 3 arguments were supplied --> crates\victory-shader\src\emit\lower.rs:3817:34 3817 | self.packed_src(inst, k, high)? | ^^^^^^^^^^---------------- argument #4 of type `bool` is missing ``` `packed_src` gained a fourth argument on main, so this PR needs a rebase. At its own head it builds, and its GPU tests pass on AMD (see my earlier comment).
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 10:46 UTC · original

Following up on the gfx1036 single-rounding measurement: on an RTX 4090 under Wine/vkd3d-proton, DXIL Dot2AddHalf returned 0x00000000 for the cancellation example above. It also returned 0x4b800000 for packed operands a=b=0x00013c00, addend 0x4b800000; rounding the exact sum once gives 0x4b800001. Both results repeated on vkd3d-proton 3.1 and 3.2.

We compared 1,026 deliberately rounding-sensitive finite inputs against an exact rational reference. With DXC denormal preservation enabled, the direct intrinsic matched 142. A separate compensated FP32 test shader matched all 1,026 on both backends. Without explicit denormal preservation, that same compensated shader matched 770; all 256 misses were subnormal results after cancellation.

These counts describe this constructed test set. The compensated shader is an experimental reference. Guest denormal mode, NaNs, infinities, and rendering cost remain open before adopting a lowering. No title shaders were used.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 10:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7129227520) Following up on the gfx1036 single-rounding measurement: on an RTX 4090 under Wine/vkd3d-proton, DXIL `Dot2AddHalf` returned `0x00000000` for the cancellation example above. It also returned `0x4b800000` for packed operands `a=b=0x00013c00`, addend `0x4b800000`; rounding the exact sum once gives `0x4b800001`. Both results repeated on vkd3d-proton 3.1 and 3.2. We compared 1,026 deliberately rounding-sensitive finite inputs against an exact rational reference. With DXC denormal preservation enabled, the direct intrinsic matched 142. A separate compensated FP32 test shader matched all 1,026 on both backends. Without explicit denormal preservation, that same compensated shader matched 770; all 256 misses were subnormal results after cancellation. These counts describe this constructed test set. The compensated shader is an experimental reference. Guest denormal mode, NaNs, infinities, and rendering cost remain open before adopting a lowering. No title shaders were used.
Author
Owner

@⁠Baconzido on GitHub · 2026-11-24 12:41 UTC · original

Thanks for the measurements. Both points are addressed, and the branch is rebased on main ffe310e.

Rounding (@⁠Lyrnc, @⁠MichaelSmithAI). 2b0d00b sums the two products and the addend with a single rounding, using Boldo and Melquiond's correctly rounded sum of three: two TwoSums, their errors added with rounding to odd, then one rounded add. A zero tail keeps the sign of an all-negative-zero sum, and an infinite or NaN term falls back to the plain sum. The shortcut: comment is gone. One limit is written down instead: f32 denormals along the way follow the shader's denormal mode, which the translator doesn't set (the subnormal misses @⁠MichaelSmithAI saw).

New tests, v_dot2_f32_f16_rounds_the_exact_sum_once and v_dot2c_f32_f16_rounds_the_exact_sum_once:

  • (1, 2^-12) . (1, 2^-12) - 1 → 0x33800000, the gfx1036 result above;
  • (1, 2^-14) . (1, 2^-14) + 2^24 → 0x4b800001, the tie case (a normal-half variant of 0x00013c00), which needs the round-to-odd step;
  • (-0, -0) . (1, 1) - 0 → -0.

Rebase (@⁠slint6614-dev). packed_src now takes float = true, so inline constants read as halves, as in packed16.

Tested on Windows 11, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, dxil.dll from SDK 10.0.26100, Rust 1.98.1:

Result
new tests with the old lowering (e1da143's lower.rs) fail on the hardware device: 0x00000000, want 0x33800000
cargo test -p victory-shader --lib dot2 6 passed, hardware and WARP
cargo test -p victory-shader 126 passed, 0 failed, 1 ignored
cargo test --workspace --no-fail-fast 348 passed; 1 failed: victory-hle display::sdr_and_display_deferrals, which opens a window; it failed the same way over SSH on main d2a4bae
cargo clippy -p victory-shader --all-targets clean

I also checked the algorithm against an exact rational reference with subnormals kept: 40,000 random cases, 40% of them cancellations, all match. No game data used.

AI use: Claude Code (Claude Opus 5.5) wrote the change, the tests and this comment; I ran the tests on the hardware above.

**@⁠Baconzido** on GitHub · 2026-11-24 12:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7131778673) Thanks for the measurements. Both points are addressed, and the branch is rebased on `main` `ffe310e`. **Rounding (@⁠Lyrnc, @⁠MichaelSmithAI).** `2b0d00b` sums the two products and the addend with a single rounding, using Boldo and Melquiond's correctly rounded sum of three: two TwoSums, their errors added with rounding to odd, then one rounded add. A zero tail keeps the sign of an all-negative-zero sum, and an infinite or NaN term falls back to the plain sum. The `shortcut:` comment is gone. One limit is written down instead: f32 denormals along the way follow the shader's denormal mode, which the translator doesn't set (the subnormal misses @⁠MichaelSmithAI saw). New tests, `v_dot2_f32_f16_rounds_the_exact_sum_once` and `v_dot2c_f32_f16_rounds_the_exact_sum_once`: - `(1, 2^-12) . (1, 2^-12) - 1` → `0x33800000`, the gfx1036 result above; - `(1, 2^-14) . (1, 2^-14) + 2^24` → `0x4b800001`, the tie case (a normal-half variant of `0x00013c00`), which needs the round-to-odd step; - `(-0, -0) . (1, 1) - 0` → `-0`. **Rebase (@⁠slint6614-dev).** `packed_src` now takes `float = true`, so inline constants read as halves, as in `packed16`. Tested on Windows 11, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, `dxil.dll` from SDK 10.0.26100, Rust 1.98.1: | | Result | |---|---| | new tests with the old lowering (`e1da143`'s `lower.rs`) | fail on the hardware device: `0x00000000`, want `0x33800000` | | `cargo test -p victory-shader --lib dot2` | 6 passed, hardware and WARP | | `cargo test -p victory-shader` | 126 passed, 0 failed, 1 ignored | | `cargo test --workspace --no-fail-fast` | 348 passed; 1 failed: `victory-hle` `display::sdr_and_display_deferrals`, which opens a window; it failed the same way over SSH on `main` `d2a4bae` | | `cargo clippy -p victory-shader --all-targets` | clean | I also checked the algorithm against an exact rational reference with subnormals kept: 40,000 random cases, 40% of them cancellations, all match. No game data used. AI use: Claude Code (Claude Opus 5.5) wrote the change, the tests and this comment; I ran the tests on the hardware above.
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 15:23 UTC · original

Re-checked 2b0d00b against the hardware, using the same encodings on both sides:

  • Hardware: Radeon iGPU (Ryzen 7 9800X3D), gfx1036 / RDNA2, driver 32.0.21042.62. I ran v_dot2_f32_f16 (VOP3P, default op_sel_hi) and v_dot2c_f32_f16 (VOP2) on 554 inputs:
    • your three cases: 0x33800000, the 0x4b800001 tie, and -0, which the hardware gives exactly;
    • 400 random cancellations where c ≈ -(a·b);
    • 150 combinations of half edges (±0, ±inf, NaN, denormals, max) with f32 addends (±0, ±inf, NaN, a denormal, 2^24).
  • Translator: the same words through build_valu_cs, on the RTX 5080 (610.88) and on the same Radeon iGPU (#94's VICTORY_ADAPTER).
Host v_dot2_f32_f16 v_dot2c_f32_f16
Radeon gfx1036 506 exact, 48 NaN payload, 0 other 506 exact, 48 NaN payload, 0 other
RTX 5080 446 exact, 108 NaN payload, 0 other 446 exact, 108 NaN payload, 0 other

The single rounding matches the hardware on every non-NaN result. That includes the cancellations, which an earlier head got wrong. The only differences are which NaN comes back. This run used the shader's default denormal mode, so it doesn't speak to the denormal limit you wrote down. No game data.

AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them; the numbers are from those runs.

**@⁠Lyrnc** on GitHub · 2026-11-24 15:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7135942127) Re-checked `2b0d00b` against the hardware, using the same encodings on both sides: - **Hardware:** Radeon iGPU (Ryzen 7 9800X3D), gfx1036 / RDNA2, driver 32.0.21042.62. I ran `v_dot2_f32_f16` (VOP3P, default `op_sel_hi`) and `v_dot2c_f32_f16` (VOP2) on 554 inputs: - your three cases: `0x33800000`, the `0x4b800001` tie, and `-0`, which the hardware gives exactly; - 400 random cancellations where `c ≈ -(a·b)`; - 150 combinations of half edges (±0, ±inf, NaN, denormals, max) with f32 addends (±0, ±inf, NaN, a denormal, `2^24`). - **Translator:** the same words through `build_valu_cs`, on the RTX 5080 (610.88) and on the same Radeon iGPU (#94's `VICTORY_ADAPTER`). | Host | `v_dot2_f32_f16` | `v_dot2c_f32_f16` | |---|---|---| | Radeon gfx1036 | 506 exact, 48 NaN payload, **0** other | 506 exact, 48 NaN payload, **0** other | | RTX 5080 | 446 exact, 108 NaN payload, **0** other | 446 exact, 108 NaN payload, **0** other | The single rounding matches the hardware on every non-NaN result. That includes the cancellations, which an earlier head got wrong. The only differences are which NaN comes back. This run used the shader's default denormal mode, so it doesn't speak to the denormal limit you wrote down. No game data. AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them; the numbers are from those runs.
Author
Owner

@⁠Baconzido on GitHub · 2026-11-24 22:16 UTC · original · edited 2026-11-24 23:29 UTC

Rebased on main 70564ae. The conflicts were only in placement: main's new narrow16 and the upscaler dot-product tests landed where this PR adds its helpers and tests, so both sides are kept. Against main the diff is additions only. The one other change is the wording of the denormal limit, which now follows main's convention: f32 denormals inside the sum follow the host's mode, not the console's, which reads them as zero (ftz). No behavior change.

Re-run on Windows 11, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, dxil.dll from SDK 10.0.26100, Rust 1.98.1, head bdced0f:

Result
cargo test -p victory-shader --lib dot2 6 passed, hardware and WARP
cargo test -p victory-shader 214 passed, 1 failed, 2 ignored
cargo test --workspace --no-fail-fast 480 passed, 2 failed, 7 ignored
cargo clippy -p victory-shader --all-targets clean

Neither failure comes from this branch:

  • victory-hle display::sdr_and_display_deferrals opens a window and fails over SSH, as before.
  • fspx_programs_run_with_the_hardwares_dot_products fails the same way on plain main 70564ae, on the RX 5700 device only: the first case ([cc164000, 1c0e0501]) gives 0x80007FF5, want 0x7FFFFBF5. The RX 5700 is RDNA1, so this is likely how its driver handles dot4AddPacked, not the lowering.
**@⁠Baconzido** on GitHub · 2026-11-24 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7146035302) · edited 2026-11-24 23:29 UTC Rebased on `main` `70564ae`. The conflicts were only in placement: main's new `narrow16` and the upscaler dot-product tests landed where this PR adds its helpers and tests, so both sides are kept. Against `main` the diff is additions only. The one other change is the wording of the denormal limit, which now follows main's convention: f32 denormals inside the sum follow the host's mode, not the console's, which reads them as zero (`ftz`). No behavior change. Re-run on Windows 11, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, `dxil.dll` from SDK 10.0.26100, Rust 1.98.1, head `bdced0f`: | | Result | |---|---| | `cargo test -p victory-shader --lib dot2` | 6 passed, hardware and WARP | | `cargo test -p victory-shader` | 214 passed, 1 failed, 2 ignored | | `cargo test --workspace --no-fail-fast` | 480 passed, 2 failed, 7 ignored | | `cargo clippy -p victory-shader --all-targets` | clean | Neither failure comes from this branch: - `victory-hle` `display::sdr_and_display_deferrals` opens a window and fails over SSH, as before. - `fspx_programs_run_with_the_hardwares_dot_products` fails the same way on plain `main` `70564ae`, on the RX 5700 device only: the first case (`[cc164000, 1c0e0501]`) gives `0x80007FF5`, want `0x7FFFFBF5`. The RX 5700 is RDNA1, so this is likely how its driver handles `dot4AddPacked`, not the lowering.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:27 UTC · original · edited 2026-11-26 01:22 UTC

Automated triage for the maintainers.

Merge candidate. Rebased cleanly onto current main; the only new change is moving the lowering and its two_sum / sum3_rounded_once helpers into crates/victory-shader/src/emit/lower/dot2.rs (as lower/bvh.rs does), with a one-line arm left in valu_op, to stay under the policy's file-size limit. The lowering itself matches the version reviewed before: single rounding of the exact three-term sum, backed by the gfx1036 hardware measurements in this thread, with unmodelled modifiers refused. The new test helpers (vop2, vop3p_mods) don't clash with anything in main's valu_tests.rs, and the branch merges cleanly.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7148525425) · edited 2026-11-26 01:22 UTC <!-- victory-triage v1 head=693468ad6525ba2fcfe97a6881b31bff01a41218 verdict=merge-candidate at=2026-11-26T01:22:55Z --> Automated triage for the maintainers. **Merge candidate.** Rebased cleanly onto current `main`; the only new change is moving the lowering and its `two_sum` / `sum3_rounded_once` helpers into `crates/victory-shader/src/emit/lower/dot2.rs` (as `lower/bvh.rs` does), with a one-line arm left in `valu_op`, to stay under the policy's file-size limit. The lowering itself matches the version reviewed before: single rounding of the exact three-term sum, backed by the gfx1036 hardware measurements in this thread, with unmodelled modifiers refused. The new test helpers (`vop2`, `vop3p_mods`) don't clash with anything in `main`'s `valu_tests.rs`, and the branch merges cleanly. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Baconzido on GitHub · 2026-11-25 22:31 UTC · original

Rebased on main f3578e3. The conflicts were only in placement: main's new fma_f16 and v_mul_legacy_f32_treats_denormals_as_zero landed where this PR adds its helpers and tests, so both sides are kept.

One new commit, 693468a. With this PR, lower.rs went past the policy's 512 KiB file limit: 526,928 bytes, and repository_passes_policy failed. The commit moves the dot2 lowering and its two_sum / sum3_rounded_once helpers to emit/lower/dot2.rs, as lower/bvh.rs does. valu_op keeps a one-line arm, and lower.rs is now 94 bytes over main. No behavior change.

Re-run on Windows 11, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, dxil.dll from SDK 10.0.26100, Rust 1.98.1, head 693468a:

Result
cargo test -p victory-shader --lib dot2 6 passed, hardware and WARP
cargo test -p victory-shader 308 passed, 0 failed, 3 ignored
cargo test -p xtask --bin xtask policy 6 passed
cargo test --workspace --no-fail-fast 874 passed, 1 failed, 10 ignored
cargo clippy -p victory-shader --all-targets clean
rustfmt --check on lower/dot2.rs clean

The one failure, victory-hle modules::lifecycle::tests::showing_a_title_window_shows_its_stand_in, opens a window and fails the same way over SSH on plain main f3578e3. With #1790 merged, fspx_programs_run_with_the_hardwares_dot_products now passes on the RX 5700.

No game data used.

AI use: Claude Code (Claude Opus 5.5) did the rebase and the move and wrote this comment; I ran the tests on the hardware above.

**@⁠Baconzido** on GitHub · 2026-11-25 22:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/465#issuecomment-7176479466) Rebased on `main` `f3578e3`. The conflicts were only in placement: main's new `fma_f16` and `v_mul_legacy_f32_treats_denormals_as_zero` landed where this PR adds its helpers and tests, so both sides are kept. One new commit, `693468a`. With this PR, `lower.rs` went past the policy's 512 KiB file limit: 526,928 bytes, and `repository_passes_policy` failed. The commit moves the dot2 lowering and its `two_sum` / `sum3_rounded_once` helpers to `emit/lower/dot2.rs`, as `lower/bvh.rs` does. `valu_op` keeps a one-line arm, and `lower.rs` is now 94 bytes over `main`. No behavior change. Re-run on Windows 11, AMD Radeon RX 5700 (RDNA1, driver 26.11.2) and WARP, `dxil.dll` from SDK 10.0.26100, Rust 1.98.1, head `693468a`: | | Result | |---|---| | `cargo test -p victory-shader --lib dot2` | 6 passed, hardware and WARP | | `cargo test -p victory-shader` | 308 passed, 0 failed, 3 ignored | | `cargo test -p xtask --bin xtask policy` | 6 passed | | `cargo test --workspace --no-fail-fast` | 874 passed, 1 failed, 10 ignored | | `cargo clippy -p victory-shader --all-targets` | clean | | `rustfmt --check` on `lower/dot2.rs` | clean | The one failure, `victory-hle` `modules::lifecycle::tests::showing_a_title_window_shows_its_stand_in`, opens a window and fails the same way over SSH on plain `main` `f3578e3`. With #1790 merged, `fspx_programs_run_with_the_hardwares_dot_products` now passes on the RX 5700. No game data used. AI use: Claude Code (Claude Opus 5.5) did the rebase and the move and wrote this comment; I ran the tests on the hardware above.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-465'
git switch 'github-bot/gh-465'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-465'
git switch 'github-bot/gh-465'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-465'
git switch 'main'
git merge --squash 'github-bot/gh-465'
git switch 'main'
git merge --ff-only 'github-bot/gh-465'
git switch 'main'
git merge 'github-bot/gh-465'
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!465
No description provided.