GPU: add opt-in VICTORY_BURY_LAG for delayed resource retirement #3473

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

@⁠pushkarreddyy on GitHub · 2026-11-27 04:34 UTC · original
pushkarreddyy:perf/gpu-bury-lag → main · +96 −10 · 1 files · 1 commits · open

Summary

Adds opt-in VICTORY_BURY_LAG (default 0) to delay releasing retired host ID3D12Resource objects for N additional completed submissions via a VecDeque lag queue in crates/victory-gpu/src/host.rs.

Motivation

By default (VICTORY_BURY_LAG=0), release_retired() continues to release retired host resources immediately after the completed submission, preserving existing memory behavior. When VICTORY_BURY_LAG=N is set, retired resources remain alive for N extra submissions before release_later drops them on the background release thread, helping diagnose or avoid late GPU reads when title threads rewrite descriptors across submissions.

Changes

  • crates/victory-gpu/src/host.rs:
    • Added bury_lag() reading VICTORY_BURY_LAG (default 0).
    • Replaced RETIRED: Mutex<Vec<ID3D12Resource>> with Retired<T> (pending: Vec<T>, lagging: VecDeque<Vec<T>>) and Retired::drain_ready(lag).
    • Updated retire and release_retired to respect bury_lag().
    • Added unit tests retired_resources_release_immediately_when_lag_is_zero and retired_resources_wait_for_bury_lag_submissions.

Testing & Verification

  • Added CPU-only unit tests for both lag = 0 and lag > 0 behavior.
  • Testers on untested GPU models and drivers are welcome to test with VICTORY_BURY_LAG=64 as well as default 0.

No game files used.

AI-assisted: yes (Gemini 4 Neon)

**@⁠pushkarreddyy** on GitHub · 2026-11-27 04:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/3473) `pushkarreddyy:perf/gpu-bury-lag` → `main` · +96 −10 · 1 files · 1 commits · open ## Summary Adds opt-in `VICTORY_BURY_LAG` (default `0`) to delay releasing `retire`d host `ID3D12Resource` objects for `N` additional completed submissions via a `VecDeque` lag queue in `crates/victory-gpu/src/host.rs`. ## Motivation By default (`VICTORY_BURY_LAG=0`), `release_retired()` continues to release retired host resources immediately after the completed submission, preserving existing memory behavior. When `VICTORY_BURY_LAG=N` is set, retired resources remain alive for `N` extra submissions before `release_later` drops them on the background release thread, helping diagnose or avoid late GPU reads when title threads rewrite descriptors across submissions. ## Changes - `crates/victory-gpu/src/host.rs`: - Added `bury_lag()` reading `VICTORY_BURY_LAG` (default `0`). - Replaced `RETIRED: Mutex<Vec<ID3D12Resource>>` with `Retired<T>` (`pending: Vec<T>`, `lagging: VecDeque<Vec<T>>`) and `Retired::drain_ready(lag)`. - Updated `retire` and `release_retired` to respect `bury_lag()`. - Added unit tests `retired_resources_release_immediately_when_lag_is_zero` and `retired_resources_wait_for_bury_lag_submissions`. ## Testing & Verification - Added CPU-only unit tests for both `lag = 0` and `lag > 0` behavior. - Testers on untested GPU models and drivers are welcome to test with `VICTORY_BURY_LAG=64` as well as default `0`. No game files used. AI-assisted: yes (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 04:36:56 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 04:46 UTC · original

WARP test report (victory-gpu, --features diagnostics --lib --locked --no-fail-fast -- --test-threads=1)

OS: Windows 11 Pro 10.0.26200 (build 26200.9974), x64
Host adapter: WARP only (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1; d3d10warp.dll 10.0.26100.9818); no physical GPU used. victory-gpu only honours VICTORY_D3D12_WARP with the diagnostics feature, so the run uses it; a test that prints its adapter reported "Microsoft Basic Render Driver".
dxil.dll: Windows SDK 10.0.26100.0, version 1.8.2502.11 (via VICTORY_DXIL)
rustc/cargo: 1.98.1 (48a229cea 2026-09-01)
Base: main 63bcca43c6
Head: d611cfaf13 (fast-forwards onto main, no conflicts, 1 file)

