GPU: what shaders write beside a root UAV in its pages goes back to title memory #1963
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!1963
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1963"
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?
@oVolkra on GitHub · 2026-11-25 01:47 UTC · original
oVolkra:fix/root-uav-partial-pages→main· +300 −36 · 3 files · 2 commits · openProblem
In programs that use title memory, shaders mark the 64 KiB pages they write, and each marked page goes back after the submission. Pages that a root UAV's range touches are left out (
Map::precise), since the range goes back byte for byte. That loses writes in two cases:shortcut:onMap::precise). A bigger root UAV loses the rest of the page its 1 MiB window ends in.shadow::findgives the innermost buffer, but the page table names the copy holding the whole page. For a buffer that holds its page only in part inside a bigger one, what shaders write through the page table is in the bigger copy. The snapshot is of the small one, and the page is skipped: those writes are lost.Change
Map::precisetakes the range out to whole pages, cut to the copy, for the refresh, the snapshot and the skip alike. Only bytes the GPU changed go back, as before.Layout::others,Step::GpuWrites): refreshed, snapshotted, and copied back byte for byte with the existingShadow::writingandcopy_back. So the bytes written through the root UAV and those written through the page table both go back, whether or not the memory is write-watched.The second point (
e841f64) answers the triage of9d41eb7, which was right. There the bigger copy's page went back throughcopy_back_page, after the root UAV's bytes. In tracked memory that write-back had marked the page changed, so the page-table writes were lost. In untracked memory the whole page went back over the root UAV's bytes.Cost: per root UAV, at most two more pages of its own copy are snapshotted and compared (the range is up to 1 MiB), plus a page-table lookup for each page of the range at submission. Pages read from another copy are also snapshotted and compared there.
Tests
Four synthetic tests write through the page table and mark pages as translated shaders do. All pass now on an RTX 3060 (Windows 11) and on WARP.
[1, 2, 3, 4][0, 2, 0, 4](main)[1, 2][0, 0](main)[1, 2][1, 0](9d41eb7)[1, 2][0, 2](9d41eb7)The last two are new. They also check that the GPU wrote both copies, submit the list again and twice in one submission, and check that a title write beside those bytes is kept. With only the second point of the change turned off they fail as in the table.
On the RTX 3060:
cargo test --workspace --locked --no-fail-fast: the same 5 tests fail as onmain, all NVIDIA ones reported before (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views, twostride_tests,gathers_at_a_level_match_the_hardware).cargo test -p victory-gpu --lockedwith #1751 applied locally: 147 passed, 0 failed, 2 ignored.cargo xtask policypass.Not verified
Not covered
The same loss happens when the inner copy's write is declared without
Map::precise(tested by replacing that call withrefreshandgpu_writes, with the same root UAV:[1, 0]tracked,[0, 2]untracked). This PR does not touch that path.Next to #1869 and #1865, which change the lookup and the bitmap of the same loop, not which bytes go back: a textual conflict is likely, and I can rebase on whichever lands.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
@DesertGamer on GitHub · 2026-11-25 02:17 UTC · original
VIctory V2: community PRs, merged and tested
Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.
Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).
⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.
Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2
Unofficial community fork of Marvisak/VIctory, GPL-3.0.
@BaggyALPHA on GitHub · 2026-11-25 02:23 UTC · original
Independent synthetic verification on Windows with an RTX 3080 (driver 621.24). I tested this PR at
9d41eb7on940d32fwith #1751 (4521591) applied to clear the two already-reproduced NVIDIA descriptor-heap failures.cargo test -p victory-gpu --locked -- --test-threads=1: 145 passed, 0 failed, 2 ignored. Both root UAV copy-back regressions passed.All inputs were synthetic. No title run or frame timing was performed.
AI-assisted (OpenAI Codex).
@Marvisak on GitHub · 2026-11-25 08:21 UTC · original · edited 2026-11-26 01:20 UTC
Automated triage for the maintainers.
Merge candidate. The head is rebased (
2a3016a) and merges cleanly into currentmain. It removes theshortcut:onMap::precise(memory.rs). The root UAV range is now widened to whole 64 KiB pages, cut to the copy, for the refresh, thegpu_writessnapshot and the marked-page skip alike. A newStep::GpuWrites(host.rs) usesLayout::othersto find, at submission, the pages of that range that the page table reads from another copy. It declares them written in that copy too, so they go back byte for byte through the existingShadow::writing/copy_back. The missed-page skip now matches on the copy as well as the address.main's #2172 widened marked refreshes but left this shortcut in place, so the PR does not duplicate it. The four synthetic tests cover the data loss the PR describes, including the same-page tracked and untracked cases from the earlier triage. CI (check) passes on this head.Nit: the doc comment above
none_missedinmemory.rstests is over-indented.Generated by Claude Code
@oVolkra on GitHub · 2026-11-25 10:40 UTC · original
Update for the triage of
9d41eb7: it was right about the second case, ande841f64fixes it.Reproduced. Two new tests write through the root UAV on the inner copy and through the page table in the same page. Expected
[1, 2];9d41eb7gave[1, 0]in tracked memory and[0, 2]in untracked memory, as described.Fix. At submission, the pages of the root UAV's range that the page table reads from another copy are declared as written in that copy too. They are snapshotted and go back byte for byte, so both writes are kept (the first option suggested).
Tests. The four root UAV tests pass on an RTX 3060 and on WARP. With this fix turned off the two new ones fail again with the values above.
cargo test -p victory-gpu --lockedwith #1751 applied locally: 147 passed, 0 failed, 2 ignored. Without it, only the two NVIDIA descriptor-heap tests fail. Both clippy runs andcargo xtask policypass, and CI passes one841f64.Not run with the title, and no frame time measured. A similar loss remains for writes declared without
Map::precise, which this PR does not touch. The description is updated with the details.AI-assisted (Claude Code).
@oVolkra on GitHub · 2026-11-25 19:21 UTC · original · edited 2026-11-25 22:49 UTC
Rebased onto
main(219878a) to resolve the merge conflicts.The two failing GPU tests (
dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views) also fail onmainwithout these changes.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.