GPU: report the first differing captured render target #2673

Open
github-bot wants to merge 2 commits from github-bot/gh-2673 into main AGit
Owner

@⁠necrobytes on GitHub · 2026-11-25 17:55 UTC · original
necrobytes:feat/compare-target-captures → main · +901 −115 · 10 files · 2 commits · open

The render-target PNGs drop alpha, downsample the image and normalize some formats. Two submissions can therefore produce identical diagnostic images even when their raw target contents differ. This implements the first-difference report proposed in #2370 using the per-submission capture that already exists. Command recording and replay remain open in that issue.

Capture the same numbered frames from each build with VICTORY_DUMP_TARGETS=1, VICTORY_CAPTURE_FRAMES and a separate fresh VICTORY_CAPTURE directory. Compare them with this command.

victory compare-targets before after

The diagnostics build records a BLAKE3 digest over the logical rows of subresource zero, across all its depth slices, excluding D3D12 row padding. The command pairs target-bearing submissions in order within each frame and reports the first missing or changed target, the submission IDs from each run, and the recorded writer if available. Multisampled targets retain their slots, descriptions and writers with an unavailable digest. A comparison that reaches one, or another unreadable target, is inconclusive (exit 2). Captures generated before this review update should be regenerated to include MSAA targets. The report identifies the first difference visible at a captured submission boundary. A submission can contain multiple draws.

I tested on a Radeon RX 9060 XT with Wine 11.21 and vkd3d-proton 3.2.0. A synthetic GPU test clears a 3×2 RGBA8 target, changes only its bottom-right alpha byte and reads it back. The two GPU hashes each matched the expected 24 bytes, and the comparison found the change. All 12 capture-related tests passed in the Windows diagnostics build, including coverage for row padding, shifted submission IDs, missing targets and malformed input. I also exercised the built CLI and verified exit codes 0 for matching targets, 1 for a difference and 2 for an unavailable readback or PNG-only directory.

For the MSAA review, I reproduced two false matches on the previous implementation using actual 4× RGBA8 render targets. Both tests now report an inconclusive comparison. One includes an identical single-sample target alongside the MSAA target. The other checks that an MSAA-only submission keeps its position before a later single-sample submission.

Strict Windows MSVC-target Clippy passed locally across the workspace with all targets and features. The asset-policy check passed for all 187 tracked files. I used synthetic inputs throughout. The native Linux GPU crate still fails to compile on both the base and this branch on the same Windows-only symbols.

Tracked as NEW-214. Claim in #1633

Implemented and tested with Codex.

**@⁠necrobytes** on GitHub · 2026-11-25 17:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673) `necrobytes:feat/compare-target-captures` → `main` · +901 −115 · 10 files · 2 commits · open The render-target PNGs drop alpha, downsample the image and normalize some formats. Two submissions can therefore produce identical diagnostic images even when their raw target contents differ. This implements the first-difference report proposed in #2370 using the per-submission capture that already exists. Command recording and replay remain open in that issue. Capture the same numbered frames from each build with `VICTORY_DUMP_TARGETS=1`, `VICTORY_CAPTURE_FRAMES` and a separate fresh `VICTORY_CAPTURE` directory. Compare them with this command. ```console victory compare-targets before after ``` The diagnostics build records a BLAKE3 digest over the logical rows of subresource zero, across all its depth slices, excluding D3D12 row padding. The command pairs target-bearing submissions in order within each frame and reports the first missing or changed target, the submission IDs from each run, and the recorded writer if available. Multisampled targets retain their slots, descriptions and writers with an unavailable digest. A comparison that reaches one, or another unreadable target, is inconclusive (exit 2). Captures generated before this review update should be regenerated to include MSAA targets. The report identifies the first difference visible at a captured submission boundary. A submission can contain multiple draws. I tested on a Radeon RX 9060 XT with Wine 11.21 and vkd3d-proton 3.2.0. A synthetic GPU test clears a 3×2 RGBA8 target, changes only its bottom-right alpha byte and reads it back. The two GPU hashes each matched the expected 24 bytes, and the comparison found the change. All 12 capture-related tests passed in the Windows diagnostics build, including coverage for row padding, shifted submission IDs, missing targets and malformed input. I also exercised the built CLI and verified exit codes 0 for matching targets, 1 for a difference and 2 for an unavailable readback or PNG-only directory. For the MSAA review, I reproduced two false matches on the previous implementation using actual 4× RGBA8 render targets. Both tests now report an inconclusive comparison. One includes an identical single-sample target alongside the MSAA target. The other checks that an MSAA-only submission keeps its position before a later single-sample submission. Strict Windows MSVC-target Clippy passed locally across the workspace with all targets and features. The asset-policy check passed for all 187 tracked files. I used synthetic inputs throughout. The native Linux GPU crate still fails to compile on both the base and this branch on the same Windows-only symbols. Tracked as `NEW-214`. [Claim in #1633](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) Implemented and tested with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:43 +00:00
Author
Owner

