Skip to content

GPU diagnostics: pick capture frames by draw count - #500

Open
itsRevela wants to merge 1 commit into
Marvisak:mainfrom
itsRevela:diag/capture-on-draws
Open

itsRevela wants to merge 1 commit into
Marvisak:mainfrom
itsRevela:diag/capture-on-draws

Conversation

@itsRevela

Copy link
Copy Markdown
Contributor

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 (CI: check the formatting with cargo fmt on all PRs #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

@ghost

ghost commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

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

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 <noreply@anthropic.com>
@itsRevela
itsRevela force-pushed the diag/capture-on-draws branch from be6df3a to bdbaac6 Compare November 24, 2026 12:22

Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants