shader: intersect v_cndmask_b32 active masks with partial_active on 32-lane hosts #2059

Manually merged
github merged 1 commit from github-bot/gh-2059 into main 2026-11-30 14:16:43 +00:00 AGit
Owner

@⁠steven-seagull27 on GitHub · 2026-11-29 08:52 UTC · original
steven-seagull27:fix/cndmask-partial-active → main · +228 −35 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC

Related: Marvisak/VIctory#3750 (Cause 3)

What it changes

On 32-lane hosts, counted wave64 compute shaders (USER_DISPATCH_THREADS_X) that cannot early-return at entry (because of a group barrier, two-wave exchange, or loop back to entry) keep threads with x >= count alive under Lower::partial_active.

Previously, ballot and collapsed whole-wave reductions (Shape::Masked, Shape::Active, Shape::Prefix, active_f64_sum) intersected masks in st.active with self.partial_active, but direct mask consumers in crates/victory-shader/src/emit/lower.rs did not:

  • v_cndmask_b32
  • v_add_co_ci_u32 / v_sub_co_ci_u32 / v_subrev_co_ci_u32 (carry-in)
  • v_div_fmas_f32 (VCC)
  • lane_heap_index (Source::Lanes)

When a counted wave64 compute shader saved EXEC with s_or_saveexec_b64, masked inactive lanes to zero with v_cndmask_b32, and ran a cross-lane reduction/DPP prefix sum without collapsing into a single-block whole-wave section, v_cndmask_b32 evaluated entry EXEC as Bool::TRUE in every thread—leaving lanes >= count unzeroed and letting them pollute the cross-lane result.

Changes:

  • Added Lower::launched_mask in crates/victory-shader/src/emit/lower.rs to intersect tracked st.active lane-mask booleans with self.partial_active, and applied it across all eight st.masks.get consumers (fixing the four unguarded sites and unifying the four existing sites).
  • Added a synthetic regression test cndmask_saved_exec_respects_dispatch_x_partial_active in crates/victory-shader/src/emit/wave64_tests.rs: a counted 64-thread compute shader that saves EXEC via s_or_saveexec_b64, zeroes inactive lanes with v_cndmask_b32, runs a 64-lane DPP + v_readlane_b32 prefix sum, and stores (prefix, wave_total) per active lane for counts 5, 37, and 0 (all 64 lanes).

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA RTX 5080 (32-lane native hardware D3D12 compute dispatch) + DXIL validation (dxil.dll); synthetic unit test only (no game assets).
  • Before: Synthetic test cndmask_saved_exec_respects_dispatch_x_partial_active failed on 32-lane hardware at count = 5, lane = 0 with left: (1, 2080) vs right: (1, 15) (lanes 5..63 were not zeroed by v_cndmask_b32, so lane 63 summed 1..=64 = 2080 instead of 1..=5 = 15).
  • After: cndmask_saved_exec_respects_dispatch_x_partial_active passes DXIL validation on both 64-lane and 32-lane forms and passes D3D12 hardware execution on 32-lane waves for counts 5 (total 15), 37 (total 703), and 0 (total 2080). (WARP skipped WaveSize(32)/WaveSize(64) PSO creation on this host.)
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): 64-lane and 32-lane lowering + DXIL validation; 32-lane D3D12 hardware execution.
  • cargo test passed for the crates it touches: yes (cargo test --locked -j 3 -p victory-shader --lib -- wave64_tests --test-threads=1 -> 45 passed, 0 failed; cargo clippy --locked -j 3 -p victory-shader --lib --tests -> 0 new warnings; git diff --check clean).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: Marvisak/VIctory#3750
