GPU diagnostics: VICTORY_CARD_VERIFY compares card copies with their CPU side #455
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/455"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from fxceless/victory-fork. Originally posted by xunbreakablex on 2026-11-25T01:02:47Z.
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: #418.Not tested
1582757/#191-style changes beyond whatmainalready has.AI-assisted (Claude); the in-game run was done on my machine.
Imported from fxceless/victory-fork. Originally posted by deepdev237 on 2026-11-25T04:03:41Z.
Full test environment
x86_64-pc-windows-msvccargo build --profile diag -p victory --features diagnostics(diag= release + debug info)main310c6eb6c16822ab95076aad61fce19bba86bb98levels.rpf,audio.rpf,pack/story000/story000.rpf,navmeshes.rpfand sixdata/ttdb/*.ttpf), so failures that depend on those bytes are not emulator bugs.Integration note: this PR and #496 ("GPU: avoid re-uploading card data after a waited fetch") both merge onto
main310c6eb, but together they do not compile:#496 changes
Card::dirtyfromMutex<Vec<(usize, usize)>>toMutex<CardUpdates>, where the pending ranges are split intouploadandhash_only.card_verify_viewstill doescard.dirty.lock()...clone(). This is what I used, which leaves both kinds of pending range out of the comparison (bytes the card has not received yet, and bytes whose hash only needs refreshing):The conflict in
Host::presentwithmain(which now takes&Arc<HostTexture>and moves the texture toCOPY_SOURCEthrough the copy list's prelude) resolves by putting the twocard_verify::frame(self, frame)lines at the top ofmain's version.With both changes, the full unit and hardware test run (598 passed, 0 failed, 6 ignored) passes on
310c6ebplus about 100 open PRs, on an RX 9060 XT (RDNA4, driver 32.0.32015.7029). I have not yet run withVICTORY_CARD_VERIFYset; I will add the results here when I do.Exact state tested
4de64fd0eb52243b1a5c145e4a877a867ef06ffe; #496's head:b7d8c444e14f950a6afd9f5ae1e1b32765091522. #496 was merged first, then this PR, both withgit merge --no-ffonto the integration branch.crates/victory-gpu/src/host.rs,impl Host { fn present }:mainnow haspresent(&self, texture: &Arc<HostTexture>, frame: u64) -> Option<bool>and moves the texture toCOPY_SOURCEthrough the copy list's prelude underself.submitted. Resolved by keepingmain's function and adding the PR's#[cfg(feature = "diagnostics")] card_verify::frame(self, frame);at its start.no method named clone found for struct std::sync::MutexGuard<'_, CardUpdates>atcrates/victory-gpu/src/shadow.rs:3103.VICTORY_CARD_VERIFYset. Game runs with this build had it unset.Integration test run, every test binary
Command:
cargo test --profile diag -p victory -p victory-game -p victory-gpu -p victory-hle -p victory-loader -p victory-shader --features victory/diagnostics, onmain310c6ebplus about 110 open PRs merged in order (list with outcomes:integration-merge-log.tsvin the gist). PR #445 is reverted there.victory(unit)victory-gamevictory-gpu(includes tests on the real D3D12 device)victory-hlevictory-loaderunit /no_dll_planting/load_probe/title_dllsvictory-shader(includes the hardware shader tests, 29.9 s)Full output:
integration-test-all.login https://gist.github.com/deepdev237/785e05b02d0dcece7aac1303f7fe4ba8Imported from fxceless/victory-fork. Originally posted by xunbreakablex on 2026-11-25T07:27:52Z.
Thank you for building this together with #496 and for writing down the fix. Leaving both kinds of pending range (
uploadandhash_only) out of the comparison is the right reading: the comparison should skip bytes the card has not received yet, and a hash-only refresh does not change the bytes. Your snippet looks correct to me, but I have not compiled it against #496.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.