GPU diagnostics: pick capture frames by draw count #500

Closed
github-bot wants to merge 1 commit from github-bot/gh-500 into main AGit
Owner

@⁠itsRevela on GitHub · 2026-11-24 04:12 UTC · original
diag/capture-on-draws → main · +101 −2 · 4 files · 1 commits · closed without merging

What

A new diagnostics variable, VICTORY_CAPTURE_DRAWS=<draws>[,<frames>]. The first frame that records at least draws draws picks the frames frames after it (3 by default), exactly as if they were listed in VICTORY_CAPTURE_FRAMES. So with VICTORY_CAPTURE, their images are saved; with VICTORY_DUMP_TARGETS, their render targets too; and their draws are traced at debug level. The trigger fires once.

  • list.rs: a per-frame draw counter next to the existing one, which is only read at power-of-two frames.
  • queue.rs: at each present, the frame's count goes to capture::frame_recorded.
  • capture.rs: Trigger (parse and pick), plus the check in listed.
  • README.md: a row in the debugging table.

All of it is behind diagnostics.

Why

The frame number where a scene starts is not stable between runs. With the opening cutscene (#255, #325), the first heavy frame moved from about 2,850 to about 3,330 to about 3,960 across runs of the same build. Loading time and a cold or warm shader cache shift it by hundreds of frames.

So a VICTORY_CAPTURE_FRAMES list taken from one run misses the scene in the next. That's worse with the cutscene's GPU hang, which leaves only a few heavy frames to catch. A draw-count threshold finds the scene wherever it starts.

Tested

Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088) through Windows Sandbox's vGPU, Rust 1.98.1, on d2a4bae.

  • New unit tests:
    • capture::tests::the_draw_trigger_reads_a_count_and_an_optional_length covers parsing, including the rejected forms (0, 1000,0, extra fields, text).
    • capture::tests::the_draw_trigger_picks_the_frames_after_the_one_that_fired checks that nothing is picked before the trigger fires, and that exactly the next frames frames are picked after it.
  • cargo test -p victory-gpu --features diagnostics --lib capture passes (3 tests), and cargo test -p victory-gpu --lib passes (43 passed, 1 ignored).
  • cargo clippy -p victory-gpu --tests, with and without diagnostics: nothing in the changed files. The two unsafe block missing a safety comment warnings (host.rs) are already on main.
  • cargo fmt -p victory-gpu --check reports the same 79 diffs as main (#17), and none in the new code. cargo xtask policy is ok.
  • With the title, VICTORY_CAPTURE_DRAWS=1000,3:
    • The log read capture trigger: saving the frames after this one frame=3960 draws=16446 frames=3.
    • Frames 3961, 3962 and 3963 were saved, with 154, 199 and 199 render targets.
    • That was the opening cutscene, which the run's earlier frame-number list had missed.

AI-assisted (Claude Code). The title runs used my own copy; no game data is in this PR.

🤖 Generated with Claude Code

**@⁠itsRevela** on GitHub · 2026-11-24 04:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/500) `diag/capture-on-draws` → `main` · +101 −2 · 4 files · 1 commits · closed without merging ## What A new diagnostics variable, `VICTORY_CAPTURE_DRAWS=<draws>[,<frames>]`. The first frame that records at least `draws` draws picks the `frames` frames after it (3 by default), exactly as if they were listed in `VICTORY_CAPTURE_FRAMES`. So with `VICTORY_CAPTURE`, their images are saved; with `VICTORY_DUMP_TARGETS`, their render targets too; and their draws are traced at debug level. The trigger fires once. - `list.rs`: a per-frame draw counter next to the existing one, which is only read at power-of-two frames. - `queue.rs`: at each present, the frame's count goes to `capture::frame_recorded`. - `capture.rs`: `Trigger` (parse and pick), plus the check in `listed`. - `README.md`: a row in the debugging table. All of it is behind `diagnostics`. ## Why The frame number where a scene starts is not stable between runs. With the opening cutscene (#255, #325), the first heavy frame moved from about 2,850 to about 3,330 to about 3,960 across runs of the same build. Loading time and a cold or warm shader cache shift it by hundreds of frames. So a `VICTORY_CAPTURE_FRAMES` list taken from one run misses the scene in the next. That's worse with the cutscene's GPU hang, which leaves only a few heavy frames to catch. A draw-count threshold finds the scene wherever it starts. ## Tested Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088) through Windows Sandbox's vGPU, Rust 1.98.1, on `d2a4bae`. - New unit tests: - `capture::tests::the_draw_trigger_reads_a_count_and_an_optional_length` covers parsing, including the rejected forms (`0`, `1000,0`, extra fields, text). - `capture::tests::the_draw_trigger_picks_the_frames_after_the_one_that_fired` checks that nothing is picked before the trigger fires, and that exactly the next `frames` frames are picked after it. - `cargo test -p victory-gpu --features diagnostics --lib capture` passes (3 tests), and `cargo test -p victory-gpu --lib` passes (43 passed, 1 ignored). - `cargo clippy -p victory-gpu --tests`, with and without `diagnostics`: nothing in the changed files. The two `unsafe block missing a safety comment` warnings (`host.rs`) are already on `main`. - `cargo fmt -p victory-gpu --check` reports the same 79 diffs as `main` (#17), and none in the new code. `cargo xtask policy` is ok. - With the title, `VICTORY_CAPTURE_DRAWS=1000,3`: - The log read `capture trigger: saving the frames after this one frame=3960 draws=16446 frames=3`. - Frames 3961, 3962 and 3963 were saved, with 154, 199 and 199 render targets. - That was the opening cutscene, which the run's earlier frame-number list had missed. AI-assisted (Claude Code). The title runs used my own copy; no game data is in this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
VICTORY_CAPTURE_DRAWS=<draws>[,<frames>]: the first frame that records at
least that many draws picks the frames after it (3 by default), as if
they were listed in VICTORY_CAPTURE_FRAMES, so their images and render
targets are saved. Where a scene such as the opening cutscene starts
moves by hundreds of frames between runs (loading time, a warm shader
cache), so a frame number taken from one run misses it in the next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:06:14 +00:00
Author
Owner

