Shader tests: check Wave64 binary64 sums after one half exits a loop #3501

Open
github-bot wants to merge 7 commits from github-bot/gh-3501 into main AGit
Owner

@⁠Venom2054 on GitHub · 2026-11-27 10:45 UTC · original
Venom2054:test/wave64-masked-loop → main · +693 −7 · 8 files · 7 commits · draft

This is the masked-loop regression requested in #2978, stacked on f923b5d. Review the single test commit. The other commits shown against main belong to the parent stack.

Three synthetic groups each start with 64 lanes. Only the upper half, lower half, or lane 63 continues to the second iteration. The readback checks both words of the binary64 sum for each active lane and both initialized marker words for each lane that exited. The inputs keep all intermediate sums exactly representable and give each lane a distinct contribution to the low word.

Second iteration Expected result, high and low words
Upper half 40400000_00000c20
Lower half 40400000_00000420
Lane 63 3ff00000_00001000

A native Wave64 hardware readback is requested. On Microsoft app-local WARP 1.0.22, all 192 first-iteration results and 127 inactive-lane markers matched. All 65 continuing lanes returned the first sum, 40500000_00000820. A separate DXC-compiled HLSL control using WaveActiveSum(double) inside a divergent loop showed the same result on WARP. A uniform two-iteration HLSL control that zeroed inactive contributions passed all 65 second-iteration sums. This leaves the cause on native Wave64 hardware open.

On an RTX 5070 Ti, the parent stack requires a native wave of 64 for this program and correctly skips dispatch on the 32-lane adapter. In a separate split-Wave64 implementation based on #439, the identical synthetic instruction words, inputs and expected results passed all 768 output-word checks on that card.

To reproduce, run cargo test -p victory-shader --lib --features host --locked a_wave64_binary64_sum_observes_early_loop_exits -- --nocapture. The output identifies devices skipped for wave width and devices that executed the check. For the software comparison, run a copy of the test executable next to the x64 d3d10warp.dll from Microsoft.Direct3D.WARP 1.0.22.

The patch passes shader all-target/all-feature Clippy with warnings denied and the repository asset check. The full local shader suite also encountered an access violation in heap_direct_texture_reads_mark_their_heap_index; the same isolated test crashed at the unmodified parent. The new fixture uses hand-written instructions and synthetic inputs. Implementation and testing were assisted by Codex.

