Diagnostics: preserve the world capture draw count #2589

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 16:19 UTC · original
andrewpozdnakov7-jpg:codex2/capture-world-draw-order → main · +16 −3 · 1 files · 1 commits · open

VICTORY_CAPTURE_WORLD picks the first frame that reaches 500 host draws. If two calls to Present sample the cumulative counter and the older sample is processed later, that sample can lower the stored counter. The next frame then counts some of the same draws again.

Keep the greatest draw count seen so far and return zero for an older sample. The same synthetic sequence on 67e8ae1 reports 515 draws after the stale sample and crosses the threshold early. The patch reports 395 on that frame and still reports exactly 500 on the next one.

All three diagnostics capture tests, strict GPU Clippy, and staged asset policy pass. The change touches the world-capture counter. #2340 covers the counters in the log line.

Coordination claim

If you cherry-pick or rebase this commit, please retain its Git author. If you fold the change into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted. Verification used synthetic draw counts.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2589) `andrewpozdnakov7-jpg:codex2/capture-world-draw-order` → `main` · +16 −3 · 1 files · 1 commits · open `VICTORY_CAPTURE_WORLD` picks the first frame that reaches 500 host draws. If two calls to `Present` sample the cumulative counter and the older sample is processed later, that sample can lower the stored counter. The next frame then counts some of the same draws again. Keep the greatest draw count seen so far and return zero for an older sample. The same synthetic sequence on `67e8ae1` reports 515 draws after the stale sample and crosses the threshold early. The patch reports 395 on that frame and still reports exactly 500 on the next one. All three diagnostics capture tests, strict GPU Clippy, and staged asset policy pass. The change touches the world-capture counter. #2340 covers the counters in the log line. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) If you cherry-pick or rebase this commit, please retain its Git author. If you fold the change into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted. Verification used synthetic draw counts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:52 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:20 UTC · original

Automated triage for the maintainers.

Merge candidate (small, diagnostics only). capture::presented counted draws since the last present with LAST.swap(drawn). If two presents race and the older sample is stored last, LAST moves backwards and the next frame counts some draws twice, so VICTORY_CAPTURE_WORLD can pick its first world frame too early. fetch_max plus saturating_sub keeps LAST monotonic and gives an older sample zero. The test walks the PR's sequence. The impact is small: it only affects which frame the diagnostics capture counts from. The change is correct by my reading and cannot affect release builds.

A nit for the author or maintainer: the #[test] sits at module level in capture.rs rather than in its tests module.

CI: check passing. Merges cleanly into current main. A recommendation to look at it, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2589#issuecomment-7176237630) <!-- victory-triage v1 head=94190ff21061a0daec703af6721991698197d933 verdict=merge-candidate at=2026-11-25T22:20:12Z --> Automated triage for the maintainers. **Merge candidate (small, diagnostics only).** `capture::presented` counted draws since the last present with `LAST.swap(drawn)`. If two presents race and the older sample is stored last, `LAST` moves backwards and the next frame counts some draws twice, so `VICTORY_CAPTURE_WORLD` can pick its first world frame too early. `fetch_max` plus `saturating_sub` keeps `LAST` monotonic and gives an older sample zero. The test walks the PR's sequence. The impact is small: it only affects which frame the diagnostics capture counts from. The change is correct by my reading and cannot affect release builds. A nit for the author or maintainer: the `#[test]` sits at module level in `capture.rs` rather than in its `tests` module. CI: `check` passing. Merges cleanly into current `main`. A recommendation to look at it, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 00:57 UTC · original

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 94190ff (on its base 67e8ae1).

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: 773 passed, 0 failed, 9 ignored.
  • stale_draw_samples_do_not_trigger_world_capture_early only builds with the diagnostics feature, so the run above doesn't include it; it passes in cargo test -p victory-gpu --lib --locked --features 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-26 00:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2589#issuecomment-7179281476) Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `94190ff` (on its base `67e8ae1`). **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`: **773 passed, 0 failed, 9 ignored**. - `stale_draw_samples_do_not_trigger_world_capture_early` only builds with the `diagnostics` feature, so the run above doesn't include it; it passes in `cargo test -p victory-gpu --lib --locked --features 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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:20 UTC · original · approved these changes

Reviewed 94190ff21061a0daec703af6721991698197d933 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer.

Audit

  • crates/victory-gpu/src/capture.rs:48, :57, :62: replacing LAST.swap(drawn, Relaxed) with drawn.saturating_sub(last.fetch_max(drawn, Relaxed)) keeps LAST monotonically non-decreasing across concurrent out-of-order Present samples, returning 0 for stale samples and preventing double-counted draws from triggering VICTORY_CAPTURE_WORLD early. Diagnostics-only (capture is gated by feature = "diagnostics").

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features)
  • victory-gpu capture:: (--features diagnostics, VICTORY_D3D12_DEBUG=1): 12/12 passed on RTX 5090; 12/12 passed on WARP (including stale_draw_samples_do_not_trigger_world_capture_early).
  • Additional 8-thread concurrency stress probe interleaving 32,000 rising and stale samples verified exact monotonicity with zero double counting (max_seen == summed == 20004).
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2589#pullrequestreview-6077453874) · **approved these changes** Reviewed `94190ff21061a0daec703af6721991698197d933` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer. ### Audit - `crates/victory-gpu/src/capture.rs:48`, `:57`, `:62`: replacing `LAST.swap(drawn, Relaxed)` with `drawn.saturating_sub(last.fetch_max(drawn, Relaxed))` keeps `LAST` monotonically non-decreasing across concurrent out-of-order `Present` samples, returning `0` for stale samples and preventing double-counted draws from triggering `VICTORY_CAPTURE_WORLD` early. Diagnostics-only (`capture` is gated by `feature = "diagnostics"`). ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default & `--all-features`) - `victory-gpu` `capture::` (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`): **12/12 passed** on RTX 5090; **12/12 passed** on WARP (including `stale_draw_samples_do_not_trigger_world_capture_early`). - Additional 8-thread concurrency stress probe interleaving 32,000 rising and stale samples verified exact monotonicity with zero double counting (`max_seen == summed == 20004`).
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 18:32 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Using fetch_max + saturating_sub in draws_since_last_present ensures a stale/out-of-order draw count sample cannot rewind LAST and falsely trigger the 500-draw world capture threshold.
  • cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1: 12 passed, 0 failed (including stale_draw_samples_do_not_trigger_world_capture_early).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default + --features diagnostics): clean.
  • cargo xtask policy: 191 files ok.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 18:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2589#pullrequestreview-6079016820) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Using `fetch_max` + `saturating_sub` in `draws_since_last_present` ensures a stale/out-of-order draw count sample cannot rewind `LAST` and falsely trigger the 500-draw world capture threshold. - `cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1`: 12 passed, 0 failed (including `stale_draw_samples_do_not_trigger_world_capture_early`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default + `--features diagnostics`): clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2589/head:github-bot/gh-2589'
git switch 'github-bot/gh-2589'

Merge

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