fix(gpu): enable >65,535-group indirect dispatches on NVIDIA (runs_wide) #1005

Manually merged
github merged 1 commit from github-bot/gh-1005 into main 2026-11-29 08:22:11 +00:00 AGit
Owner

@⁠whoalin1 on GitHub · 2026-11-28 10:59 UTC · original
whoalin1:pr/wide-indirect-dispatches → main · +22 −7 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

Summary

Allows indirect compute dispatches wider than 65,535 groups in X (up to 1 << 20, matching AMD) on NVIDIA hardware (0x10de) via runs_wide, opt-out via VICTORY_INDIRECT_WIDE=0.

Why

NVIDIA's hardware/driver supports 2^31 - 1 compute groups in X, yet indirect.rs previously clamped every non-AMD adapter to 65,535. On dense 1440p GI tile dispatches (e.g. CS_FinalGather lists around ~67,440 groups), the tail ~1,905 groups were dropped, leaving the lower band of the frame unlit or smudged.

Change (crates/victory-gpu/src/indirect.rs)

  • Factor PCI vendor lookup into vendor(device) and add runs_wide(device) matching AMD (0x1002) or NVIDIA (0x10de), while preserving amd(device) for AMD-specific callers.
  • Use widest(runs_wide(device)) in make_from.
  • Enable card_runs_wide_indirect_dispatches on runs_wide adapters.

Verification

Verified on Windows (x86_64-pc-windows-msvc, RTX 4070 SUPER, driver 610.88):

  • git diff --check origin/main..HEAD — clean
  • cargo run --locked -p xtask -- policy — asset policy: 294 files ok
  • cargo clippy --workspace --all-targets --locked & --all-features — 0 warnings in crates/victory-gpu/src/indirect.rs
  • cargo test --release -p victory-gpu --locked --lib indirect:: -- --test-threads=1 — 29 passed, 0 failed, 9 ignored (including card_runs_wide_indirect_dispatches)
**@⁠whoalin1** on GitHub · 2026-11-28 10:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1005) `whoalin1:pr/wide-indirect-dispatches` → `main` · +22 −7 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC ## Summary Allows indirect compute dispatches wider than 65,535 groups in X (up to `1 << 20`, matching AMD) on NVIDIA hardware (`0x10de`) via [`runs_wide`](crates/victory-gpu/src/indirect.rs), opt-out via `VICTORY_INDIRECT_WIDE=0`. ## Why NVIDIA's hardware/driver supports `2^31 - 1` compute groups in X, yet [`indirect.rs`](crates/victory-gpu/src/indirect.rs) previously clamped every non-AMD adapter to `65,535`. On dense 1440p GI tile dispatches (e.g. `CS_FinalGather` lists around ~67,440 groups), the tail ~1,905 groups were dropped, leaving the lower band of the frame unlit or smudged. ## Change (`crates/victory-gpu/src/indirect.rs`) - Factor PCI vendor lookup into `vendor(device)` and add `runs_wide(device)` matching AMD (`0x1002`) or NVIDIA (`0x10de`), while preserving `amd(device)` for AMD-specific callers. - Use `widest(runs_wide(device))` in `make_from`. - Enable `card_runs_wide_indirect_dispatches` on `runs_wide` adapters. ## Verification Verified on Windows (`x86_64-pc-windows-msvc`, RTX 4070 SUPER, driver 610.88): - `git diff --check origin/main..HEAD` — clean - `cargo run --locked -p xtask -- policy` — `asset policy: 294 files ok` - `cargo clippy --workspace --all-targets --locked` & `--all-features` — 0 warnings in `crates/victory-gpu/src/indirect.rs` - `cargo test --release -p victory-gpu --locked --lib indirect:: -- --test-threads=1` — 29 passed, 0 failed, 9 ignored (including `card_runs_wide_indirect_dispatches`)
Allow indirect dispatches wider than 65,535 groups in x (up to `2^20`, matching AMD) on NVIDIA hardware (`0x10de`), opt-out via `VICTORY_INDIRECT_WIDE=0`.