pass fail ignored
main 246 0 1
main + PR 248 0 1
  • 2 new tests, both run and pass (none ignored or skipped): host::present_plane_tests::retired_resources_release_immediately_when_lag_is_zero, host::present_plane_tests::retired_resources_wait_for_bury_lag_submissions. They test the queue with plain integers, not real resources. No other test changed result.

Review note (diff read):

  • Opt-in holds: bury_lag() is 0 when VICTORY_BURY_LAG is unset or does not parse. With 0, drain_ready returns the pending resources as one batch and the lagging queue stays empty, so what is released and when is the same as before (the only change is that release_later now gets a Vec of batches instead of a Vec of resources, which is dropped the same way).
  • With a lag of N, the batch from each submission is held for N more submissions. Nothing flushes what is still queued at shutdown, which is harmless in a process that is exiting.
  • The value is read once (OnceLock), so changing it needs a restart. The retire reformat is whitespace only.
  • No bugs found.

AI-assisted (Claude). Aggregate counts only; no game files used.

**@⁠oni-swr** on GitHub · 2026-11-27 04:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/3473#issuecomment-7210084802) **WARP test report** (`victory-gpu`, `--features diagnostics --lib --locked --no-fail-fast -- --test-threads=1`) OS: Windows 11 Pro 10.0.26200 (build 26200.9974), x64 Host adapter: WARP only (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1; d3d10warp.dll 10.0.26100.9818); no physical GPU used. `victory-gpu` only honours `VICTORY_D3D12_WARP` with the `diagnostics` feature, so the run uses it; a test that prints its adapter reported "Microsoft Basic Render Driver". dxil.dll: Windows SDK 10.0.26100.0, version 1.8.2502.11 (via VICTORY_DXIL) rustc/cargo: 1.98.1 (48a229cea 2026-09-01) Base: main 63bcca43c6a0 Head: d611cfaf13db (fast-forwards onto main, no conflicts, 1 file) | | pass | fail | ignored | |---|---|---|---| | main | 246 | 0 | 1 | | main + PR | 248 | 0 | 1 | - 2 new tests, both run and pass (none ignored or skipped): `host::present_plane_tests::retired_resources_release_immediately_when_lag_is_zero`, `host::present_plane_tests::retired_resources_wait_for_bury_lag_submissions`. They test the queue with plain integers, not real resources. No other test changed result. Review note (diff read): - Opt-in holds: `bury_lag()` is 0 when `VICTORY_BURY_LAG` is unset or does not parse. With 0, `drain_ready` returns the pending resources as one batch and the lagging queue stays empty, so what is released and when is the same as before (the only change is that `release_later` now gets a `Vec` of batches instead of a `Vec` of resources, which is dropped the same way). - With a lag of N, the batch from each submission is held for N more submissions. Nothing flushes what is still queued at shutdown, which is harmless in a process that is exiting. - The value is read once (`OnceLock`), so changing it needs a restart. The `retire` reformat is whitespace only. - No bugs found. AI-assisted (Claude). Aggregate counts only; no game files used.
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-27 05:17 UTC · original · edited 2026-11-27 06:54 UTC

@⁠oni-swr Thank you for the WARP verification (248 passed, 0 failed, 1 ignored) and diff review!

@⁠Marvisak Please review and merge this PR when convenient (CI is green). Testers on untested GPU models and drivers are welcome to test both default VICTORY_BURY_LAG=0 and VICTORY_BURY_LAG=64.

AI-assisted: yes (Gemini 4 Neon)

**@⁠pushkarreddyy** on GitHub · 2026-11-27 05:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3473#issuecomment-7210517402) · edited 2026-11-27 06:54 UTC @⁠oni-swr Thank you for the WARP verification (`248 passed, 0 failed, 1 ignored`) and diff review! @⁠Marvisak Please review and merge this PR when convenient (CI is green). Testers on untested GPU models and drivers are welcome to test both default `VICTORY_BURY_LAG=0` and `VICTORY_BURY_LAG=64`. AI-assisted: yes (Gemini 4 Neon)
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 09:30 UTC · original

Independent verification of PR #3473 (CPU-only, synthetic inputs, no game data).

Windows / Rust 1.100.0 / MSVC, per-worktree CARGO_TARGET_DIR=D:\Victory-Contrib\target-3473-verify, CARGO_BUILD_JOBS=2.

Head d611cfa, base/merge base 63bcca4. The two new tests are gated by #[cfg(all(test, feature = "diagnostics"))] in crates/victory-gpu/src/host.rs (module host::present_plane_tests), so the feature flag and the full module path are required.

