GPU: remapping one mapping of aliased pages leaves the others guarded #2415
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!2415
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2415"
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:07 UTC · original
BastienRodz:gpu/remap-keeps-alias-guards→main· +57 −2 · 2 files · 1 commits · openWhat's wrong
title_memory_remapped(at, len)marks[at, at + len)changed withchanged, which also walksalias_of. So remapping or unmapping one address of aliased physical pages opens every other address that shows them, and marks their trackers changed without saving, while those addresses still show the same bytes. A copy over such an address that is armed for marked writes then loses the shaders' writes:copy_back_markedsees a changed page with nothing saved and keeps the title's bytes. A later title write there doesn't fault, so nothing is saved either.What the fix does
title_memory_remappedmarks only[first, last)itself (changed_here).Pages that do have a tracker stay guarded and unchanged, as they are when nothing is remapped.
Tests
New
shadow::tests::remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy: two pages mapped ataandb, a copy overaarmed for marked writes, a shader-side byte written in each page, thenbis remapped and the title writes page 1 througha. Both shader writes must go back, and so must the title's write.main(940d32f) it fails at the first check (page 0's shader write goes back).shadow::tests(5),watch::tests(6) andvictory-hle'smodules::xmem::(10). Run under Wine 10 with vkd3d-proton 3.1 on llvmpipe: the copy needs a host device, and the test returns early without one.Not tested
No title run, and no AMD/NVIDIA GPU. Whether the title unmaps one view of pages while a submission writes them through another is not measured. #2021 adds an early return for
len == 0at the top of the same function; the two combine without overlapping lines.Fixes #2414
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code
@kotekompotek on GitHub · 2026-11-25 14:11 UTC · original
Verified on Windows 10 / GTX 1050 at
487f6b4:remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copypasses — real twin mappings, real guard faults.Mechanics check out:
changed→changed_hereis the core fix: an unmap changes only what[first, last)shows; the physical pages still exist through other mappings, so marking the aliases "changed" was wrong — and its side effect (opening the survivors' guards) let the next title write through the surviving mapping land unguarded, nosavedbaseline,copy_back_markedthen dropping the shaders' bytes.open(g, other)fallback is the right stale-guard cleanup: unguard a surviving mapping only when nothing holds it directly or through a remaining alias — a guard kept while any alias is held is still doing its job.@Marvisak on GitHub · 2026-11-25 15:28 UTC · original · edited 2026-11-26 00:20 UTC
Automated triage for the maintainers.
Merge candidate.
title_memory_remapped(crates/victory-gpu/src/watch.rs) now marks changed and opens only the remapped range (mark_changed+open_guarded), instead of going throughchanged, which also opened and marked every alias. A page that loses its alias links is opened only when no tracker holds it, directly or through a remaining alias. The newshadow::tests::remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copycovers the lost-write case.On your reply: the rebase applies exactly the change the second look asked for after #2239 split
changed_here. It matches whatchangedonmaindoes for the range itself, without the alias walk. CI: passing.Generated by Claude Code
@BastienRodz on GitHub · 2026-11-25 15:47 UTC · original
Rebased onto main
da82e44(conflict only in the shadow tests block). On the new main the test still fails without the fix (page 0's shader write goes back) and passes with it;shadow::9/9,watch::12/12.@Marvisak on GitHub · 2026-11-25 22:03 UTC · original
Automated triage for the maintainers, second look (a review against
main, with the PR built and tested).This is right as reviewed. It no longer builds on
main, though: #2239, merged today, splitchanged_herein two. Incrates/victory-gpu/src/watch.rstitle_memory_remapped,changed_here(&mut g, first, last, false);becomesmark_changed(&mut g, first, last, false); open_guarded(&mut g, first, last);. With that change it was built and tested together with the rest.Push the change and it will be reviewed again. Thank you for the contribution.
@BastienRodz on GitHub · 2026-11-25 22:22 UTC · original
Rebased on
main(f3578e3) as5661933, with the change you describe:changed_here(&mut g, first, last, false)becomesmark_changed(&mut g, first, last, false); open_guarded(&mut g, first, last);intitle_memory_remapped.The
shadow::tests(10, includingremapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy) andwatch::tests(15) pass under Wine with vkd3d-proton, andcargo clippy --workspace --all-targets --locked -- -D warningsis clean. The test conflict with #2377'spartial_refresh_under_marked_range_updates_saved_byteswas positional: both tests are kept.@catminou4 on GitHub · 2026-11-25 13:19 UTC · original · reviewed
Remapping one mapping of aliased pages leaves the others guarded (twin_views regression test). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
@DenRakEiw on GitHub · 2026-11-25 14:06 UTC · original · approved these changes
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:cargo test -p victory-gpu shadow::: 5/5 passed on RTX 5090, 5/5 passed on WARP (includingremapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy).cargo test -p victory-gpu watch::tests: 6/6 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 18:18 UTC · original · approved these changes
Looks good. Verified merged onto
main(63bcca43) on Windows 11 (RTX 5090 + Microsoft WARP +VICTORY_D3D12_DEBUG=1):title_memory_remapped(crates/victory-gpu/src/watch.rs:820-836) tomark_changed+open_guardedon[first, last)while opening an unlinkedotherpage only when neitherothernor any remaining alias ofotherhas a holder keeps surviving mapped copies guarded and avoids leaking stale guards on orphaned aliases.cargo xtask policy(191 files ok),cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features), and all 25shadow::tests::(10) +watch::tests::(15) tests pass on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1.aopens its unheld orphan aliasb(no leaked guard) and that in a 3-way alias (xheld,yheld,zunheld), remappingxkeepsyandzguarded while subsequently remappingycleanly opens orphanz.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.