Previously `!amd` clamped NVIDIA indirect compute dispatches to `65_535` groups, cutting off the tail of 1440p tile dispatches (e.g. `CS_FinalGather` lists of ~67,440 groups, leaving the bottom fifth unlit/smudged).

Includes `card_runs_wide_indirect_dispatches` enabled for both AMD and NVIDIA (verified passing on RTX 4070 SUPER).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:31:32 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 11:48 UTC · original · approved these changes

Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests (RTX 5090 + WARP): cargo test -p victory-gpu --lib indirect:: passed (29 passed; 0 failed; 9 ignored, including the new indirect::tests::card_runs_wide_indirect_dispatches verified directly on RTX 5090 hardware) with 0 compiler warnings.

Great NVIDIA wide indirect-dispatch (>65,535 groups) fix verified on hardware. LGTM.

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

**@⁠Dukestar69** on GitHub · 2026-11-28 11:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1005#pullrequestreview-6097613762) · **approved these changes** Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests (RTX 5090 + WARP)**: `cargo test -p victory-gpu --lib indirect::` passed (`29 passed; 0 failed; 9 ignored`, including the new `indirect::tests::card_runs_wide_indirect_dispatches` verified directly on RTX 5090 hardware) with 0 compiler warnings. Great NVIDIA wide indirect-dispatch (>65,535 groups) fix verified on hardware. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Exopus-0x65f7ad0 on GitHub · 2026-11-28 13:39 UTC · original

Ran the card test natively on another architecture: RTX 5060 Ti 8 GB (Blackwell, 10de:2d04), Windows 11 26300, native D3D12. 63b902f + this PR, release.

cargo test --release --locked -p victory-gpu --lib indirect::tests::card_runs_wide_indirect_dispatches -- --exact --nocapture → passed, in 1.53 s.

I added a local eprintln! after the test's early returns, because WarpHarness::on(false) / runs_wide returning early would also show as "ok". It printed runs on the card, widest=1048576, so the 67,440 / 115,200 / 2^20 / 2^20+1 cases really did run on the NVIDIA card, batched and unbatched, and every group was counted once.

One note for the description: D3D12 itself caps dispatches at D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION = 65,535. The 2^31 − 1 figure is the Vulkan limit (maxComputeWorkGroupCount[0]) on NVIDIA. So this relies on NVIDIA's driver accepting more than the D3D12 spec allows, which it does on Blackwell here (and on Ada per your 4070 SUPER). The VICTORY_INDIRECT_WIDE=0 escape hatch seems worth keeping for that reason.

**@⁠Exopus-0x65f7ad0** on GitHub · 2026-11-28 13:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1005#issuecomment-7240095302) Ran the card test natively on another architecture: RTX 5060 Ti 8 GB (Blackwell, `10de:2d04`), Windows 11 26300, native D3D12. `63b902f` + this PR, release. `cargo test --release --locked -p victory-gpu --lib indirect::tests::card_runs_wide_indirect_dispatches -- --exact --nocapture` → **passed**, in 1.53 s. I added a local `eprintln!` after the test's early returns, because `WarpHarness::on(false)` / `runs_wide` returning early would also show as "ok". It printed `runs on the card, widest=1048576`, so the 67,440 / 115,200 / 2^20 / 2^20+1 cases really did run on the NVIDIA card, batched and unbatched, and every group was counted once. One note for the description: D3D12 itself caps dispatches at `D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION` = 65,535. The `2^31 − 1` figure is the Vulkan limit (`maxComputeWorkGroupCount[0]`) on NVIDIA. So this relies on NVIDIA's driver accepting more than the D3D12 spec allows, which it does on Blackwell here (and on Ada per your 4070 SUPER). The `VICTORY_INDIRECT_WIDE=0` escape hatch seems worth keeping for that reason.
Author
Owner