**@⁠Venom2054** on GitHub · 2026-11-27 10:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/3501) `Venom2054:test/wave64-masked-loop` → `main` · +693 −7 · 8 files · 7 commits · draft This is the masked-loop regression requested in [#2978](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2978), stacked on `f923b5d`. [Review the single test commit](https://github.com/Venom2054/VIctory/commit/55353e5b08412d7d42aed77946415737238ca2b8). The other commits shown against main belong to the parent stack. Three synthetic groups each start with 64 lanes. Only the upper half, lower half, or lane 63 continues to the second iteration. The readback checks both words of the binary64 sum for each active lane and both initialized marker words for each lane that exited. The inputs keep all intermediate sums exactly representable and give each lane a distinct contribution to the low word. | Second iteration | Expected result, high and low words | | --- | --- | | Upper half | `40400000_00000c20` | | Lower half | `40400000_00000420` | | Lane 63 | `3ff00000_00001000` | **A native Wave64 hardware readback is requested.** On Microsoft app-local WARP 1.0.22, all 192 first-iteration results and 127 inactive-lane markers matched. All 65 continuing lanes returned the first sum, `40500000_00000820`. A separate DXC-compiled HLSL control using `WaveActiveSum(double)` inside a divergent loop showed the same result on WARP. A uniform two-iteration HLSL control that zeroed inactive contributions passed all 65 second-iteration sums. This leaves the cause on native Wave64 hardware open. On an RTX 5070 Ti, the parent stack requires a native wave of 64 for this program and correctly skips dispatch on the 32-lane adapter. In a separate split-Wave64 implementation based on #439, the identical synthetic instruction words, inputs and expected results passed all 768 output-word checks on that card. To reproduce, run `cargo test -p victory-shader --lib --features host --locked a_wave64_binary64_sum_observes_early_loop_exits -- --nocapture`. The output identifies devices skipped for wave width and devices that executed the check. For the software comparison, run a copy of the test executable next to the x64 `d3d10warp.dll` from Microsoft.Direct3D.WARP 1.0.22. The patch passes shader all-target/all-feature Clippy with warnings denied and the repository asset check. The full local shader suite also encountered an access violation in `heap_direct_texture_reads_mark_their_heap_index`; the same isolated test crashed at the unmodified parent. The new fixture uses hand-written instructions and synthetic inputs. Implementation and testing were assisted by Codex.
The console's 64-bit to 32-bit conversion: the VGPR pair is bitcast to a
`double` and truncated with the host's `fptrunc`, round to nearest even,
which is MODE's default. The toward-zero 64-bit mode has no DXIL form and is
refused by name rather than mis-rounded.

The IR had no 64-bit float type: it gains `double` (bitcode type 4) and the
`fptrunc` cast (LLVM opcode 7). A module that uses it declares the doubles
feature — SFI0 0x1 and the module's feature-info bit 2 — which dxil.dll
checks against the module.

Ten cases run on the card, checked against Rust's `as f32`: 1.0, -2.5, 0.1,
a tie that rounds to even, the two smallest subnormals (0), f64 max (inf),
±inf and a NaN (payload kept). WARP tops out at SM 6.2 here, so the hardware
device is the one exercised; the DXIL is validated by dxil.dll.

(cherry picked from commit 0439ea5bdb)
Two findings from the review (tyr0nsur):

- A literal source of `v_cvt_f32_f64` is the **high** word of the binary64
  (RDNA 2 ISA 6.2.1), the low word zero: 0xC0020000 is -2.25. `src64` reads a
  literal as the sign-extended integer its bits are, so the value became
  garbage there. The literal is handled in the lowering now, and
  `a_64_bit_literal_source_is_the_high_word` runs it on the card.
- The round-mode check admitted every mode but toward-zero: the directed
  modes (1, 2) and a mode written at run time (`None`) have no DXIL form, and
  `fptrunc` rounds nearest-even regardless. Only MODE's default (0) converts
  now; anything else is refused by name.

Lib suite 249 passed, 0 failed, 3 ignored; clippy `-D warnings` clean.

(cherry picked from commit 1ab5616df4)
Review feedback on #2348: `v_cvt_f32_f64` lowers an inline float constant
(operand codes 240-248) through `src64`'s fallback, which zero-extends the
**f32** bit pattern — `1.0` became 0x000000003F800000, a subnormal that
converts to 0, where the hardware uses the binary64 of the value (RDNA 2 ISA
6.2.1).

The instruction now maps 240-248 to the same values as binary64 (including
1/(2π)) and builds the bits with an integer constant; register pairs and
literals keep their paths. `a_64_bit_inline_constant_source_is_the_same_value`
converts code 242 (1.0) and expects 1.0; before this it got 0.

(cherry picked from commit f956a6699e)
The console compiler expands a wave sum of doubles into a whole-wave section
on dword pairs: v_cndmask per dword, two v_mov_b32 per DPP step, v_add_f64 on
the pairs, v_permlanex16 per dword, v_readlane, and s_mov_b32 copies out. The
simulator followed 32-bit steps only, so both dwords were unknown and a
program reading them was refused ("a whole-wave section step the simulation
does not follow").

- wave.rs: Sym::Red64 is one dword of the binary64 sum over some lanes of
  mask ? (lo, hi) : +0.0; v_add_f64 joins two terms of one masked sum over
  disjoint lanes and writes both destination dwords; s_mov_b32 keeps what
  its source holds; a sum over every lane is Shape::Sum64.
- lower/sum64.rs: Shape::Sum64 is one waveActiveOp.f64 per block, shared by
  both dwords (FLOAT64, INT64, WAVE_OPS).

Tests: two simulator tests (the wave32 expansion is followed through its
dwords and copies; a lane counted twice is not a sum) and a GPU test running
the section end to end into v_cvt_f32_f64.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The section declares the console's wave of 32, which WARP (4-lane waves)
refuses: run_cases_wave32 skips WARP there, as synthetic_tests does. A
second test runs the section over 32 lanes with only lanes below s2 active;
lane l adds 2^l, so the sum is 2^s2 - 1 in any order and the inactive
lanes' +0.0 must not count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI has no hardware adapter, and the inbox WARP runs 4-lane waves only, so
both binary64 sum tests skipped every device and then failed the 'some
device ran' assertion. synthetic_tests' wave-32 tests already allow this;
run_cases_wave32 now does too. run_cases keeps its assertion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 10:50:24 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 11:35 UTC · original

Independent WARP/CPU verification (no physical GPU), Windows 11 build 26200, Rust 1.98.1 debug build, cargo test -p victory-shader --lib --features host --locked, VICTORY_WARP=1 and VICTORY_D3D12_WARP=1, dxil.dll 10.0.19041.5609 (Windows SDK redist). Synthetic tests only.

Commits: base 63bcca4 (main), parent f923b5d, head 55353e5b.

The new test, on head 55353e5b (masked_sum_tests::a_wave64_binary64_sum_observes_early_loop_exits):

  • System WARP 10.0.26100.9818 (4-lane waves): passes, but only by skipping (native Wave64/FP64 unavailable (lanes 4..4); skipped), so it checks nothing here.
  • App-local Microsoft.Direct3D.WARP 1.0.22.0 next to the test exe: the test runs and fails. The first mismatch per group is (group 0, lane 0x20), (group 1, lane 0), (group 2, lane 0x3f). In each, the continuing lane returns 40500000_00000820 (the first-iteration sum) where 40400000_00000c20, 40400000_00000420 and 3ff00000_00001000 were expected. This is the same result the PR describes for WARP 1.0.22, so the fixture reproduces it. It is red by design until the Wave64 behaviour is resolved; it will be red in any environment that runs it on that WARP.

Parent f923b5d: the test does not exist (312 tests listed, 313 on head); masked_sum filters to 0 tests.

Suite, base vs head (--test-threads 1; the same sets also appeared at 4 threads):

WARP base 63bcca4 head 55353e5b
system 10.0.26100.9818 298 passed, 4 failed, 3 ignored 304 passed, 6 failed, 3 ignored
app-local 1.0.22 296 passed, 6 failed, 3 ignored 303 passed, 7 failed, 3 ignored
  • The failures present on base are the same on head: synthetic_tests::{gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out, permutes_mask_high_address_bits_and_divergent_branches, a_mask_joined_with_data_at_a_uniform_loop_is_its_number} on the system WARP, and a similar set (plus hosts_that_do_not_fuse_are_named, wave64_permutes_stay_within_each_32_lane_half, edge_flagged_triangles_draw_as_unflagged_ones) on 1.0.22.
  • Head's only additions: the new test (fails on 1.0.22, as above) and, on the system WARP only, two tests from the parent stack: valu_tests::a_whole_wave_binary64_sum_counts_the_active_lanes_only and valu_tests::a_whole_wave_binary64_sum_reaches_the_host. They panic at crates/victory-shader/src/emit/valu_tests.rs:239 with hardware: compute_pipeline failed: The parameter is incorrect. They fail the same way at the parent f923b5d, so they are not from the reviewed commit. The commit message of ab08acb says they skip WARP's 4-lane waves, but on this system WARP they fail instead. They pass on 1.0.22.

Findings: no blockers in the reviewed commit. The new test is a deliberate failing repro on WARP 1.0.22 and a vacuous pass on 4-lane WARP. The valu_tests.rs:239 failure on the system WARP belongs to the parent stack.

Not verified: native Wave64 hardware (no GPU here).

AI-assisted (Claude Code / Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-27 11:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3501#issuecomment-7217253047) Independent WARP/CPU verification (no physical GPU), Windows 11 build 26200, Rust 1.98.1 debug build, `cargo test -p victory-shader --lib --features host --locked`, `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1`, dxil.dll 10.0.19041.5609 (Windows SDK redist). Synthetic tests only. Commits: base `63bcca4` (main), parent `f923b5d`, head `55353e5b`. **The new test, on head `55353e5b`** (`masked_sum_tests::a_wave64_binary64_sum_observes_early_loop_exits`): - System WARP 10.0.26100.9818 (4-lane waves): passes, but only by skipping (`native Wave64/FP64 unavailable (lanes 4..4); skipped`), so it checks nothing here. - App-local Microsoft.Direct3D.WARP 1.0.22.0 next to the test exe: the test runs and **fails**. The first mismatch per group is (group 0, lane 0x20), (group 1, lane 0), (group 2, lane 0x3f). In each, the continuing lane returns `40500000_00000820` (the first-iteration sum) where `40400000_00000c20`, `40400000_00000420` and `3ff00000_00001000` were expected. This is the same result the PR describes for WARP 1.0.22, so the fixture reproduces it. It is red by design until the Wave64 behaviour is resolved; it will be red in any environment that runs it on that WARP. **Parent `f923b5d`:** the test does not exist (312 tests listed, 313 on head); `masked_sum` filters to 0 tests. **Suite, base vs head** (`--test-threads 1`; the same sets also appeared at 4 threads): | WARP | base `63bcca4` | head `55353e5b` | | --- | --- | --- | | system 10.0.26100.9818 | 298 passed, 4 failed, 3 ignored | 304 passed, 6 failed, 3 ignored | | app-local 1.0.22 | 296 passed, 6 failed, 3 ignored | 303 passed, 7 failed, 3 ignored | - The failures present on base are the same on head: `synthetic_tests::{gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out, permutes_mask_high_address_bits_and_divergent_branches, a_mask_joined_with_data_at_a_uniform_loop_is_its_number}` on the system WARP, and a similar set (plus `hosts_that_do_not_fuse_are_named`, `wave64_permutes_stay_within_each_32_lane_half`, `edge_flagged_triangles_draw_as_unflagged_ones`) on 1.0.22. - Head's only additions: the new test (fails on 1.0.22, as above) and, on the system WARP only, two tests from the parent stack: `valu_tests::a_whole_wave_binary64_sum_counts_the_active_lanes_only` and `valu_tests::a_whole_wave_binary64_sum_reaches_the_host`. They panic at `crates/victory-shader/src/emit/valu_tests.rs:239` with `hardware: compute_pipeline failed: The parameter is incorrect.` They fail the same way at the parent `f923b5d`, so they are not from the reviewed commit. The commit message of `ab08acb` says they skip WARP's 4-lane waves, but on this system WARP they fail instead. They pass on 1.0.22. **Findings:** no blockers in the reviewed commit. The new test is a deliberate failing repro on WARP 1.0.22 and a vacuous pass on 4-lane WARP. The `valu_tests.rs:239` failure on the system WARP belongs to the parent stack. Not verified: native Wave64 hardware (no GPU here). AI-assisted (Claude Code / Claude Sonnet 5.5).
Author
Owner

@⁠ColorMeBoom on GitHub · 2026-11-27 13:52 UTC · original

AMD run: RX 5700 XT (RDNA1, 32–64 lanes, native Wave64 and FP64), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1, debug. The head was merged onto main 63bcca4 and run on the native adapter (VICTORY_WARP unset), no game files. Head 55353e5. This is the native Wave64 readback the description asks for.

  • a_wave64_binary64_sum_observes_early_loop_exits passes on hardware: hardware: verified both iterations in all three Wave64 groups. The upper half, the lower half and lane 63 each get their second-iteration sum, so on native Wave64 the translated program gives the right results. The system WARP in the same run skipped (native Wave64/FP64 unavailable (lanes 4..4)). That points to the continuing lanes returning 40500000_00000820 being WARP 1.0.22's behaviour, which matches your DXC WaveActiveSum(double) control on WARP, and not the translation's. I didn't run app-local WARP 1.0.22 here.
  • The parent stack's a_whole_wave_binary64_sum_reaches_the_host and a_whole_wave_binary64_sum_counts_the_active_lanes_only pass on this card. The system WARP skips them with no pipeline for a wave of 32, as ab08acb intends; on @⁠oni-swr's machine they panicked there instead. a_64_bit_value_converts_to_f32_round_to_nearest and both wave::tests binary64 tests pass.
  • Full victory-shader suite (--features host): 310 passed, 0 failed, 3 ignored. heap_direct_texture_reads_mark_their_heap_index didn't crash on this card. cargo clippy -p victory-shader --all-targets --features host -- -D warnings: clean.

AI use: Claude Code (Claude Opus 5.5).

**@⁠ColorMeBoom** on GitHub · 2026-11-27 13:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/3501#issuecomment-7220043437) **AMD run: RX 5700 XT** (RDNA1, 32–64 lanes, native Wave64 and FP64), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1, debug. The head was merged onto `main` `63bcca4` and run on the native adapter (`VICTORY_WARP` unset), no game files. Head `55353e5`. This is the native Wave64 readback the description asks for. - **`a_wave64_binary64_sum_observes_early_loop_exits` passes on hardware:** `hardware: verified both iterations in all three Wave64 groups`. The upper half, the lower half and lane 63 each get their second-iteration sum, so on native Wave64 the translated program gives the right results. The system WARP in the same run skipped (`native Wave64/FP64 unavailable (lanes 4..4)`). That points to the continuing lanes returning `40500000_00000820` being WARP 1.0.22's behaviour, which matches your DXC `WaveActiveSum(double)` control on WARP, and not the translation's. I didn't run app-local WARP 1.0.22 here. - The parent stack's `a_whole_wave_binary64_sum_reaches_the_host` and `a_whole_wave_binary64_sum_counts_the_active_lanes_only` pass on this card. The system WARP skips them with `no pipeline for a wave of 32`, as `ab08acb` intends; on @⁠oni-swr's machine they panicked there instead. `a_64_bit_value_converts_to_f32_round_to_nearest` and both `wave::tests` binary64 tests pass. - Full `victory-shader` suite (`--features host`): **310 passed, 0 failed, 3 ignored**. `heap_direct_texture_reads_mark_their_heap_index` didn't crash on this card. `cargo clippy -p victory-shader --all-targets --features host -- -D warnings`: clean. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠oddmaniv on GitHub · 2026-11-27 14:18 UTC · original

Independent verification of the PR author's concurrent WARP pipeline/draw test at 55353e5b08412d7d42aed77946415737238ca2b8.

cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture

Tree Result
Unmodified PR head 1 passed, 0 failed, 0 ignored; native exit 0
Unmodified main 1 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 1 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

**@⁠oddmaniv** on GitHub · 2026-11-27 14:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3501#issuecomment-7220625060) Independent verification of the PR author's concurrent WARP pipeline/draw test at `55353e5b08412d7d42aed77946415737238ca2b8`. `cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture` | Tree | Result | | --- | --- | | Unmodified PR head | 1 passed, 0 failed, 0 ignored; native exit 0 | | Unmodified main | 1 passed, 0 failed, 0 ignored; native exit 0 | | PR patch applied to pinned main | 1 passed, 0 failed, 0 ignored; native exit 0 | Main baseline pin: `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits. This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed. AI-assisted verification.
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/3501/head:github-bot/gh-3501'
git switch 'github-bot/gh-3501'

Merge

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