GPU: a declared copy-back after a marked one puts the title's older bytes back #2436
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#2436
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@BastienRodz on GitHub · 2026-11-25 13:28 UTC · original
What happens
After a submission,
host.rsrunscopy_back_marks(Shadow::copy_back_markedper marked page) before the copy-backs of declared ranges (Shadow::copy_back).copy_back_markedputs the shaders' bytes into title memory, and the copy takes the title's others (*h = *t). But a declared range over the same page keeps its snapshot of the bytes from before the submission (Shadow::before). When that range'scopy_backruns, every byte the title wrote during the submission (now in the copy) differs from the snapshot and is taken for a shader write. If the title has written it again since the marked copy-back, the older value goes back over it.That is the failure
copy_back's comment warns about: "putting back the copy's older bytes there broke the title's own records". The window is the time betweencopy_back_marksand the declared copy-backs of one submission, while the title's threads keep writing these buffers.A synthetic run with one page that is both marked and declared shows it: a shader writes byte 10, the title writes byte 40 during the submission, then writes 10 and 40 again after the marked copy-back. The declared copy-back writes the whole page back and restores the older values.
Expected
update_busykeeps the snapshot in step with the copy for the same reason: "The same bytes go into the snapshotwritingtook, so copy-back neither takes them for the GPU's nor puts them back over a later title write." A marked copy-back should do the same for the snapshot of declared ranges over its page.Where
crates/victory-gpu/src/shadow.rs,Shadow::copy_back_marked(sincecd94d35). The related case of two overlapping declared ranges (the copy-back not advancing its own snapshot) is part of #261.AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
@Marvisak on GitHub · 2026-11-25 15:50 UTC · original · edited 2026-11-25 18:47 UTC
Automated triage for the maintainers.
Still on main (
13f91ca; nothing incrates/victory-gpuchanged sinceda82e44): incrates/victory-gpu/src/host.rs,copy_back_marksruns before the per-rangeShadow::copy_back. Incrates/victory-gpu/src/shadow.rs,Shadow::copy_back_markedsets the copy's bytes to title memory (*h = *t) but leaves thebeforesnapshot thatwritingtook for declared ranges unchanged.copy_back_or_notthen reads every byte where the copy differs from that snapshot and title memory differs from the copy as a shader write, so title bytes taken in by the marked copy-back can be written back over a later title write.Open PR #2437 addresses it, and a test run on
67e8ae1(RTX 4050 Laptop, Windows 11) shows its regression test passing with no new failures. #2513 has been closed without merging. #2434 (a broader rework ofcopy_back_marks) also merges cleanly and passes its tests. #2437, #2377 and #2434 all changecopy_back_markedand conflict with each other, so the maintainers will need to pick a merge order; the tester suggests the two small ones first and #2434 rebased on top.Generated by Claude Code
@shawshanker18 on GitHub · 2026-11-25 16:41 UTC · original
Tested on
main(67e8ae1), on Windows 11 with an RTX 4050 Laptop. Command:cargo test -p victory-gpu --lib.a_declared_copy_back_after_a_marked_one_keeps_newer_title_writespasses; no failures beyondmain's 2 (NVIDIA view-heap cap). It fixes exactly this:copy_back_markedadvances the snapshot segments over its page, asupdate_busydoes.copy_back_marksfor other bugs: copies sharing a 64 KiB page, and sub-page copies that never re-take their page.Conflicts: #2437, #2377 (#2375) and #2434 all change
copy_back_markedand conflict pairwise. #2172 merges cleanly with #2434.The order with the least rework would be the two small ones first (#2437, #2377), then #2434 rebased on top.