Repository navigation
GPU: a page whose alias cannot be guarded stays changed - #2455
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f):
- Keeping a page marked as changed (and preserving its saved bytes) when an alias cannot be guarded cleanly prevents missed writes.
cargo test -p victory-gpu watch::tests: 7/7 passed (includinga_busy_alias_leaves_the_page_changed_and_keeps_saved_bytes).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
A page whose alias cannot be guarded stays changed. 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.
|
Independent WARP verification of #2455 at Commands (Rust 1.98.1, Windows 11, merged cleanly with
AI-assisted verification by Claude Code (Claude Sonnet 5.5). Software-only: Microsoft Basic Render Driver (WARP, vendor 0x1414, forced by |
|
Verified on Windows 10 / GTX 1050 at The direction is right: an alias that cannot be guarded (a |
|
Rebased onto main da82e44. |
guard_aliases ignored what protect returned. While a write the guards do not see (watch::writing: a kernel read, a DirectStorage write) is under way through one mapping of a physical page, that mapping stays open; taking the page through another mapping still guarded it there, dropped it from the changed pages and dropped the bytes saved of it. Writes through the open mapping then went unseen by the copy, and when the write ended (changed without saving) an armed page was left changed with nothing saved, so copy_back_marked dropped the shaders' writes to it. watch.rs: "taking a page guards every address showing it", and "a page that is mapped but cannot be guarded is left out (it stays changed)". guard_aliases now returns the pages with a mapping it could not guard; take and taken leave those changed. title_memory_aliased marks the page changed when the new mapping of a guarded page cannot be guarded. Co-Authored-By: Gemini 4 Neon <noreply@google.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0a741d6 to
a96d12f
Compare
|
Automated triage for the maintainers. Merge candidate. In On your reply: the switch to Generated by Claude Code |
fyernald
left a comment
There was a problem hiding this comment.
Tested on real hardware: RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1. 193 passed, 3 failed (victory-gpu --lib, the 3 also fail on main here). a_busy_alias_leaves_the_page_changed_and_keeps_saved_bytes passes.
Heads-up: #2561 is the same fix for #2454. The one difference that matters is in title_memory_aliased: this PR marks the newly linked page with changed(..., save = true), #2561 with save = false. When the new mapping is busy, the write the guards can't see may already have landed through it. Saving at that point can store post-write bytes as the page's "before" copy, while save = false keeps what was saved earlier. If you agree, switching that one argument would make the two equivalent, and the maintainers can take either.
…out saving Its bytes may already hold the write under way through it; saved as the page's old bytes, they would be taken for the GPU's at a marked copy-back (review by fyernald). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @fyernald, agreed. If the new mapping can't be guarded because a write the guards don't see is under way through it, its bytes may already hold that write, and saving them as the page's old bytes would get them taken for the GPU's at a marked copy-back. a86706c makes |
fyernald
left a comment
There was a problem hiding this comment.
Thanks. Retested a86706c on the RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1: cargo test -p victory-gpu --lib --locked -- --test-threads=1 gives 193 passed, 3 failed. The 3 also fail on main here: the heap cap (FIND-9) and the Windows 10 castable test (#1999). title_memory_aliased now marks with save = false, so this and #2561 are equivalent, and either can land.
…RAM small buffers & bitmask changed_runs, water texback fence (Marvisak#999), dynamic sky ambient, screen-probe skip, watch alias/refresh fixes (Marvisak#2455/Marvisak#2377), and xgamesave fix
What's wrong
guard_aliasescalledprotecton a page's other mappings and dropped the result. While one mappingbof a physical page is busy with a write the guards do not see (watch::writing: kernel reads and DirectStorage writes into pool views),protectskips it.Tracked::take/takenthrough another mappingastill guardeda, removed it from the changed pages and dropped its saved bytes. Writes through the openbthen went unseen by the copy. When the write ended (Writing::drop, changed without saving), an armed page was left changed with nothing saved, andcopy_back_markeddropped the shaders' writes to it.title_memory_aliasedignoredprotect's result the same way.What the fix does
guard_aliasesreturns the pages that still have a mapping it could not guard. It returns an empty set at once when there are no aliases.takeandtakenleave those pages changed and keep their saved bytes, asprotect's own doc says for a page it cannot guard ("it stays changed"). They are taken at a later refresh, once every mapping can be guarded.title_memory_aliasedmarks the page changed (saving armed pages) when the new mapping of a guarded page cannot be guarded.Tests
New
watch::tests::a_busy_alias_leaves_the_page_changed_and_keeps_saved_bytes:a/bof one page,atracked and armed, a write under way throughb;takeandtakenthroughamust leave the page changed, a write throughbmust still be seen, and the saved bytes must survive the end of the write;Results:
main(940d32f) it fails attake must leave the page changed.watch::tests(7),shadow::tests(4) andvictory-hle'smodules::xmem::(10) pass (Wine 10, vkd3d-proton 3.1 on llvmpipe).Not tested
No title run, and no AMD/NVIDIA GPU. How often the title streams into a pool view while a copy of another mapping of the same pages is taken is not measured.
Fixes #2454
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code