Translate BVH prefix scans on wave32 GPUs #142

Open
gomeaw wants to merge 49 commits from upstream-pr/142 into main
gomeaw commented 2026-11-26 07:10:46 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by gomeaw on 2026-11-26T07:10:46Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6621474694 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/142). Originally posted by [gomeaw](https://github.com/gomeaw) on 2026-11-26T07:10:46Z. --- 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.
avatarmanz commented 2026-11-26 07:56:21 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by avatarmanz on 2026-11-26T07:56:21Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7186001078 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/142#issuecomment-7186001078). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T07:56:21Z. --- Merged into main in the next push (tests pass); thanks.
avatarmanz commented 2026-11-26 08:19:31 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by avatarmanz on 2026-11-26T08:19:31Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7186457492 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/142#issuecomment-7186457492). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T08:19:31Z. --- 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.
Aniseto commented 2026-11-26 17:16:51 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Aniseto on 2026-11-26T17:16:51Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7198764327 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/142#issuecomment-7198764327). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-26T17:16:51Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/142:upstream-pr/142'
git switch 'upstream-pr/142'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/142'
git switch 'upstream-pr/142'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/142'
git switch 'upstream-pr/142'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/142'
git switch 'main'
git merge --squash 'upstream-pr/142'
git switch 'main'
git merge --ff-only 'upstream-pr/142'
git switch 'main'
git merge 'upstream-pr/142'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!142
No description provided.