@⁠ghost on GitHub · 2026-11-24 04:43 UTC · original

Tested be6df3a with the title on an RX 9060 XT (RDNA4), Windows 11: works. Merged onto d2a4bae + #135 + #365 (+ #318 #385 #346 #305); diag build.

  • VICTORY_CAPTURE_DRAWS=1000,4 with VICTORY_CAPTURE and VICTORY_DUMP_TARGETS=1: capture trigger: saving the frames after this one frame=2495 draws=16150 frames=4, then frames 2496–2499 were saved with 41, 252, 277 and 250 dumped targets.
  • Without it, fixed VICTORY_CAPTURE_FRAMES lists missed the world in two runs of the baseline (d2a4bae + #135 + #365): its first world frame was about 1215 in one and after 1400 in the other; here it was 2495.

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

**@⁠ghost** on GitHub · 2026-11-24 04:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/500#issuecomment-7122275573) Tested `be6df3a` with the title on an RX 9060 XT (RDNA4), Windows 11: **works**. Merged onto `d2a4bae` + #135 + #365 (+ #318 #385 #346 #305); diag build. - `VICTORY_CAPTURE_DRAWS=1000,4` with `VICTORY_CAPTURE` and `VICTORY_DUMP_TARGETS=1`: `capture trigger: saving the frames after this one frame=2495 draws=16150 frames=4`, then frames 2496–2499 were saved with 41, 252, 277 and 250 dumped targets. - Without it, fixed `VICTORY_CAPTURE_FRAMES` lists missed the world in two runs of the baseline (`d2a4bae` + #135 + #365): its first world frame was about 1215 in one and after 1400 in the other; here it was 2495. AI-assisted (Claude Code, Claude Opus 5.5); no game data.
Author
Owner

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

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/capture.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/500#issuecomment-7148434189) <!-- victory-triage v1 head=bdbaac636524e792a00909d5813cc9c8cf577ed1 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-gpu/src/capture.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot closed this pull request 2026-11-26 12:56:09 +00:00

Pull request closed

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!500
No description provided.