Translate BVH prefix scans on wave32 GPUs #142

Open
github-bot wants to merge 49 commits from github-bot/gh-142 into main AGit
Owner

@⁠gomeaw on GitHub · 2026-11-26 07:10 UTC · original
gomeaw:fix/wave32-bvh-first-lane → main · +358 −44 · 3 files · 7 commits · open

Fixes the three prefix-scan translation failures reported in #37: 39321a95223001ed, 77360df21e12ea43, and 9fc111d3be79364f. The builder needs all 53 stages to have a host pipeline before it can start.

These scans read the first lane of a subtotal inside a loop whose exit can differ across console waves. If every lane within a console wave holds the same value, either 32-lane half can read its own first lane without making the entire workgroup meet at a barrier. The patch backports justrealyme and ryotdev's fix and narrows the uniformity proof for register reads, predicates, and LDS operations. It incorporates findings from adriaespii's earlier review.

Verification

  • Windows CI reproduced the first-lane refusal on f249fe0. With the patch the same synthetic scan passes the SDK DXIL validator, the lane-dependent variant still refuses, and 290 shader tests pass. The prefix tests also pass at VICTORY_SHADER_OPT=127.
  • The test checks all 256 output values when a 32-lane hardware device is available. Hosted CI could validate the DXIL and skipped that dispatch.
  • #66 covers counted partial workgroups in other builder stages. Its RTX 5070 Ti report reached 53/53 pipelines with the donor first-lane fix and #66 together. The builder stays opt-in in this patch. The translator cache version is bumped because the new proof can change DXIL for shaders that already translated. A gameplay retest is needed to establish runtime stability on this branch.

A native test can run cargo test --locked -p victory-shader --lib a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop -- --nocapture. For the live comparison in #37, compare the three shader hashes and the builder's stage count with VICTORY_BVH_BUILDER=1. Please include where the run reaches and any device failure.

The combined test branch pairs this backport with #66 and the existing descriptor and thread-ID fixes on the original 0a43566 baseline. Windows accepted both synthetic DXIL programs on that branch and passed 292 shader tests.

**@⁠gomeaw** on GitHub · 2026-11-26 07:10 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/142) `gomeaw:fix/wave32-bvh-first-lane` → `main` · +358 −44 · 3 files · 7 commits · open Fixes the three prefix-scan translation failures reported in #37: `39321a95223001ed`, `77360df21e12ea43`, and `9fc111d3be79364f`. The builder needs all 53 stages to have a host pipeline before it can start. These scans read the first lane of a subtotal inside a loop whose exit can differ across console waves. If every lane within a console wave holds the same value, either 32-lane half can read its own first lane without making the entire workgroup meet at a barrier. The patch backports [justrealyme and ryotdev's fix](https://github.com/fxceless/victory-fork/pull/497) and narrows the uniformity proof for register reads, predicates, and LDS operations. It incorporates findings from [adriaespii's earlier review](https://github.com/fxceless/victory-fork/pull/36). ## Verification - [Windows CI](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45773987564) reproduced the first-lane refusal on `f249fe0`. With the patch the same synthetic scan passes the SDK DXIL validator, the lane-dependent variant still refuses, and 290 shader tests pass. The prefix tests also pass at `VICTORY_SHADER_OPT=127`. - The test checks all 256 output values when a 32-lane hardware device is available. Hosted CI could validate the DXIL and skipped that dispatch. - #66 covers counted partial workgroups in other builder stages. Its RTX 5070 Ti report reached 53/53 pipelines with the donor first-lane fix and #66 together. The builder stays opt-in in this patch. The translator cache version is bumped because the new proof can change DXIL for shaders that already translated. A gameplay retest is needed to establish runtime stability on this branch. A native test can run `cargo test --locked -p victory-shader --lib a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop -- --nocapture`. For the live comparison in #37, compare the three shader hashes and the builder's stage count with `VICTORY_BVH_BUILDER=1`. Please include where the run reaches and any device failure. The [combined test branch](https://github.com/gomeaw/VIctory-7900XTX/tree/test/nvidia-bvh) pairs this backport with #66 and the existing descriptor and thread-ID fixes on the original `0a43566` baseline. [Windows accepted both synthetic DXIL programs](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45773772694) on that branch and passed 292 shader tests.
On a GPU with 32-lane waves a console wave64 program runs as two host
waves, and a v_readfirstlane where not every lane runs was refused (the
two halves cannot meet there to give each other their first lane). Three
programs of the ray-tracing structure builder stopped that way, so the
builder (all or none) could not run on NVIDIA at all (issue #4).

They read the first lane of a value every lane of the console wave holds
alike, inside a loop whose conditions are alike in the console wave too:
a prefix over wave totals, `if (id >> 6 != 0)` and lanes leaving at their
wave's own index. Then each host wave can take its own first lane.

lane_uniform now proves that: it runs to a fixed point; an instruction
under a condition whose atoms are compares of alike values (or uniform)
counts, over an old value that is alike too (waves the condition leaves
out keep that); LDS reads at an alike address count; phis count where
every predecessor is reached by whole console waves (past branches on
alike conditions only); and the thread id's x shifted right by 6 or more
is alike where console waves are runs of 64 ids along x. The result is
only used for v_readfirstlane in the two-host-wave form.

Checked: a GPU test of the same shape (256 threads, four console waves)
fails on the old analysis with the builder's refusal and passes with
this one on an RTX 5070 Ti (driver 621.40), every thread getting the
console's sum. Over the title's whole shader pack and the builder DLL
(VICTORY_HOST_WAVE=32), the only programs whose translation changes are
these three (now emitted and validated: compute 2,718 -> 2,721 of 2,734)
and one other builder program, whose first-lane read of `id >> 6` now
skips an exchange that gave the same value. victory-shader tests: 211
passed. In a world run with VICTORY_BVH_BUILDER=1 the builder now runs
(all 53 programs have host pipelines); the title still crashes within
seconds of it, with or without VICTORY_BVH_QUARANTINE, so it stays off by
default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3f2bcc7f2d79f04dca6d26e32f823a700b1c327f)
(cherry picked from commit 9e24afa06d4d332d432c92680c398b31f59f28d3)
Reuse the control-flow region map during fixed-point analysis. Require all explicit register words and exclude partial LDS loads, GDS and implicit state from the proof. The LDS and operand restrictions draw on adriaespii’s review in fxceless/victory-fork#36.

