GPU: target dumps name every writer, and VICTORY_DUMP_AFTER dumps a texture right after a pipeline #3415

Open
JurajSimicevic wants to merge 2 commits from upstream-pr/3415 into main
JurajSimicevic commented 2026-11-26 23:52:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by JurajSimicevic on 2026-11-26T23:52:33Z.


Problem

With VICTORY_DUMP_TARGETS, each submission of a listed frame dumps the textures its lists wrote, as frame-<n>-s<sub>-<i>-…-by-<pipeline>.png. Two things made these files easy to misread:

  • Content. A file holds what the whole submission left in the texture, but it is named after the first pipeline that wrote it. Its doc comment said the files follow a frame "pass by pass".
  • Writers. Only views bound through tables counted as writers. Draws that render to a target were never named.

An example, in the world on an RTX 5080, counts only:

  • An additive lighting target was named after the compute pass that writes it first. 188 more pipelines, the draws that render to it, wrote it later in the same submission.
  • Its share of green-dominant pixels was 27% right after that compute pass, and 61% in the per-submission file.

I read such files as the named pass's output twice in my own reports on #2711, and others measure the same way.

Change

Writers.

  • Lists and the frame-end dump keep every pipeline that wrote a target, in order. That covers unordered views through tables, as before, and now also the draws that render to it (render targets, depth).
  • The file name gives the first writer and -and-<n>-more; one log line lists them all.
  • The doc comment and the README say what the per-submission files hold.

VICTORY_DUMP_AFTER=<hash>,.... In listed frames, a texture can now be dumped right after one pipeline's command:

  • It applies after a dispatch, indirect execution, draw or mesh dispatch of a pipeline containing a listed shader hash.
  • The 2D textures that command writes are read back in the same list, right after it: its shaders' unordered views through tables, and a draw's render targets and depth.
  • Once the list has run, each is saved as frame-<n>-after-<k>-…, where n is the frame whose submission ran it and k counts these dumps in order.

Shared code.

  • capture::snapshot does the read-back: a UAV barrier, copy-source, then back to the state the next command needs.
  • The existing 1D/3D probe after dispatches (probe_written) now uses it too.
  • dump_one is split into its read-back and save_target, which both paths use.

Scope.

  • Diagnostics builds only, and nothing changes without these switches.
  • Not covered: depth textures with a writable twin (crate::twin), whose unordered writes are not in the texture yet; they are skipped with a log line. 1D, 3D and multisampled targets are not dumped after a command.

capture.rs, draw.rs, host.rs (all victory-gpu) and README.md.

Tested