@⁠upipibi on GitHub · 2026-11-28 19:55 UTC · original

Tested on Ampere: RTX 3070 (10de:2484), driver 616.56, Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile.

  • Head 6235b60c5. The base 63b902f is 76 commits behind main 32ecacfae, so I merged it onto 32ecacfae locally (--no-ff, clean, merge f1c4ec0). indirect.rs is the only file that changes.
  • Main has since moved on to 923e38cc8. See the re-check at the end.

indirect::tests::card_runs_wide_indirect_dispatches

cargo test -p victory-gpu --lib --locked indirect::tests::card_runs_wide_indirect_dispatches -- --exact --nocapture
VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --locked --features diagnostics <same> -- --exact --nocapture
  • Hardware, 3 runs: 1 passed, 0 failed, 0 ignored each (0.35 to 0.37 s).
  • With VICTORY_D3D12_WARP=1 and diagnostics, 3 runs: 1 passed, 0 failed, 0 ignored each.
  • That switch does not reach this test. WarpHarness::on(false) always opens adapter 0, so these runs were also on the 3070, not on WARP.

I added a temporary eprintln! after the early returns, then removed it. It printed adapter 'NVIDIA GeForce RTX 3070' vendor 0x10de, runs_wide=true, widest(true)=1048576, and the body ran in both settings. Every case came back exact, batched and unbatched (count, max group, max thread):

asked read back
67,440 67440, 67439, 67439
115,200 115200, 115199, 115199
1,048,576 1048576, 1048575, 1048575
1,048,577 65535, 65534, 65534

The per-group check (every group once) passed for each case.

With VICTORY_INDIRECT_WIDE=0 the test still shows as passed, but it returns early: widest(true)=65535, and no dispatch runs.

Negative control

I reverted only the make_from line to widest(amd(device)) and kept the test and the runs_wide/vendor helpers it calls (git diff --stat against the PR: 1 line in indirect.rs). Over 3 runs on hardware it failed every time, at the same place:

indirect.rs:3040:17: assertion `left == right` failed: asked for 67440, batched false
  left: [65535, 65534, 65534]
 right: [67440, 67439, 67439]

So on Ampere the clamp at 65,535 drops the last 1,905 groups, and the PR runs all of them.

cargo test -p victory-gpu --lib --locked (PR merged onto 32ecacfae, hardware)

  • 3 runs: 477 passed, 0 failed, 37 ignored, the same as main 32ecacfae on this card.
  • 1 more run: 476 passed, 1 failed, 37 ignored. The failure was watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view (watch.rs:4650, left: Some([26361745]) right: Some([])). That is a CPU page-guard test, not in this diff. Run alone it passed 5 of 5 on this tree and 5 of 5 on main, so it looks intermittent.
  • With --features diagnostics and VICTORY_D3D12_WARP=1: 529/1/37 twice, and 528/2/37 once.
    • The constant failure is pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws, which also fails on main under WARP.
    • The extra one was timeline::report::tests::real_waits_are_recorded_with_who_ended_them, a timing test. It passed 3 of 3 on rerun.

