GPU/indirect: gate diagnostic budget atomics and readbacks behind diagnostics feature #793

Open
github-bot wants to merge 1 commit from github-bot/gh-793 into main AGit
Owner

@⁠im-a-cat on GitHub · 2026-11-25 07:53 UTC · original
im-a-cat:perf/indirect-release-no-diag-atomics → main · +124 −23 · 2 files · 1 commits · open

Why

On current main (9376fd6), the indirect argument clamp compute shader (indirect::SOURCE) unconditionally executes 4 extra global atomic operations (budget.InterlockedMax / budget.InterlockedAdd at byte offsets 4, 8, 12, and 16) on every indirect compute and mesh record to collect frame diagnostics, and HostList::budget() / frame_line() always read, clear, and log MESH_GROUPS and COMPUTE_GROUPS even in non-diagnostics (release) builds — while the rest of indirect.rs (IndirectBounded, barrier_test) is already gated on #[cfg(feature = "diagnostics")].

Because world frames run ~6,700 indirect calls per frame, removing these diagnostic-only atomics and per-list volatile readbacks from non-diagnostics builds reduces unnecessary global atomic contention and mapped-buffer work without altering clamping, budgeting, or diagnostics-profile telemetry.

What

  • crates/victory-gpu/src/indirect.rs:
    • Adds clamp_source(diagnostics: bool) and make_for_with(device, diagnostics) passing #define VICTORY_DIAGNOSTICS 0/1 to D3DCompile.
    • Guards the diagnostic budget.InterlockedMax / InterlockedAdd writes at offsets 4, 8, 12, 16 under #if VICTORY_DIAGNOSTICS.
    • Uses cfg!(feature = "diagnostics") in make_for(), keeps WarpHarness::new() testing the diagnostics path (true) for existing mesh telemetry assertions, and adds a new WARP test warp_release_clamp_skips_diagnostic_atomics_and_keeps_bounds covering diagnostics = false (verifying both compute > 65535 clamping and mesh budget[0] tracking while budget[1..=4] stay zero).
  • crates/victory-gpu/src/host.rs:
    • Gates MESH_GROUPS, COMPUTE_GROUPS, reading/clearing words.add(1..=4) in HostList::budget() (still zeroing words.write_volatile(0) for the real budget counter), and the two diagnostic log lines under #[cfg(feature = "diagnostics")].

Verification

  • cargo xtask policy: asset policy: 171 files ok
  • cargo clippy -p victory-gpu --lib --tests and --features diagnostics: clean in indirect.rs and host.rs
  • cargo test -p victory-gpu --lib --features diagnostics --locked and cargo test --workspace --locked: 0 failures across all crates (victory-gpu passes with both default and --features diagnostics, including warp_release_clamp_skips_diagnostic_atomics_and_keeps_bounds on WARP).
**@⁠im-a-cat** on GitHub · 2026-11-25 07:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/793) `im-a-cat:perf/indirect-release-no-diag-atomics` → `main` · +124 −23 · 2 files · 1 commits · open ## Why On current `main` (`9376fd6`), the indirect argument clamp compute shader (`indirect::SOURCE`) unconditionally executes 4 extra global atomic operations (`budget.InterlockedMax` / `budget.InterlockedAdd` at byte offsets 4, 8, 12, and 16) on every indirect compute and mesh record to collect frame diagnostics, and `HostList::budget()` / `frame_line()` always read, clear, and log `MESH_GROUPS` and `COMPUTE_GROUPS` even in non-diagnostics (`release`) builds — while the rest of `indirect.rs` (`IndirectBounded`, `barrier_test`) is already gated on `#[cfg(feature = "diagnostics")]`. Because world frames run ~6,700 indirect calls per frame, removing these diagnostic-only atomics and per-list volatile readbacks from non-diagnostics builds reduces unnecessary global atomic contention and mapped-buffer work without altering clamping, budgeting, or `diagnostics`-profile telemetry. ## What - **`crates/victory-gpu/src/indirect.rs`**: - Adds `clamp_source(diagnostics: bool)` and `make_for_with(device, diagnostics)` passing `#define VICTORY_DIAGNOSTICS 0/1` to `D3DCompile`. - Guards the diagnostic `budget.InterlockedMax` / `InterlockedAdd` writes at offsets `4, 8, 12, 16` under `#if VICTORY_DIAGNOSTICS`. - Uses `cfg!(feature = "diagnostics")` in `make_for()`, keeps `WarpHarness::new()` testing the diagnostics path (`true`) for existing mesh telemetry assertions, and adds a new WARP test `warp_release_clamp_skips_diagnostic_atomics_and_keeps_bounds` covering `diagnostics = false` (verifying both compute `> 65535` clamping and mesh `budget[0]` tracking while `budget[1..=4]` stay zero). - **`crates/victory-gpu/src/host.rs`**: - Gates `MESH_GROUPS`, `COMPUTE_GROUPS`, reading/clearing `words.add(1..=4)` in `HostList::budget()` (still zeroing `words.write_volatile(0)` for the real budget counter), and the two diagnostic log lines under `#[cfg(feature = "diagnostics")]`. ## Verification - `cargo xtask policy`: `asset policy: 171 files ok` - `cargo clippy -p victory-gpu --lib --tests` and `--features diagnostics`: clean in `indirect.rs` and `host.rs` - `cargo test -p victory-gpu --lib --features diagnostics --locked` and `cargo test --workspace --locked`: 0 failures across all crates (`victory-gpu` passes with both default and `--features diagnostics`, including `warp_release_clamp_skips_diagnostic_atomics_and_keeps_bounds` on WARP).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:17 +00:00
Author
Owner

