Shaders: count threads of wave64 builder programs on 32-lane hosts (NVIDIA) #66

Merged
Mumogg merged 1 commit from upstream-pr/66 into main 2026-11-26 08:17:50 +00:00
Mumogg commented 2026-11-26 01:22:35 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Mumogg on 2026-11-26T01:22:35Z.


Summary

On 32-lane hosts (NVIDIA), counted_in_threads skips the structure builder's one-dimensional wave64 programs (!parts.native.wave64 || host_max_wave() >= 64), because their console waves run as two host waves that exchange through group barriers, and lanes cannot leave at entry. The lanes past the dispatch's thread count (USER_DISPATCH_THREADS_X) therefore run: they count in wave ops (s_bcnt1 exec, reductions, ballots) and store.

This keeps those lanes alive for the barriers and leaves them out instead (partial_active): memory accesses (global, flat, buffer, image, LDS), EXEC ballots, wave reductions, scc tests and the halves' exchange. Shuffles (ds_swizzle, ds_(b)permute) keep the plain guard, because they read other lanes, not memory. AMD and other 64-lane hosts are unchanged (they still take the early return).

Together with the first-lane fix from fxceless/victory-fork#497 (54f3815, 3e36c41: the builder's prefix scans), this brings the ray-tracing structure builder to 53/53 host pipelines on an RTX 5070 Ti, and VICTORY_BVH_BUILDER=1 turns on in game. That fix is not part of this PR.

Test

partial_dispatch_with_a_cross_half_wave_op_runs_in_32_lane_waves (adapted from fxceless/victory-fork#646's test): a spilled 64-thread wave64 program reads s_bcnt1_i32_b64(exec) on entry, takes a whole-wave OR of 1 << (lane >> 1) (which crosses the halves), and stores both for every lane. It is lowered through lower::lower on a 32-lane host, so it goes through counted_in_threads as the game's programs do. It must take 32-lane waves and give exact results for counts 45, 1, 33 and 0.

  • Without the change: fails (USER_DISPATCH_THREADS_X is never read).
  • With it: passes on the hardware device.
  • Full victory-shader --features host suite on this branch: 278 passed, 1 failed (stub_pipeline_is_created, which also fails without this change: vkd3d-proton does not check the DXIL digest).

Tested on Linux only: RTX 5070 Ti, Wine 11.22 + vkd3d-proton, DXC 1.9.2609 validator. Not tested on Windows or AMD yet. In-game testing on NVIDIA/Linux is still in progress; I will post updates here.

No game data, code or assets are included.

AI-assisted: the change, the test and this text were made with Claude Code at my request.

🤖 Generated with Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6617344397 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/66). Originally posted by [Mumogg](https://github.com/Mumogg) on 2026-11-26T01:22:35Z. --- ## Summary On 32-lane hosts (NVIDIA), `counted_in_threads` skips the structure builder's one-dimensional wave64 programs (`!parts.native.wave64 || host_max_wave() >= 64`), because their console waves run as two host waves that exchange through group barriers, and lanes cannot leave at entry. The lanes past the dispatch's thread count (`USER_DISPATCH_THREADS_X`) therefore run: they count in wave ops (`s_bcnt1 exec`, reductions, ballots) and store. This keeps those lanes alive for the barriers and leaves them out instead (`partial_active`): memory accesses (global, flat, buffer, image, LDS), EXEC ballots, wave reductions, `scc` tests and the halves' exchange. Shuffles (`ds_swizzle`, `ds_(b)permute`) keep the plain guard, because they read other lanes, not memory. AMD and other 64-lane hosts are unchanged (they still take the early return). Together with the first-lane fix from fxceless/victory-fork#497 (`54f3815`, `3e36c41`: the builder's prefix scans), this brings the ray-tracing structure builder to **53/53 host pipelines on an RTX 5070 Ti**, and `VICTORY_BVH_BUILDER=1` turns on in game. That fix is not part of this PR. ## Test `partial_dispatch_with_a_cross_half_wave_op_runs_in_32_lane_waves` (adapted from fxceless/victory-fork#646's test): a spilled 64-thread wave64 program reads `s_bcnt1_i32_b64(exec)` on entry, takes a whole-wave OR of `1 << (lane >> 1)` (which crosses the halves), and stores both for every lane. It is lowered through `lower::lower` on a 32-lane host, so it goes through `counted_in_threads` as the game's programs do. It must take 32-lane waves and give exact results for counts 45, 1, 33 and 0. - Without the change: fails (`USER_DISPATCH_THREADS_X` is never read). - With it: passes on the hardware device. - Full `victory-shader --features host` suite on this branch: 278 passed, 1 failed (`stub_pipeline_is_created`, which also fails without this change: vkd3d-proton does not check the DXIL digest). Tested on Linux only: RTX 5070 Ti, Wine 11.22 + vkd3d-proton, DXC 1.9.2609 validator. **Not tested on Windows or AMD yet.** In-game testing on NVIDIA/Linux is still in progress; I will post updates here. No game data, code or assets are included. *AI-assisted: the change, the test and this text were made with Claude Code at my request.* 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MoonYueya commented 2026-11-26 05:28:31 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by MoonYueya on 2026-11-26T05:28:31Z.


Tested on an RTX 3080 10 GB, driver 32.0.16.1742, Ryzen 7 7700, 31.1 GB RAM, Windows 11 26300, merged into MoonYueya/VIctory-Kira a3de053 on top of e2a28ec together with the other open NVIDIA PRs (#47 #48 #24 #23 #78 #42 #66 #18 #10 #4 #58 #17).

  • cargo test --workspace --locked --no-fail-fast -- --test-threads=1: 925 passed, 0 failed, 45 ignored after this PR was merged (never below the count before it; the branch started at 923).
  • The RTX 3080 reports 32-lane waves, so counted_in_threads used to skip the structure builder's programs outright. Its spill test passes here.
  • With everything merged, three unattended runs reached the world with no device removal, panic or untranslated shader.

What this does not show: the PR was not run in the game on its own, so this is unit tests plus a combined run, not an in-game verification of this PR by itself; nothing here is about picture quality.

AI-assisted.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7183517897 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/66#issuecomment-7183517897). Originally posted by [MoonYueya](https://github.com/MoonYueya) on 2026-11-26T05:28:31Z. --- Tested on an RTX 3080 10 GB, driver 32.0.16.1742, Ryzen 7 7700, 31.1 GB RAM, Windows 11 26300, merged into [MoonYueya/VIctory-Kira](https://github.com/MoonYueya/VIctory-Kira) `a3de053` on top of `e2a28ec` together with the other open NVIDIA PRs (#47 #48 #24 #23 #78 #42 #66 #18 #10 #4 #58 #17). - `cargo test --workspace --locked --no-fail-fast -- --test-threads=1`: **925 passed, 0 failed, 45 ignored** after this PR was merged (never below the count before it; the branch started at 923). - The RTX 3080 reports 32-lane waves, so `counted_in_threads` used to skip the structure builder's programs outright. Its spill test passes here. - With everything merged, three unattended runs reached the world with no device removal, panic or untranslated shader. What this does **not** show: the PR was not run in the game on its own, so this is unit tests plus a combined run, not an in-game verification of this PR by itself; nothing here is about picture quality. *AI-assisted.*
avatarmanz commented 2026-11-26 07:56:12 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185998453 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/66#issuecomment-7185998453). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T07:56:12Z. --- Merged into main in the next push (tests pass); thanks.
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!66
No description provided.