Commands and results:

  • cargo test --locked -p victory-gpu --lib --features diagnostics -- host::present_plane_tests::retired_resources_release_immediately_when_lag_is_zero --exact --test-threads=1 --quiet -> 1 passed, 0 failed, 248 filtered, exit 0.
  • cargo test --locked -p victory-gpu --lib --features diagnostics -- host::present_plane_tests::retired_resources_wait_for_bury_lag_submissions --exact --test-threads=1 --quiet -> 1 passed, 0 failed, 248 filtered, exit 0.
  • git grep -F <test name> 63bcca4 -- crates/victory-gpu/src/host.rs -> no hits (both tests new on this PR).
  • git diff --check 63bcca4 HEAD -> clean.

Notes: only the two named synthetic tests were replayed; full crate suite not run. Only pre-existing fetch_update deprecation warnings. GPU/driver N/A for these CPU-only tests. AI-assisted (Hy4 flash). No game data or extracted assets used.

**@⁠cloph-dsp** on GitHub · 2026-11-27 09:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3473#issuecomment-7214766527) Independent verification of PR #3473 (CPU-only, synthetic inputs, no game data). Windows / Rust 1.100.0 / MSVC, per-worktree CARGO_TARGET_DIR=D:\Victory-Contrib\target-3473-verify, CARGO_BUILD_JOBS=2. Head d611cfa, base/merge base 63bcca4. The two new tests are gated by `#[cfg(all(test, feature = "diagnostics"))]` in crates/victory-gpu/src/host.rs (module `host::present_plane_tests`), so the feature flag and the full module path are required. Commands and results: - `cargo test --locked -p victory-gpu --lib --features diagnostics -- host::present_plane_tests::retired_resources_release_immediately_when_lag_is_zero --exact --test-threads=1 --quiet` -> 1 passed, 0 failed, 248 filtered, exit 0. - `cargo test --locked -p victory-gpu --lib --features diagnostics -- host::present_plane_tests::retired_resources_wait_for_bury_lag_submissions --exact --test-threads=1 --quiet` -> 1 passed, 0 failed, 248 filtered, exit 0. - `git grep -F <test name> 63bcca4 -- crates/victory-gpu/src/host.rs` -> no hits (both tests new on this PR). - `git diff --check 63bcca4 HEAD` -> clean. Notes: only the two named synthetic tests were replayed; full crate suite not run. Only pre-existing `fetch_update` deprecation warnings. GPU/driver N/A for these CPU-only tests. AI-assisted (Hy4 flash). No game data or extracted assets used.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-27 10:35 UTC · original

NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head d611cfa (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 866 passed, 0 failed, 10 ignored.
  • retired_resources_release_immediately_when_lag_is_zero, retired_resources_wait_for_bury_lag_submissions only build with the diagnostics feature, so the run above doesn't include them; they pass in cargo test -p victory-core -p victory-gpu -p victory-hle -p victory-loader -p victory-shader -p victory --lib --locked --features victory-core/diagnostics,victory-gpu/diagnostics,victory-hle/diagnostics,victory-loader/diagnostics,victory-shader/diagnostics,victory/diagnostics (same skips).
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-27 10:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3473#issuecomment-7216073595) NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head `d611cfa` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **866 passed, 0 failed, 10 ignored**. - `retired_resources_release_immediately_when_lag_is_zero`, `retired_resources_wait_for_bury_lag_submissions` only build with the `diagnostics` feature, so the run above doesn't include them; they pass in `cargo test -p victory-core -p victory-gpu -p victory-hle -p victory-loader -p victory-shader -p victory --lib --locked --features victory-core/diagnostics,victory-gpu/diagnostics,victory-hle/diagnostics,victory-loader/diagnostics,victory-shader/diagnostics,victory/diagnostics` (same skips). - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3473/head:github-bot/gh-3473'
git switch 'github-bot/gh-3473'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3473'
git switch 'github-bot/gh-3473'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3473'
git switch 'github-bot/gh-3473'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3473'
git switch 'main'
git merge --squash 'github-bot/gh-3473'
git switch 'main'
git merge --ff-only 'github-bot/gh-3473'
git switch 'main'
git merge 'github-bot/gh-3473'
git push origin 'main'
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/Marvisak--VIctory!3473
No description provided.