GPU/shadow: write only GPU-changed byte runs in relay_merge, card_merge, and card_merge_relay #786
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!786
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-786"
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?
@AscilCH on GitHub · 2026-11-25 07:35 UTC · original
AscilCH:fix/gpu-shadow-relay-and-card-merge-write-changed-runs→main· +285 −67 · 1 files · 1 commits · openSummary
Fix the write-back race (upstream VIctory #2009) across all three default shadow-buffer merge paths in
crates/victory-gpu/src/shadow.rs:Shadow::copy_back_with(back_piece,VICTORY_RELAY=0) was previously updated to write back only the maximal contiguous byte runs modified by the GPU, leaving untouched bytes between the first and last changed byte alone so concurrent title CPU writes in the gap survive.Shadow::relay_merge,Shadow::card_merge, andShadow::card_merge_relaystill wrote back the entire[first..=last]stretch (up to 64 KiB) in a singlewrite_mappedcall, reverting concurrent title CPU writes landing in untouched gap bytes (or insideskipranges incard_merge_relay) betweenread_intoandwrite_mapped.Changes
merged ^ old_title) inmerge_pieceandmerge_card_piece, extract maximal nonzero byte runs viacollect_mask_runs(reused byback_pieceas well) using per-thread scratch (with_merge_scratch), and write back only those runs viawrite_changed_runs.runsintomerge_racesoVICTORY_MERGE_RACE=1diagnostics measure only bytes actually written back to title memory.card_and_relay_merges_emit_only_gpu_changed_runsandwrite_changed_runs_preserves_concurrent_cpu_writes_in_gap) verifying run extraction and proving that both deterministic and concurrent CPU writes in the untouched middle of a 64 KiB stretch are never clobbered.Verification
cargo test -p victory-gpu --locked -- shadow:::30 passed; 0 failed; 0 ignored.cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings incrates/victory-gpu/src/shadow.rs(only pre-existing9376fd6warnings indraw.rsandindirect.rs).cargo xtask policy:171 files ok.(AI-assisted; synthetic unit tests only, no game data.)
@alexodee on GitHub · 2026-11-25 11:09 UTC · original
A cost number that may matter here, from the one path that already writes per run. It is not a review of the correctness part, and I have not run this PR.
With
VICTORY_RELAY=0,copy_back_withwrites onewrite_mappedper run since8dd30ab. On an RTX 3070 Ti Laptop 8 GB with 16 GB RAM (Windows 11, diagnostics build, Series X profile,a26859fplus a few open PRs), medians over gameplay report lines:2119b0e), whole stretch in one callSo on this machine per-run writes cost about 0.9 ms per differing piece in this path.
write_changed_runshas no bound on the number of calls, and this PR uses it inrelay_merge,card_mergeandcard_merge_relay, which are the default paths. I do not know whether their pieces are as scattered, since I did not run the relay. A run with the relay on, comparing the merge times before and after, would tell.If the cost shows up there too,
collect_mask_runslooks like the place for a bound, since all four paths share it here. #857 joins runs less than 64 bytes apart incopy_back, and upstream Marvisak/VIctory#2242 does it under 256 bytes. #690 and Marvisak/VIctory#1024 store from user mode, which leaves the gaps untouched. Joining reopens the race inside the joined gaps, so it is a trade.Limits: one machine, one run per row, and the joined runs each differ from the per-run one by one more switch. More Windows rows in my comment on #857.
AI-assisted (Claude Code). No game data.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.