@⁠necrobytes on GitHub · 2026-11-25 18:18 UTC · original

@⁠DrDarkDK, thanks for catching this. I implemented your suggestion in aa709af. Each MSAA target now gets a manifest record with its slot, description, writer and hash: None. If the comparison reaches that target, it reports an inconclusive result (exit 2). A submission containing only MSAA targets also keeps its place when the two runs are paired. Original review

I added two regressions using real 4× MSAA textures. One pairs an MSAA target with an identical single-sample target. The other puts an MSAA-only submission before a later matching submission. Both reproduced a false match with the old code. With the fix, all 12 capture tests passed on a Radeon RX 9060 XT. The update is ready for another look. Windows CI

**@⁠necrobytes** on GitHub · 2026-11-25 18:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#issuecomment-7170726855) @⁠DrDarkDK, thanks for catching this. I implemented your suggestion in [aa709af](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2673/commits/aa709afe33882e19c8d34a504f98c8c2418c844d). Each MSAA target now gets a manifest record with its slot, description, writer and `hash: None`. If the comparison reaches that target, it reports an inconclusive result (exit `2`). A submission containing only MSAA targets also keeps its place when the two runs are paired. [Original review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2673) I added two regressions using real 4× MSAA textures. One pairs an MSAA target with an identical single-sample target. The other puts an MSAA-only submission before a later matching submission. Both reproduced a false match with the old code. With the fix, all 12 capture tests passed on a Radeon RX 9060 XT. The update is ready for another look. [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/45673059662)
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:48 UTC · original

Read through the whole change - solid work, several details done right:

  • ReadbackLayout validates the D3D12 footprint (row_bytes <= pitch, checked arithmetic for end <= total, isize::try_from catching the UINT64_MAX failure sentinel) - the old code assumed RowPitch*Height was unconditionally safe to map.
  • hash_rows covers all depth slices of subresource 0 and correctly excludes row padding including after the last row.
  • The manifest format is strict (numeric fields, header, duplicate slot+plane and duplicate manifest detection - the s1 vs s01 test is a nice catch) and written atomically via staging+rename.
  • Comparison pairs by position within each frame rather than submission ID, which is the only sane choice given the counter drifts between runs; the missing_submission fallback correctly distinguishes 'submission absent' from 'present but empty'.
  • MSAA keeps its slot and forces inconclusive instead of silently comparing equal - verified by the 'matching targets before an unavailable readback' test.
  • Exit codes 0/1/2 map cleanly for scripting.