Re-checked on the current main 923e38cc8 (188 commits later; indirect.rs changed there with #851): this head merges cleanly onto it. The test then passes in 2 of 2 runs on the 3070. With only the widest(runs_wide(device)) line set back to widest(amd(device)), it fails the same way: asked for 67440, batched false, left [65535, 65534, 65534], right [67440, 67439, 67439].

Not tested

  • The test on real WARP (the harness does not offer it).
  • The game, or any CS_FinalGather capture.
  • A release build, clippy, the rest of the workspace on 923e38cc8 (only this test and its control were re-run there).

Upstream Marvisak/VIctory#2312 takes on the same 65,535 limit another way (it spreads dispatches across z).

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

**@⁠upipibi** on GitHub · 2026-11-28 19:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1005#issuecomment-7244901909) Tested on Ampere: RTX 3070 (`10de:2484`), driver 616.56, Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile. - Head `6235b60c5`. The base `63b902f` is 76 commits behind main `32ecacfae`, so I merged it onto `32ecacfae` locally (`--no-ff`, clean, merge `f1c4ec0`). `indirect.rs` is the only file that changes. - Main has since moved on to `923e38cc8`. See the re-check at the end. **`indirect::tests::card_runs_wide_indirect_dispatches`** ``` cargo test -p victory-gpu --lib --locked indirect::tests::card_runs_wide_indirect_dispatches -- --exact --nocapture VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --locked --features diagnostics <same> -- --exact --nocapture ``` - Hardware, 3 runs: 1 passed, 0 failed, 0 ignored each (0.35 to 0.37 s). - With `VICTORY_D3D12_WARP=1` and `diagnostics`, 3 runs: 1 passed, 0 failed, 0 ignored each. - That switch does not reach this test. `WarpHarness::on(false)` always opens adapter 0, so these runs were also on the 3070, not on WARP. I added a temporary `eprintln!` after the early returns, then removed it. It printed `adapter 'NVIDIA GeForce RTX 3070' vendor 0x10de, runs_wide=true, widest(true)=1048576`, and the body ran in both settings. Every case came back exact, batched and unbatched (count, max group, max thread): | asked | read back | |---|---| | 67,440 | 67440, 67439, 67439 | | 115,200 | 115200, 115199, 115199 | | 1,048,576 | 1048576, 1048575, 1048575 | | 1,048,577 | 65535, 65534, 65534 | The per-group check (`every group once`) passed for each case. With `VICTORY_INDIRECT_WIDE=0` the test still shows as passed, but it returns early: `widest(true)=65535`, and no dispatch runs. **Negative control** I reverted only the `make_from` line to `widest(amd(device))` and kept the test and the `runs_wide`/`vendor` helpers it calls (`git diff --stat` against the PR: 1 line in `indirect.rs`). Over 3 runs on hardware it failed every time, at the same place: ``` indirect.rs:3040:17: assertion `left == right` failed: asked for 67440, batched false left: [65535, 65534, 65534] right: [67440, 67439, 67439] ``` So on Ampere the clamp at 65,535 drops the last 1,905 groups, and the PR runs all of them. **`cargo test -p victory-gpu --lib --locked`** (PR merged onto `32ecacfae`, hardware) - 3 runs: 477 passed, 0 failed, 37 ignored, the same as main `32ecacfae` on this card. - 1 more run: 476 passed, 1 failed, 37 ignored. The failure was `watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view` (`watch.rs:4650`, `left: Some([26361745]) right: Some([])`). That is a CPU page-guard test, not in this diff. Run alone it passed 5 of 5 on this tree and 5 of 5 on main, so it looks intermittent. - With `--features diagnostics` and `VICTORY_D3D12_WARP=1`: 529/1/37 twice, and 528/2/37 once. - The constant failure is `pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws`, which also fails on main under WARP. - The extra one was `timeline::report::tests::real_waits_are_recorded_with_who_ended_them`, a timing test. It passed 3 of 3 on rerun. Re-checked on the current `main` `923e38cc8` (188 commits later; `indirect.rs` changed there with #851): this head merges cleanly onto it. The test then passes in 2 of 2 runs on the 3070. With only the `widest(runs_wide(device))` line set back to `widest(amd(device))`, it fails the same way: `asked for 67440, batched false`, left `[65535, 65534, 65534]`, right `[67440, 67439, 67439]`. **Not tested** - The test on real WARP (the harness does not offer it). - The game, or any `CS_FinalGather` capture. - A release build, clippy, the rest of the workspace on `923e38cc8` (only this test and its control were re-run there). Upstream Marvisak/VIctory#2312 takes on the same 65,535 limit another way (it spreads dispatches across z). AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
github manually merged commit aec28b3089 into main 2026-11-29 08:22:11 +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!1005
No description provided.