Validate both a wave-uniform prefix scan and its lane-dependent counterpart and require a compute PSO when the hardware can exercise the wave32 program.
Check the previous destination of swaps and accumulators. A conditional select needs a proven uniform predicate, since a scalar bit pattern can select different inputs in different lanes. Leave relative register accesses and operations with an implicit VCC input outside the proof.
The IR can retain an old destination on ordinary instructions that overwrite it. Only require implicit VGPR values on swaps and accumulators, where lowering consumes them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 07:13:03 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:56 UTC · original

Merged into main in the next push (tests pass); thanks.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:56 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/142#issuecomment-7186001078) Merged into main in the next push (tests pass); thanks.
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 08:19 UTC · original

The earlier version of this PR is in main (0ce46d5a). The commits added after it (head e06ac8d7) aren't yet, and need a review first.

**@⁠avatarmanz** on GitHub · 2026-11-26 08:19 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/142#issuecomment-7186457492) The earlier version of this PR is in main (0ce46d5a). The commits added after it (head e06ac8d7) aren't yet, and need a review first.
Author
Owner

@⁠Aniseto on GitHub · 2026-11-26 17:16 UTC · original

Ran the requested first-lane prefix-scan test at e06ac8d7 on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

. D:\AVATAR-OPS\env-avatar.ps1
$env:VICTORY_D3D12_ADAPTER = 'NVIDIA'
cargo test --locked -p victory-shader --lib a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop -- --nocapture --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 293 filtered out      (exit 0)

The test printed ran on the hardware device: every console wave got the sum of the waves before it, so the 32-lane path was exercised on the real adapter, not only through the DXIL validator. This is the native test the description asks for. I tested the exact head e06ac8d7, which GitHub currently marks as dirty against main; no rebased tree was used. The thread has no prior report from this adapter.

Not tested: the live comparison in #37 with VICTORY_BVH_BUILDER=1, the three shader hashes and the 53-stage builder count, native wave64, AMD and Intel GPUs, Wine, release profile, a retail title, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-26 17:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/142#issuecomment-7198764327) Ran the requested first-lane prefix-scan test at `e06ac8d7` on an NVIDIA Blackwell desktop part: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build. ``` . D:\AVATAR-OPS\env-avatar.ps1 $env:VICTORY_D3D12_ADAPTER = 'NVIDIA' cargo test --locked -p victory-shader --lib a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loop -- --nocapture --test-threads=1 1 passed; 0 failed; 0 ignored; 0 measured; 293 filtered out (exit 0) ``` The test printed `ran on the hardware device: every console wave got the sum of the waves before it`, so the 32-lane path was exercised on the real adapter, not only through the DXIL validator. This is the native test the description asks for. I tested the exact head `e06ac8d7`, which GitHub currently marks as dirty against main; no rebased tree was used. The thread has no prior report from this adapter. Not tested: the live comparison in #37 with `VICTORY_BVH_BUILDER=1`, the three shader hashes and the 53-stage builder count, native wave64, AMD and Intel GPUs, Wine, release profile, a retail title, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
This pull request has changes conflicting with the target branch.
  • apps/victory/src/main.rs
  • apps/victory/src/run.rs
  • apps/victory/src/translate.rs
  • crates/victory-gpu/src/copystat.rs
  • crates/victory-gpu/src/cores.rs
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/host/upq.rs
  • crates/victory-gpu/src/lib.rs
  • crates/victory-gpu/src/port.rs
  • crates/victory-gpu/src/port_descriptors.rs
  • crates/victory-gpu/src/queue.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-gpu/src/texture.rs
  • crates/victory-gpu/src/watch.rs
  • crates/victory-loader/src/descriptor_sites.rs
  • crates/victory-loader/src/lib.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/lib.rs
  • docs/README-fxceless.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-142'
git switch 'github-bot/gh-142'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-142'
git switch 'github-bot/gh-142'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-142'
git switch 'main'
git merge --squash 'github-bot/gh-142'
git switch 'main'
git merge --ff-only 'github-bot/gh-142'
git switch 'main'
git merge 'github-bot/gh-142'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.