One thing to flag for the next iteration (not a blocker): an unreadable target on only one side still bails - correct and conservative. Also appreciate that this closes only the compare half of #2370 and states command record/replay stays open.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#issuecomment-7171417724) Read through the whole change - solid work, several details done right: - ReadbackLayout validates the D3D12 footprint (row_bytes <= pitch, checked arithmetic for end <= total, isize::try_from catching the UINT64_MAX failure sentinel) - the old code assumed RowPitch*Height was unconditionally safe to map. - hash_rows covers all depth slices of subresource 0 and correctly excludes row padding including after the last row. - The manifest format is strict (numeric fields, header, duplicate slot+plane and duplicate manifest detection - the s1 vs s01 test is a nice catch) and written atomically via staging+rename. - Comparison pairs by position within each frame rather than submission ID, which is the only sane choice given the counter drifts between runs; the missing_submission fallback correctly distinguishes 'submission absent' from 'present but empty'. - MSAA keeps its slot and forces inconclusive instead of silently comparing equal - verified by the 'matching targets before an unavailable readback' test. - Exit codes 0/1/2 map cleanly for scripting. One thing to flag for the next iteration (not a blocker): an unreadable target on only one side still bails - correct and conservative. Also appreciate that this closes only the compare half of #2370 and states command record/replay stays open.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:03 UTC · original

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of aa709afe (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory-gpu -p victory --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • RTX 5090: cargo test --locked -p victory-gpu --features diagnostics --lib capture: 12 passed, 0 failed (including all 3 D3D12 readback tests and 7 capture_diff unit tests).
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 208 passed, 0 failed, 1 ignored.
  • cargo test --locked -p victory: 10 passed (unit), 2 passed (tests/census.rs).

Review & Merge-Ordering Notes

  • Atomic .tmp -> rename manifests, numeric (frame, submission_position, slot, plane) ordering, ReadbackLayout pitch-stripped row hashing with GetDeviceRemovedReason() guard, and exit-code 2 handling for unavailable/MSAA readbacks all look solid.
  • Merge compatibility in capture.rs:
    • Clean zero-conflict 3-way git merge-tree with #2680 (b44ce1ff) and #2701 (a86d36ef).
    • Content conflict in crates/victory-gpu/src/capture.rs with #2702 (b48e6c74), since both refactor dump_submission/dump_one; when merging both, submission_target can delegate MSAA color targets to #2702's resolve_destination/dump_one path and only record hash: None when resolve is unavailable (depth/integer/typeless MSAA).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#issuecomment-7171752812) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of `aa709afe` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo clippy --locked -p victory-gpu -p victory --all-targets -- -D warnings` and `--features diagnostics`: **0 warnings**. - **RTX 5090:** `cargo test --locked -p victory-gpu --features diagnostics --lib capture`: **12 passed, 0 failed** (including all 3 D3D12 readback tests and 7 `capture_diff` unit tests). - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1`: **208 passed, 0 failed, 1 ignored**. - `cargo test --locked -p victory`: **10 passed** (unit), **2 passed** (`tests/census.rs`). ### Review & Merge-Ordering Notes - Atomic `.tmp -> rename` manifests, numeric `(frame, submission_position, slot, plane)` ordering, `ReadbackLayout` pitch-stripped row hashing with `GetDeviceRemovedReason()` guard, and exit-code `2` handling for unavailable/MSAA readbacks all look solid. - **Merge compatibility in `capture.rs`:** - Clean zero-conflict 3-way `git merge-tree` with **#2680** (`b44ce1ff`) and **#2701** (`a86d36ef`). - Content conflict in `crates/victory-gpu/src/capture.rs` with **#2702** (`b48e6c74`), since both refactor `dump_submission`/`dump_one`; when merging both, `submission_target` can delegate MSAA color targets to #2702's `resolve_destination`/`dump_one` path and only record `hash: None` when resolve is unavailable (depth/integer/typeless MSAA).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:16 UTC · original · edited 2026-11-26 03:25 UTC

Automated triage for the maintainers.

Verdict: merge candidate. Thanks for rebasing; it merges cleanly into current main.

This implements the compare half of #2370. In diagnostics builds, capture.rs dump_submission writes a per-submission .targets manifest. Each entry holds a BLAKE3 digest of subresource zero's logical rows (capture_diff::hash_rows, which skips D3D12 row padding and checks the footprint arithmetic). The new victory compare-targets pairs submissions by position within a frame and reports the first difference, with exit codes 0/1/2. I checked that blake3 is already a victory-gpu dependency (no Cargo.toml change). The manifest is written via a staging file and rename. MSAA targets keep their slot with no digest, which makes a comparison that reaches them inconclusive rather than a false match. The read_back callers in draw.rs, host.rs and placed_uav_tests.rs moved to the new ReadbackLayout::with_rows, which no longer assumes RowPitch * Height is mappable.

The README addition is at the upper end of what the docs should carry; a maintainer may want it shorter. Expect a conflict with #2702 in capture.rs (both rework dump_submission).

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#issuecomment-7176158760) · edited 2026-11-26 03:25 UTC <!-- victory-triage v1 head=ba745e68b6509386b18094b293bfc2df8b94ce41 verdict=merge-candidate at=2026-11-26T03:25:51Z --> Automated triage for the maintainers. **Verdict: merge candidate.** Thanks for rebasing; it merges cleanly into current `main`. This implements the compare half of #2370. In diagnostics builds, `capture.rs` `dump_submission` writes a per-submission `.targets` manifest. Each entry holds a BLAKE3 digest of subresource zero's logical rows (`capture_diff::hash_rows`, which skips D3D12 row padding and checks the footprint arithmetic). The new `victory compare-targets` pairs submissions by position within a frame and reports the first difference, with exit codes 0/1/2. I checked that `blake3` is already a `victory-gpu` dependency (no `Cargo.toml` change). The manifest is written via a staging file and `rename`. MSAA targets keep their slot with no digest, which makes a comparison that reaches them inconclusive rather than a false match. The `read_back` callers in `draw.rs`, `host.rs` and `placed_uav_tests.rs` moved to the new `ReadbackLayout::with_rows`, which no longer assumes `RowPitch * Height` is mappable. The README addition is at the upper end of what the docs should carry; a maintainer may want it shorter. Expect a conflict with #2702 in `capture.rs` (both rework `dump_submission`). CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 18:00 UTC · original · requested changes

submission_target returns None for multisampled textures, so those targets are omitted from the manifest. If the other targets match, compare-targets can report success without comparing the MSAA target. A submission with only omitted targets can also disappear and shift the pairing with later submissions.

Could the capture emit a record for each MSAA target with its description and hash: None? The comparer already treats an unavailable hash as inconclusive. A fixture with one matching single-sample target and one unavailable MSAA target would cover the false-match case.

Static review only.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-25 18:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#pullrequestreview-6062509615) · **requested changes** `submission_target` returns `None` for multisampled textures, so those targets are omitted from the manifest. If the other targets match, `compare-targets` can report success without comparing the MSAA target. A submission with only omitted targets can also disappear and shift the pairing with later submissions. Could the capture emit a record for each MSAA target with its description and `hash: None`? The comparer already treats an unavailable hash as inconclusive. A fixture with one matching single-sample target and one unavailable MSAA target would cover the false-match case. Static review only. *AI-assisted with Codex.*
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 18:24 UTC · original · approved these changes

The MSAA finding is resolved. The capture now keeps each MSAA target’s slot and metadata with an unavailable digest, so the comparison reports an inconclusive result when it reaches that target. The new regressions cover both the mixed single-sample/MSAA case and an MSAA-only submission before a later capture.

I reviewed the update and confirmed Windows CI passed for aa709af. I didn’t rerun the GPU tests locally.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-25 18:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#pullrequestreview-6062830633) · **approved these changes** The MSAA finding is resolved. The capture now keeps each MSAA target’s slot and metadata with an unavailable digest, so the comparison reports an inconclusive result when it reaches that target. The new regressions cover both the mixed single-sample/MSAA case and an MSAA-only submission before a later capture. I reviewed the update and confirmed Windows CI passed for `aa709af`. I didn’t rerun the GPU tests locally. *AI-assisted with Codex.*
Author
Owner

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

Reviewed all 10 files at ba745e68 and verified across RTX 5090, WARP (VICTORY_D3D12_WARP=1), VICTORY_D3D12_DEBUG=1, default/release builds, and live CLI runs.

Highlights checked

  • Zero default / release overhead & non-Windows #[cfg] hygiene: all capture and readback hooks in capture.rs, host.rs, draw.rs, and placed_uav_tests.rs remain gated behind diagnostics; crates/victory-gpu/src/capture_diff.rs and capture_diff/compare.rs are platform-independent with hash_rows (capture_diff.rs:22) and write_submission (capture_diff.rs:43) cleanly gated with #[cfg(any(all(windows, feature = "diagnostics"), test))].
  • Safe readback & hashing: ReadbackLayout (capture.rs:127) checks the u64::MAX footprint sentinel, row_bytes <= pitch, and checked total bounds before mapping, guards mapped reads with GetDeviceRemovedReason().is_err() (capture.rs:663), and hashes every logical row and 3D depth slice without padding (capture.rs:704).
  • Comparison edge cases: capture_diff::compare (capture_diff/compare.rs:167) properly rejects empty/PNG-only directories, malformed lines, duplicate manifests (s1 vs s01), and duplicate (slot, plane) entries (exit 2), preserves MSAA / unavailable readback slots so they cannot silently compare equal (exit 2), and detects dimension/format or raw byte mismatches in numeric frame + submission order (exit 1).

Verification

  • cargo run -p xtask -- policy: 194 files ok.
  • cargo clippy --workspace --all-targets -- -D warnings (both default and --all-features) and cargo check --release -p victory -p victory-gpu (without diagnostics): all clean.
  • cargo test -p victory: 18/18 passed.
  • cargo test -p victory-gpu --lib --features diagnostics (capture + capture_diff + placed_uav_tests): 22/22 passed on RTX 5090 + VICTORY_D3D12_DEBUG=1, and 22/22 passed on WARP + VICTORY_D3D12_DEBUG=1.
  • Live victory.exe compare-targets: verified exit 0 on matching manifests (All captured render targets match.), exit 1 on a differing target with frame/submission/slot/plane/BLAKE3/writer details, and exit 2 on an empty directory.
  • Merge note: merges cleanly with #2655 (22/22 pass together on WARP + Debug Layer); will need a straightforward conflict resolution in crates/victory-gpu/src/capture.rs if landed after #2702 since both touch dump_submission/dump_one.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2673#pullrequestreview-6076225344) · **approved these changes** Reviewed all 10 files at `ba745e68` and verified across RTX 5090, WARP (`VICTORY_D3D12_WARP=1`), `VICTORY_D3D12_DEBUG=1`, default/release builds, and live CLI runs. ### Highlights checked - **Zero default / release overhead & non-Windows `#[cfg]` hygiene**: all capture and readback hooks in `capture.rs`, `host.rs`, `draw.rs`, and `placed_uav_tests.rs` remain gated behind `diagnostics`; `crates/victory-gpu/src/capture_diff.rs` and `capture_diff/compare.rs` are platform-independent with `hash_rows` (`capture_diff.rs:22`) and `write_submission` (`capture_diff.rs:43`) cleanly gated with `#[cfg(any(all(windows, feature = "diagnostics"), test))]`. - **Safe readback & hashing**: `ReadbackLayout` (`capture.rs:127`) checks the `u64::MAX` footprint sentinel, `row_bytes <= pitch`, and checked total bounds before mapping, guards mapped reads with `GetDeviceRemovedReason().is_err()` (`capture.rs:663`), and hashes every logical row and 3D depth slice without padding (`capture.rs:704`). - **Comparison edge cases**: `capture_diff::compare` (`capture_diff/compare.rs:167`) properly rejects empty/PNG-only directories, malformed lines, duplicate manifests (`s1` vs `s01`), and duplicate `(slot, plane)` entries (exit `2`), preserves MSAA / unavailable readback slots so they cannot silently compare equal (exit `2`), and detects dimension/format or raw byte mismatches in numeric frame + submission order (exit `1`). ### Verification - `cargo run -p xtask -- policy`: 194 files ok. - `cargo clippy --workspace --all-targets -- -D warnings` (both default and `--all-features`) and `cargo check --release -p victory -p victory-gpu` (without `diagnostics`): all clean. - `cargo test -p victory`: 18/18 passed. - `cargo test -p victory-gpu --lib --features diagnostics` (`capture` + `capture_diff` + `placed_uav_tests`): **22/22 passed** on RTX 5090 + `VICTORY_D3D12_DEBUG=1`, and **22/22 passed** on WARP + `VICTORY_D3D12_DEBUG=1`. - Live `victory.exe compare-targets`: verified exit `0` on matching manifests (`All captured render targets match.`), exit `1` on a differing target with frame/submission/slot/plane/BLAKE3/writer details, and exit `2` on an empty directory. - Merge note: merges cleanly with `#2655` (`22/22` pass together on WARP + Debug Layer); will need a straightforward conflict resolution in `crates/victory-gpu/src/capture.rs` if landed after `#2702` since both touch `dump_submission`/`dump_one`.
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/2673/head:github-bot/gh-2673'
git switch 'github-bot/gh-2673'

Merge

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