Repository navigation
GPU: fix marked copy-back across shared 64 KiB pages and sub-page copies - #2434
fuzeofficlal wants to merge 1 commit into
Conversation
|
Verification — head Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, DXC/dxil 1.8.2502.11 (Windows Kits 10.0.26100.0 x64).
Overlap with #2437 / #2377 (all based on
Read the full diff first: no process, network or filesystem code beyond what the PR describes; no game data, dumps, shader names or retail hashes involved. Verified by Claude Code (Claude Sonnet 5.5), an AI assistant; this is a test report, not a code review or approval. |
|
Reviewed at current head — the prepare/commit split is the right shape for both bugs:
Interplay note for triage: this does not subsume #2437 — |
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:
- Fixing marked copy-back across shared 64 KiB pages and sub-page copies passes all shadow copy-back tests cleanly.
cargo test -p victory-gpu shadow::: 6/6 passed on RTX 5090, 6/6 passed on WARP (includingshared_page_marked_copies_do_not_drop_or_dirty_each_otherandsubpage_marked_copy_retakes_its_page_across_rounds).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.
AI-assisted (Gemini 4 Neon).
|
Automated triage for the maintainers. Merge candidate, with a merge-order note. Both bugs are real on Relation to #2437 (merge candidate): this PR removes Nit: the doc on CI: Generated by Claude Code |
794ab08 to
4ac4d3a
Compare
copy_back_marks previously ran watch::writing and t.taken per marked entry inside a single loop, causing two bugs: 1. When multiple Shadow buffers share one 64 KiB title page, an earlier copy's watch::writing marks that page changed on every sibling holder on the page, causing the next unarmed copy on that page to mistake the copy-back for a title write and drop its GPU writes. 2. Sub-64-KiB and unaligned-end Shadow copies skipped t.taken because their slice did not span the full 64 KiB page, leaving the page unguarded and marked changed so later sub-slice refreshes dropped subsequent marked GPU writes. Split copy_back_marks into prepare (unarm and snapshot baselines before any watch::writing), commit (merge and write back changed bytes), and re-take phases (unconditionally re-guard every synced slice's page after all Writing guards drop, unless a later write in the batch overlapped its bytes).
4ac4d3a to
a17ed31
Compare
|
Automated triage for the maintainers, second look (a review against current Closing because the new code leaves copies stale, although both bugs are real (the two tests fail on If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution. |
Summary
copy_back_marks/Shadow::copy_back_marked(introduced incd94d35/940d32f) had two coupled page-tracking bugs affecting sub-allocated buffers that share a 64 KiB title page or do not span a full 64 KiB page:Cross-copy
watch::writingself-sabotage on shared 64 KiB pages:When two
Shadowcopies share a 64 KiB pagepage(e.g. sub-allocated buffers[page, page + 4096)and[page + 4096, page + 8192)) and shaders write both in the same submission via heap-indexed UAVs (where lists do not declare ranges, so neitherTrackedisarmed),copy_back_marksprocessed them sequentially:watch::writingopenedpage / PAGEand markedpage / PAGEaschangedin every holder ing.holders[page / PAGE], including the second copy.saved.is_none() && t.changed(page / PAGE)and dropped its GPU writes (MarkedKept), mistaking the first copy's write-back for a concurrent title CPU write.watch::writingimmediately re-openedpage / PAGEand marked the first copychangedagain.Sub-64-KiB / unaligned-end copies never re-taking their page after
copy_back_marked:copy_back_markedgatedt.taken(&[page / PAGE])onfrom == page && to == page + PAGE, even though[from, to)(page.max(start)..(page + PAGE).min(end)) is already 100% ofself's tracked range withinpage(matchingTracked::takeandShadow::copy_back_page). Every placed buffer withlen < 64 KiBorlen % 64 KiB != 0therefore left its page unguarded and markedchangedin its ownTrackedafter every marked write-back, causing redundant CPU->GPU re-uploads and dropping a subsequent marked write when only a sub-slice view was refreshed.Changes
copy_back_marksincrates/victory-gpu/src/shadow.rsinto three phases:Shadow::prepare_marked: unarmspage / PAGE, skips unarmed pages already changed before any write-back (MarkedKept), and snapshots each slice's baseline[from, to)(savedslice when present, else current title memory) before anywatch::writingopens shared pages.MarkedSlice::commit: fast-paths unchanged unsaved slices (*host == self.before[..]), otherwise merges GPU changes againstbeforeinto current title memory and writes back underwatch::writing.Writingguards drop, callst.taken(&[page / PAGE])for every synced slice (including sub-page copies), unless a later write in the batch overlapped its byte range.shared_page_marked_copies_do_not_drop_or_dirty_each_otherandsubpage_marked_copy_retakes_its_page_across_rounds.Verification
cargo test -p victory-gpu --lib --locked -- shadow(6 passed)cargo clippy -p victory-gpu --all-targets --no-default-features --locked -- -D warningscargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warningscargo xtask policy