@⁠timorjay on GitHub · 2026-11-25 09:44 UTC · original

Release-build comparison on an RTX 5090 D v2 (24 GB), NVIDIA 617.42, Ryzen 7 9800X3D, Windows Sandbox on Windows 11 Pro build 26300.

I built the exact PR head c4d5ca5a and base 9376fd60 with the same toolchain, without the diagnostics feature. All three runs used the Series X profile and default switches. The patched run came between the two base runs.

Each launch restored a separate copy of the same local checkpoint and started with its own empty VIctory cache. The Windows graphics driver cache was shared across the runs. I left the camera at the prison window for 90 seconds, beginning 20 seconds after the movement tutorial became visible, then backed up and turned to inspect Lucia in the window light. The reported FPS is the median of 1000 / the game window's ms per frame, sampled about once every 1.2 seconds.

Build Median FPS (P10–P90) Median time on GPU Median draws/frame Mesh-group counter reports in 90 s
Base, first launch 3.27 (3.14–3.49) 141.5 ms 4948.0 75
PR head 3.44 (3.35–3.53) 133.0 ms 4980.0 0
Base, second launch 3.42 (3.37–3.49) 140.0 ms 4978.0 77

The expected counter lines disappeared from the release build. The P10–P90 FPS interval overlaps those of both base runs. With one patched run I can't separate a small speed change from ordinary run-to-run variation. The same movement and camera inputs worked on all three, with no device-removal message before I stopped each observation.

Measured on my hardware with Codex assistance.

**@⁠timorjay** on GitHub · 2026-11-25 09:44 UTC · [original](https://github.com/fxceless/victory-fork/pull/793#issuecomment-7158741001) Release-build comparison on an RTX 5090 D v2 (24 GB), NVIDIA 617.42, Ryzen 7 9800X3D, Windows Sandbox on Windows 11 Pro build 26300. I built the exact PR head `c4d5ca5a` and base `9376fd60` with the same toolchain, without the diagnostics feature. All three runs used the Series X profile and default switches. The patched run came between the two base runs. Each launch restored a separate copy of the same local checkpoint and started with its own empty VIctory cache. The Windows graphics driver cache was shared across the runs. I left the camera at the prison window for 90 seconds, beginning 20 seconds after the movement tutorial became visible, then backed up and turned to inspect Lucia in the window light. The reported FPS is the median of 1000 / the game window's ms per frame, sampled about once every 1.2 seconds. | Build | Median FPS (P10–P90) | Median time on GPU | Median draws/frame | Mesh-group counter reports in 90 s | |---|---:|---:|---:|---:| | Base, first launch | 3.27 (3.14–3.49) | 141.5 ms | 4948.0 | 75 | | PR head | 3.44 (3.35–3.53) | 133.0 ms | 4980.0 | 0 | | Base, second launch | 3.42 (3.37–3.49) | 140.0 ms | 4978.0 | 77 | The expected counter lines disappeared from the release build. The P10–P90 FPS interval overlaps those of both base runs. With one patched run I can't separate a small speed change from ordinary run-to-run variation. The same movement and camera inputs worked on all three, with no device-removal message before I stopped each observation. Measured on my hardware with Codex assistance.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 10:20 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head c4d5ca5 into main 9376fd6 in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins never used, depth_written never read, in victory-gpu); with --all-features it fails with the same number of errors as main (4). This PR adds none and removes none. cargo test --workspace --locked: 541 passed, 0 failed, 10 ignored, two runs (main alone: 540 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 10:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/793#issuecomment-7159560533) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `c4d5ca5` into `main` `9376fd6` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with exactly the errors `main` itself has on this machine (`placed_filler_twins` never used, `depth_written` never read, in `victory-gpu`); with `--all-features` it fails with the same number of errors as `main` (4). This PR adds none and removes none. `cargo test --workspace --locked`: 541 passed, 0 failed, 10 ignored, two runs (`main` alone: 540 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
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/793/head:github-bot/gh-793'
git switch 'github-bot/gh-793'

Merge

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