GPU: copy back ordinary writes before retaking shared pages #3108
No reviewers
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!3108
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3108"
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?
@YouKnowWh on GitHub · 2026-11-26 08:22 UTC · original
YouKnowWh:fix/withheld-mark-copy-order→main· +117 −11 · 3 files · 5 commits · openA submission with a missed list can lose a valid GPU write when two distinct host buffer copies cover the same 64 KiB title page. One copy has a held title-memory mark. The other has an ordinary mark for a write to a different byte. Processing the held mark first calls
drop_withheld, which immediately retakes the shared page across copies on a missed submission. The ordinary write then fails to reach title memory.Move the held-page drops after the ordinary marked copy-backs in
copy_back_marks. The regression test executes a missed list with both bitmaps and checks both bytes. The withheld byte must stay at 0x11 and the valid write must change 0x22 to 0xbb.Verified on Windows with a GeForce RTX 5070 Ti, driver 621.14. On main at
63bcca4the fixture returned (0x11, 0x22). With this patch it returned (0x11, 0xbb). The Windows diagnostics victory-gpu suite, run serially, went from 244 passed / 3 failed / 1 ignored (main plus the regression test) to 245 / 2 / 1. The two failures in both runs weredynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views.Related to #3089 and #3099. This reproduces directly on main and is independent of the optimization to reduce the number of dropped pages. #1998 addresses an overlapping withheld interval within a copy. This fixture uses two distinct copies of the same page. No title files are needed. No rendering or performance improvement was measured.
AI-assisted with Codex.
@Dukestar69 on GitHub · 2026-11-26 08:28 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11/11 passed on RTX 5090 and WARP (includingheld_mark_preserves_an_ordinary_write_in_a_shared_page).cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed on RTX 5090.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly ensures ordinary writes on shared pages are copied back before retaking them under a held mark.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Marvisak on GitHub · 2026-11-26 08:32 UTC · original
Automated triage for the maintainers.
Verdict: needs work. CI
checkpasses.In
shadow::copy_back_marks, this PR runs the ordinary marked copy-backs before the held-pagememory::drop_withheldcalls. On a missed submission,drop_withheldcallswatch::retake, which marks the page as changed in every copy.Shadow::copy_back_markedthen returns early (saved.is_none() && t.changed(..)), so the bug you describe for two distinct copies sharing a page is real.The reordering also changes the case where the same copy and page carry both a held mark (memory bitmap) and an ordinary mark. On main that page is retaken first and its copy-back skipped. With this PR,
copy_back_markedwrites the whole differing host page back, and that page includes the bytes the withheld list wrote. Withheld results then reach title memory, whichwithholding()exists to prevent.What it needs:
(copy, page)that also appears among the held pages. One way: resolveheldto pages first and filterpagesagainst it.held_mark_preserves_an_ordinary_write_in_a_shared_page.With that, this looks ready for review for merge.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 08:51 UTC · original · requested changes
The production fix in
crates/victory-gpu/src/shadow.rs::copy_back_marks(75a6a31c) looks solid:heldis populated from a single bitmap scan in ascending word/bit order (trailing_zeros()), soheld.binary_search(n)is valid.markedagainstheldprevents a(copy, page)marked in both bitmaps from leaking withheld writes into title memory, while allowing distinct host copies covering the same title page to copy back their ordinary writes beforedrop_withheld(page, PAGE)retakes the page across all copies.marked.is_empty() && held.is_empty()ensures held-only submissions still rundrop_withheld.Root cause of the CI failure (reproduced locally on Windows 11 + WARP)
Running
shadow::locally shows whycheckfailed on75a6a31c:cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--all-features) andcargo xtask policy: clean.cargo test -p victory-gpu --lib --features diagnostics -- shadow:: --test-threads=1): 12/12 passed.cargo test -p victory-gpu --lib --features diagnostics -- shadow::): failed immediately (10 passed, 2 failed):shadow::tests::marked_pages_go_back_by_the_bytes_the_gpu_changed:both writers' bytes, page 1: left (0, 17), right (187, 17)shadow::tests::marks_of_shaders_using_title_memory_are_held_back:page 1 held back: left (170, 187), right (170, 0)Both new regression tests call
host.execute(&[&list])insideshadow::tests. Because the pre-existing direct-bitmap tests (marked_pages_go_back_by_the_bytes_the_gpu_changedandmarks_of_shaders_using_title_memory_are_held_back) mutate the global mark bitmaps and callcopy_back_markswithout holdinghost.submitted(tracked in#3085), executing submissions concurrently from the new tests steals/clears their bitmap bits under parallelcargo test.To make CI green reliably without waiting on
#3085, please either:shadow::testsagainst submissions (holdinghost.submitted, matching#3085), orcopy_back_marksdirectly in the new tests underhost.submitted(or rebase once#3085merges). Also note that callingcrate::watch::tests::free(p)(MEM_RELEASEonmain) can reuse addresses with leaked trackers under parallel runs until#3085lands.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.