**@⁠steven-seagull27** on GitHub · 2026-11-29 08:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2059) `steven-seagull27:fix/cndmask-partial-active` → `main` · +228 −35 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC Related: Marvisak/VIctory#3750 (Cause 3) ## What it changes On 32-lane hosts, counted wave64 compute shaders (`USER_DISPATCH_THREADS_X`) that cannot early-return at entry (because of a group barrier, two-wave exchange, or loop back to entry) keep threads with `x >= count` alive under `Lower::partial_active`. Previously, `ballot` and collapsed whole-wave reductions (`Shape::Masked`, `Shape::Active`, `Shape::Prefix`, `active_f64_sum`) intersected masks in `st.active` with `self.partial_active`, but direct mask consumers in `crates/victory-shader/src/emit/lower.rs` did not: - `v_cndmask_b32` - `v_add_co_ci_u32` / `v_sub_co_ci_u32` / `v_subrev_co_ci_u32` (carry-in) - `v_div_fmas_f32` (VCC) - `lane_heap_index` (`Source::Lanes`) When a counted wave64 compute shader saved `EXEC` with `s_or_saveexec_b64`, masked inactive lanes to zero with `v_cndmask_b32`, and ran a cross-lane reduction/DPP prefix sum without collapsing into a single-block whole-wave section, `v_cndmask_b32` evaluated entry `EXEC` as `Bool::TRUE` in every thread—leaving lanes `>= count` unzeroed and letting them pollute the cross-lane result. Changes: - Added `Lower::launched_mask` in `crates/victory-shader/src/emit/lower.rs` to intersect tracked `st.active` lane-mask booleans with `self.partial_active`, and applied it across all eight `st.masks.get` consumers (fixing the four unguarded sites and unifying the four existing sites). - Added a synthetic regression test `cndmask_saved_exec_respects_dispatch_x_partial_active` in `crates/victory-shader/src/emit/wave64_tests.rs`: a counted 64-thread compute shader that saves `EXEC` via `s_or_saveexec_b64`, zeroes inactive lanes with `v_cndmask_b32`, runs a 64-lane DPP + `v_readlane_b32` prefix sum, and stores `(prefix, wave_total)` per active lane for counts `5`, `37`, and `0` (all 64 lanes). ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA RTX 5080 (32-lane native hardware D3D12 compute dispatch) + DXIL validation (`dxil.dll`); synthetic unit test only (no game assets). - Before: Synthetic test `cndmask_saved_exec_respects_dispatch_x_partial_active` failed on 32-lane hardware at `count = 5, lane = 0` with `left: (1, 2080)` vs `right: (1, 15)` (lanes `5..63` were not zeroed by `v_cndmask_b32`, so lane 63 summed `1..=64 = 2080` instead of `1..=5 = 15`). - After: `cndmask_saved_exec_respects_dispatch_x_partial_active` passes DXIL validation on both 64-lane and 32-lane forms and passes D3D12 hardware execution on 32-lane waves for counts `5` (total `15`), `37` (total `703`), and `0` (total `2080`). (WARP skipped `WaveSize(32)`/`WaveSize(64)` PSO creation on this host.) - For shader changes, the wave sizes tested (32 and/or 64 lanes): 64-lane and 32-lane lowering + DXIL validation; 32-lane D3D12 hardware execution. - `cargo test` passed for the crates it touches: yes (`cargo test --locked -j 3 -p victory-shader --lib -- wave64_tests --test-threads=1` -> 45 passed, 0 failed; `cargo clippy --locked -j 3 -p victory-shader --lib --tests` -> 0 new warnings; `git diff --check` clean). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: Marvisak/VIctory#3750
On 32-lane hosts, counted wave64 compute shaders (USER_DISPATCH_THREADS_X) that stay under partial_active for a barrier or two-wave exchange still have lanes >= count alive with entry EXEC modeled as Bool::TRUE. Direct v_cndmask_b32 lowering (and v_add/sub_co_ci_u32, v_div_fmas_f32, and per-lane descriptor selects) read st.masks without intersecting st.active masks with partial_active, so saving EXEC via s_or_saveexec_b64 and zeroing inactive lanes with v_cndmask_b32 left out-of-count lanes unzeroed and let them pollute cross-lane reductions.

Add Lower::launched_mask to intersect st.active lane masks with partial_active, apply it across all st.masks.get consumers (including the four existing ballot/wave-reduction sites), and add a synthetic wave64 DPP prefix-sum regression test verifying DXIL validation and D3D12 hardware execution.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 08:56:05 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 10:30 UTC · original · approved these changes

Tested locally merged onto main (829188e9).

  • Merge: Clean merge across crates/victory-shader/src/emit/lower.rs and wave64_tests.rs.
  • Tests (RTX 5090, Wave32 host): cargo test -p victory-shader --lib emit::wave64_tests:: passed (45 passed; 0 failed, including the new cndmask_saved_exec_respects_dispatch_x_partial_active GPU execution test) with 0 new warnings.

Solid Wave32 v_cndmask_b32 active-mask intersection fix for partial-active dispatches. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-29 10:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2059#pullrequestreview-6102479456) · **approved these changes** Tested locally merged onto `main` (`829188e9`). - **Merge**: Clean merge across `crates/victory-shader/src/emit/lower.rs` and `wave64_tests.rs`. - **Tests (RTX 5090, Wave32 host)**: `cargo test -p victory-shader --lib emit::wave64_tests::` passed (`45 passed; 0 failed`, including the new `cndmask_saved_exec_respects_dispatch_x_partial_active` GPU execution test) with 0 new warnings. Solid Wave32 `v_cndmask_b32` active-mask intersection fix for partial-active dispatches. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 13:05 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs, on top of 829188e9 plus a couple of local fixes). Read the full diff first: no network, process spawning, binaries, build/CI/dependency changes or game data. Builds with --profile diag --features diagnostics; clean cherry-pick; the targeted shader tests pass. In-game runs on an RTX 4090 (wave32 host) are queued; results will follow here.

**@⁠dyshay** on GitHub · 2026-11-29 13:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2059#issuecomment-7256279036) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA), branch `janus-prs`, on top of 829188e9 plus a couple of local fixes). Read the full diff first: no network, process spawning, binaries, build/CI/dependency changes or game data. Builds with `--profile diag --features diagnostics`; clean cherry-pick; the targeted shader tests pass. In-game runs on an RTX 4090 (wave32 host) are queued; results will follow here.
github manually merged commit a358263c76 into main 2026-11-30 14:16:43 +00:00
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/trustno1-coder--VIctory-NVIDIA!2059
No description provided.