Repository navigation
GPU diagnostics: VICTORY_CARD_VERIFY compares card copies with their CPU side - #455
xunbreakablex wants to merge 1 commit into
Conversation
…CPU side
Title buffers of VICTORY_CARD_BUFFERS_MIN_MB or more are held in the card's
memory with a CPU side (what title memory is copied into, and the reference
the card's writes are found against). card_before, card_back, card_merge
and the relay's merge exist to keep the two equal; nothing checked that
end to end. With VICTORY_CARD_VERIFY=N (diagnostics builds only), every
N-th presented frame each such copy, windows included, is read back from
the card and compared with its CPU side by 64 KiB piece. One `card verify:`
line per copy (ok / MISMATCH with the pieces, bytes and the first eight
differing title addresses / skipped) and one summary line per frame.
When the sides are comparable: at the start of the present, with the
submission lock held and after every flight has been settled (with
VICTORY_RELAY the landing thread's work, waited for), so no shader of ours
runs, every fetch has been merged and card_done has run. A copy that still
names a pending shader write is skipped ("skipped: in flight"). Offsets
the CPU side holds that have not gone up to the card yet (Card::dirty) are
left out and counted, since they differ by design until the next
submission.
For the pieces that differ, each differing byte is also compared with the
title's own memory, read live: title == CPU != card (the card's byte is
newer), title == card != CPU (the CPU side is stale), neither (the title
wrote it and neither side has it); a second line per copy gives pieces per
class, how many hold a byte inside a range declared as written in the last
two frames, and the first samples.
False positives to know of: the title's other threads keep running, so the
live read of title memory is a snapshot; a write by a shader outside every
declared range is a real mismatch (an undeclared write), not a fault of the
card path; the card's side is read without a barrier, as the existing
fetches are.
Cost: off (the variable unset or 0, or any build without the
`diagnostics` feature) it is one OnceLock read per present, and the
declared-range history is not kept. On, a checked frame settles every
flight, takes the submission lock and reads up to
VICTORY_CARD_VERIFY_MAX_MB (256; 0: all) of copies back through a 64 MiB
buffer; copies that do not fit are taken first at the next check.
Unit tests cover the per-piece counting and the classification (no GPU).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on fxceless#455).
HLE: honor the requested executable on relaunch
Full test environment
Integration note: this PR and #496 ("GPU: avoid re-uploading card data after a waited fetch") both merge onto #496 changes // Since #496 the pending ranges are split into uploads and hash-only
// refreshes; both are left out of the comparison.
let mut dirty: Vec<(usize, usize)> = {
let updates = card.dirty.lock().unwrap_or_else(|e| e.into_inner());
let mut all = updates.upload.clone();
all.extend_from_slice(&updates.hash_only);
all
};The conflict in With both changes, the full unit and hardware test run (598 passed, 0 failed, 6 ignored) passes on Exact state tested
Integration test run, every test binaryCommand:
Full output: |
HLE: honor the requested executable on relaunch (cherry picked from commit e686512)
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on fxceless#455). (cherry picked from commit eb8067f)
|
Thank you for building this together with #496 and for writing down the fix. Leaving both kinds of pending range ( I will not be able to follow this PR, so if you or anyone wants it, please take the diagnostic as it is and apply your adjustment (or open a PR of your own with it); if it is not wanted, closing it is fine. What is untested in game: the three-way classification (which side is newer). The two-way comparison I ran earlier is described in the PR body and in #418. |
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on fxceless#455). (cherry picked from commit eb8067f) (cherry picked from commit c94adc0)
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on fxceless#455). (cherry picked from commit eb8067f)
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on fxceless#455). (cherry picked from commit eb8067f)
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on fxceless#455). (cherry picked from commit eb8067f)
Needs human attention: this is a diagnostics-only change, but it settles every flight and takes the submission lock on the frames it checks, so please read the "when the sides are comparable" part of
docs/card-verify.mdbefore enabling it on a build you care about. The three-way classification and the live read of title memory have been compiled and unit-tested but not run in game; only the earlier two-way comparison was run (below).Why
Title buffers of
VICTORY_CARD_BUFFERS_MIN_MBor more are held in the card's memory with a CPU side (what title memory is copied into, and the reference the card's writes are found against).card_before,card_back,card_mergeand the relay's merge exist to keep the two equal, but nothing checks that end to end, andVICTORY_CARD_BUFFERS_MIN_MB=1(recommended in the README) moves ~87 more copies to this path. This adds a way to check it.What
With
VICTORY_CARD_VERIFY=N(diagnosticsbuilds only; off by default, oneOnceLockread per present when off), every N-th presented frame each copy in the card's memory is read back and compared with its CPU side by 64 KiB piece, after every flight has been settled and with the submission lock held. Onecard verify:line per copy (ok / MISMATCH with pieces, bytes and the first eight differing title addresses / skipped) and one summary line per frame.VICTORY_CARD_VERIFY_MAX_MB(256) bounds the bytes read back per checked frame; copies that do not fit are taken first at the next check.For pieces that differ, each differing byte is also compared with the title's own memory read live, which says which side is newer: card newer (shaders wrote it and it did not come back), CPU side stale (a merge missed it), or neither has it. A second line per copy gives pieces per class and whether the differing bytes lie inside a range declared as written in the last two frames (an undeclared shader write is a real mismatch of a different kind).
Docs:
docs/card-verify.md. Nothing changes in builds without thediagnosticsfeature.Tested
cargo check -p victory-gpuand--features diagnostics(--locked): cleancargo clippy -p victory-gpu --all-targets -- -D warnings, default and--all-features(as in CI): cleancargo test -p victory-gpu --lib --features diagnostics -- verify_tests classify_tests: 2/2 passed (piece counting and the A/B/C/D classification; no GPU). The workspace tests and thextaskpolicy test were not run locallyVICTORY_RELAY=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024 VICTORY_CARD_VERIFY=10, world: 233 rounds, 98 copies, every copy checked at least once, 1,311 copy checks: 0 mismatches in 97 copies (1,302 checks); 9 checks mismatched in one 24 MiB copy (140 of its 384 pieces, the same pieces every time), which is already in the card's memory with the default 16 MB limit. Measurements around this: RTX 4070 12 GB + Ryzen 5 5600: steady-state world 361 → 263 ms/frame with CARD_BUFFERS_MIN_MB=1 on RELAY=1 (313 → 285 on RELAY=2); page faults 66k → 0.5k #418.Not tested
1582757/GPU: wait for in-flight writes from aliased copies, read-backs and late writes (#89) #191-style changes beyond whatmainalready has.AI-assisted (Claude); the in-game run was done on my machine.