Repository navigation
GPU: a copy-back keeps the snapshot in step, so a later range takes no older bytes - #198
pablogonz12 wants to merge 3 commits into
Conversation
…o older bytes A copy-back puts what the shaders wrote into title memory and lets the copy take the title's own bytes. The snapshot it compares against (the copy's bytes before the submission) kept only the GPU's bytes, so the bytes the copy had just taken from title memory looked like the GPU's to a later copy-back of a range that overlaps: it put the copy's older bytes back over a title write made after the first copy-back. Now the bytes a copy-back merges into the copy go into the snapshot too (`merge_back`, one pass over the differing span, no second copy of it): a later range finds them unchanged, takes the title's current bytes and writes nothing back. `merge_back` is `merge_piece`'s rule with the copy stored into as well; `merge_piece` keeps not storing into its source (the card may be writing it for a later flight). The same shape is already right on the card-merge path and in `relay_merge`, which update the snapshot they hold. What is not changed: `relay_merge`'s own snapshot still follows only the GPU's bytes (relay is off by default and its merge reads the copy without writing it). Tests: shadow::merge_tests::a_copy_back_keeps_its_snapshot_in_step — the upstream #2436 shape in one piece (a shader byte, a title write beside it, the copy-back, then the title writing both again: both stay), and the same piece with the snapshot left behind, which puts the older byte back. Gates: clippy clean (workspace, all targets); victory-gpu 207 passed, 2 ignored (the existing benchmark and watch benchmarks), 0 "no device" skips on the RADV card; victory-shader 187 passed, 2 ignored. Behaviour only on the CPU copy-back path, no switch. Not tested in a game run. Co-authored-by: Calvix2k <calvinhebben1@gmail.com>
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Security architecture risk:
|
…and no others The factory's SetStagingBufferSize copied whatever size the title asked for into the scheduler. The console has the staging capacities the current release documents - zero, for a title whose queues all come from memory, and 16, 20, 24, 28 and 32 MiB - and nothing between or past them. Now a size outside that list is refused with E_INVALIDARG and the capacity the scheduler has is kept, logged once. What the console answers is not documented in the interface (`E_INVALIDARG` is what this module answers for out-of-range values elsewhere, not a verified code). `VICTORY_DSTORAGE_STAGING_ CHECK=0` takes any size and copies it, as before. Our title asks for 32 MiB, which is in the list. Tests: dstorage::tests::staging_buffer_sizes_the_console_has_none_of_are_ refused (each documented size, sizes inside, between and past them, u32::MAX; then through the factory method, refused with the scheduler's capacity unchanged). Gates: clippy clean; victory-hle 98 passed, 3 failed on the RADV card, the same three failures as on hub/main in the same Wine prefix (lifecycle keyboard/window and the loopback net check need a display and network that the test prefix has not). Not tested in a game run. Co-authored-by: TheGrayOrange <357638192+TheGrayOrange@users.noreply.github.com>
…itten The merge wrote the snapshot through a slice while a shared slice of the same bytes (the whole declared range) was still live, which Rust's aliasing rules forbid even though the mutex keeps other threads out. Now the range-wide shared slice lives only for the comparison that finds the differing pieces, and each piece's bytes are read in a scope of their own that ends before `merge_back` writes them: no borrow of the snapshot is kept across the merge. Found by CodeRabbit on #198. Gates: clippy clean; victory-gpu 207 passed, 2 ignored, 0 "no device" skips on the RADV card; cargo xtask policy 244 files ok. Co-authored-by: Calvix2k <calvinhebben1@gmail.com>
|
Closed as superseded: this branch was built in a worktree that already held the DirectStorage commit, so it carried an unrelated change. The copy-back change alone is #214 (int/vic-copyback), including the fix for the aliasing finding (snapshot bytes read per piece, in their own scope). |
What
A copy-back puts what the shaders wrote into title memory and lets the copy take the title's own bytes
(
Shadow::copy_back_with). The snapshot it compares against — the copy's bytes before the submission — keptonly the GPU's bytes, so the bytes the copy had just taken from title memory looked like the GPU's to a later
copy-back of a range that overlaps the first one (the world declares overlapping views of its big heap
dozens of times per frame): it wrote the copy's older bytes back over a title write made after the first
copy-back. Same family as the stale-bytes-over-live-data failures we chase in streaming and geometry.
Now the bytes a copy-back merges into the copy go into the snapshot too:
merge_back, one pass over thediffering span (no second copy of it — this runs over the differing bytes of every declared range). A later
range finds them unchanged, takes the title's current bytes and writes nothing back.
merge_backismerge_piece's rule with the copy stored into as well;merge_piecekeeps not storing into its source (thecard may be writing it for a later flight).
The same shape is already right on the card-merge path (
Shadow::card_merge) and inrelay_merge, whichupdate the snapshot they hold — this brings the plain CPU path in line.
Not changed:
relay_mergestill lets its snapshot follow only the GPU's bytes (relay is off by default and itsmerge reads the copy without writing it).
Credit: Marvisak/VIctory #2513 (Calvix2k, GPL-3.0).
Reimplemented — theirs changes
copy_back_marked, which this tree has no equivalent of (onecopy_backmerges into the copy and keeps one snapshot per submission) — with a
Co-authored-by:trailer and oneCREDITS.md line.
Tests
shadow::merge_tests::a_copy_back_keeps_its_snapshot_in_step: upstream #2436's shape in one piece — a shaderbyte, a title write beside it, the copy-back, then the title writing both again: both stay. Plus the same
piece with the snapshot left behind, which puts the older byte back.
Gates
cargo xwin clippy --target x86_64-pc-windows-msvc --workspace --all-targets -- -D warnings: clean.victory-gpuon the RADV card (VICTORY_TEST_ADAPTER=hw, native dxgi): 207 passed, 2 ignored (the existingbenchmarkand watch benchmarks), 0skipped: no device.cargo test -p victory-shader(Linux): 187 passed, 2 ignored.cargo xtask policy: 244 files ok; the game-name grep is empty.Off switch
None: this only stops a wrong write on the CPU copy-back path (no new work per frame beyond the one extra
store per merged byte).
Not tested in a game run.
Summary by CodeRabbit
VICTORY_DSTORAGE_STAGING_CHECK=0to accept other sizes.