Unit and GPU tests:

  • cargo test -p victory-gpu --features diagnostics --lib:
    • WARP (VICTORY_D3D12_WARP=1): 248 passed.
    • RTX 5080: 246 passed and 2 failed. The two are dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, which fail on main on NVIDIA too (#3178).
  • New: draw::tests::a_snapshot_right_after_a_dispatch_holds_what_it_wrote. Two dispatches write one texture; the snapshot after the first holds the first's values, and the one after the second holds the second's. Expecting the second's values after the first makes it fail.
  • New: capture::tests::dump_names_give_the_first_writer_and_how_many_more.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, with and without --features diagnostics: clean. No other crate changes.

In the title (RTX 5080):

  • Setup: diag build of a local stack (main + #2098, #2626, #2628, #2464, #2118, #439 at e2d3cfd, and local diagnostic logging) with this change. VICTORY_DUMP_TARGETS=1, VICTORY_CAPTURE_WORLD=150, and VICTORY_DUMP_AFTER naming three compute pipelines.
  • Two runs, the second with the draw writers added. Each saved 30 after-dumps, with no device errors.
  • The lighting target's per-submission file now ends in -and-188-more.
  • After-dumps recorded for the next frame carry that frame's number.
  • The numbers repeat between the runs: 27.2% / 27.1% right after the compute pass, 60.9% / 60.8% at the end of the submission.

Overlap: #3388 also changes dump_one (footprint checks before mapping). Whichever lands second moves those checks into save_target.

No game data: counts and file-name shapes only.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5518779299 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3415). Originally posted by [JurajSimicevic](https://github.com/JurajSimicevic) on 2026-11-26T23:52:33Z. --- ## Problem With `VICTORY_DUMP_TARGETS`, each submission of a listed frame dumps the textures its lists wrote, as `frame-<n>-s<sub>-<i>-…-by-<pipeline>.png`. Two things made these files easy to misread: - **Content.** A file holds what the whole submission left in the texture, but it is named after the first pipeline that wrote it. Its doc comment said the files follow a frame "pass by pass". - **Writers.** Only views bound through tables counted as writers. Draws that render to a target were never named. An example, in the world on an RTX 5080, counts only: - An additive lighting target was named after the compute pass that writes it first. 188 more pipelines, the draws that render to it, wrote it later in the same submission. - Its share of green-dominant pixels was 27% right after that compute pass, and 61% in the per-submission file. I read such files as the named pass's output twice in my own reports on #2711, and others measure the same way. ## Change **Writers.** - Lists and the frame-end dump keep every pipeline that wrote a target, in order. That covers unordered views through tables, as before, and now also the draws that render to it (render targets, depth). - The file name gives the first writer and `-and-<n>-more`; one log line lists them all. - The doc comment and the README say what the per-submission files hold. **`VICTORY_DUMP_AFTER=<hash>,...`.** In listed frames, a texture can now be dumped right after one pipeline's command: - It applies after a dispatch, indirect execution, draw or mesh dispatch of a pipeline containing a listed shader hash. - The 2D textures that command writes are read back in the same list, right after it: its shaders' unordered views through tables, and a draw's render targets and depth. - Once the list has run, each is saved as `frame-<n>-after-<k>-…`, where `n` is the frame whose submission ran it and `k` counts these dumps in order. **Shared code.** - `capture::snapshot` does the read-back: a UAV barrier, copy-source, then back to the state the next command needs. - The existing 1D/3D probe after dispatches (`probe_written`) now uses it too. - `dump_one` is split into its read-back and `save_target`, which both paths use. **Scope.** - Diagnostics builds only, and nothing changes without these switches. - Not covered: depth textures with a writable twin (`crate::twin`), whose unordered writes are not in the texture yet; they are skipped with a log line. 1D, 3D and multisampled targets are not dumped after a command. `capture.rs`, `draw.rs`, `host.rs` (all `victory-gpu`) and `README.md`. ## Tested **Unit and GPU tests:** - `cargo test -p victory-gpu --features diagnostics --lib`: - WARP (`VICTORY_D3D12_WARP=1`): 248 passed. - RTX 5080: 246 passed and 2 failed. The two are `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, which fail on `main` on NVIDIA too (#3178). - New: `draw::tests::a_snapshot_right_after_a_dispatch_holds_what_it_wrote`. Two dispatches write one texture; the snapshot after the first holds the first's values, and the one after the second holds the second's. Expecting the second's values after the first makes it fail. - New: `capture::tests::dump_names_give_the_first_writer_and_how_many_more`. - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`, with and without `--features diagnostics`: clean. No other crate changes. **In the title (RTX 5080):** - Setup: diag build of a local stack (`main` + #2098, #2626, #2628, #2464, #2118, #439 at `e2d3cfd`, and local diagnostic logging) with this change. `VICTORY_DUMP_TARGETS=1`, `VICTORY_CAPTURE_WORLD=150`, and `VICTORY_DUMP_AFTER` naming three compute pipelines. - Two runs, the second with the draw writers added. Each saved 30 after-dumps, with no device errors. - The lighting target's per-submission file now ends in `-and-188-more`. - After-dumps recorded for the next frame carry that frame's number. - The numbers repeat between the runs: 27.2% / 27.1% right after the compute pass, 60.9% / 60.8% at the end of the submission. **Overlap:** #3388 also changes `dump_one` (footprint checks before mapping). Whichever lands second moves those checks into `save_target`. No game data: counts and file-name shapes only. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dukestar69 commented 2026-11-27 00:07:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T00:07:28Z.

Review: APPROVED


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

  • Naming every writer in target dumps and supporting opt-in VICTORY_DUMP_AFTER for post-pipeline texture dumps build and pass cleanly in both default and --features diagnostics configurations.
  • cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1: all passed.
  • 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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081855298 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3415#pullrequestreview-6081855298). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-27T00:07:28Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Naming every writer in target dumps and supporting opt-in `VICTORY_DUMP_AFTER` for post-pipeline texture dumps build and pass cleanly in both default and `--features diagnostics` configurations. - `cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1`: all passed. - `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).
Venom2054 commented 2026-11-27 00:21:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Venom2054 on 2026-11-27T00:21:40Z.


Tested VICTORY_DUMP_AFTER on Windows at 6406c5b with a synthetic four-draw case on an RTX 5070 Ti and WARP. All four DrawInstanced calls wrote to the same 1280 × 720, single-sample R8G8B8A8_TYPELESS resource through an R8G8B8A8_UNORM RTV. The draws wrote blue, red, green, then blue. I selected only the red and green pixel shader hashes.

Both adapters produced exactly two PNGs in that order. All 230,400 sampled pixels in the first PNG were red and all 230,400 in the second were green. A separate full-resolution readback after the fourth draw was blue at all 921,600 pixels. The D3D12 debug layer reported no errors.

This exercises two selected draws writing the same target in one list and verifies that a later unselected draw still renders. Synthetic inputs only. AI-assisted test and analysis.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206395287 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3415#issuecomment-7206395287). Originally posted by [Venom2054](https://github.com/Venom2054) on 2026-11-27T00:21:40Z. --- Tested `VICTORY_DUMP_AFTER` on Windows at `6406c5b` with a synthetic four-draw case on an RTX 5070 Ti and WARP. All four `DrawInstanced` calls wrote to the same 1280 × 720, single-sample `R8G8B8A8_TYPELESS` resource through an `R8G8B8A8_UNORM` RTV. The draws wrote blue, red, green, then blue. I selected only the red and green pixel shader hashes. Both adapters produced exactly two PNGs in that order. All 230,400 sampled pixels in the first PNG were red and all 230,400 in the second were green. A separate full-resolution readback after the fourth draw was blue at all 921,600 pixels. The D3D12 debug layer reported no errors. This exercises two selected draws writing the same target in one list and verifies that a later unselected draw still renders. Synthetic inputs only. AI-assisted test and analysis.
fuzeofficlal commented 2026-11-27 00:48:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:48:33Z.

Review: APPROVED


Looks good. Verified all code paths, diagnostics feature gating, and live D3D12 behavior on both RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1:

  • cargo xtask policy and cargo clippy --tests -p victory-gpu (both default and --features diagnostics, -D warnings) pass cleanly, and all new hooks in draw.rs and host.rs remain properly gated behind #[cfg(feature = "diagnostics")].
  • add_writer / writers_label preserve writer order cleanly without stripping the -and-<n>-more or -twin<p> suffixes in save_target.
  • capture::tests (6/6), a_snapshot_right_after_a_dispatch_holds_what_it_wrote (1/1), and draw::tests (21/21) all pass on both RTX 5090 and WARP.
  • Additionally tested capture::snapshot and end-to-end capture::dump_after (deferred PNG write) on R8G8B8A8_UNORM (RENDER_TARGET), D32_FLOAT (DEPTH_WRITE), and R24G8_TYPELESS (DEPTH_WRITE) textures on both RTX 5090 and WARP: all snapshots and saved PNGs succeeded with zero D3D12 debug layer messages.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082063091 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3415#pullrequestreview-6082063091). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T00:48:33Z. **Review:** APPROVED --- Looks good. Verified all code paths, diagnostics feature gating, and live D3D12 behavior on both RTX 5090 and WARP with `VICTORY_D3D12_DEBUG=1`: - `cargo xtask policy` and `cargo clippy --tests -p victory-gpu` (both default and `--features diagnostics`, `-D warnings`) pass cleanly, and all new hooks in `draw.rs` and `host.rs` remain properly gated behind `#[cfg(feature = "diagnostics")]`. - `add_writer` / `writers_label` preserve writer order cleanly without stripping the `-and-<n>-more` or `-twin<p>` suffixes in `save_target`. - `capture::tests` (6/6), `a_snapshot_right_after_a_dispatch_holds_what_it_wrote` (1/1), and `draw::tests` (21/21) all pass on both RTX 5090 and WARP. - Additionally tested `capture::snapshot` and end-to-end `capture::dump_after` (deferred PNG write) on `R8G8B8A8_UNORM` (`RENDER_TARGET`), `D32_FLOAT` (`DEPTH_WRITE`), and `R24G8_TYPELESS` (`DEPTH_WRITE`) textures on both RTX 5090 and WARP: all snapshots and saved PNGs succeeded with zero D3D12 debug layer messages.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3415:upstream-pr/3415'
git switch 'upstream-pr/3415'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3415'
git switch 'upstream-pr/3415'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3415'
git switch 'upstream-pr/3415'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3415'
git switch 'main'
git merge --squash 'upstream-pr/3415'
git switch 'main'
git merge --ff-only 'upstream-pr/3415'
git switch 'main'
git merge 'upstream-pr/3415'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3415
No description provided.