GPU: a withheld range on a marked page does not hold back valid writes there #1984
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1986"
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?
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T02:21:26Z.
Fixes #1976.
The problem
A list's valid write could be lost because another list's withheld range sat on the same 64 KiB page. In issue 1976, list A's bytes at offset 64 retired as zeros because list B's withheld range sat at offset 256 of the same page.
The mechanism: after a submission,
copy_back_marksputs the pages that shaders marked as written through views into title memory. It skipped every page a withheld range touches. A withheld range is one whose writes stay out of title memory: a program using title memory declared it in a list that missed memory. Since a page is 64 KiB, skipping the whole page also dropped any valid list's declared write on it.The fix
copy_back_marksnow takes all of the submission's declared ranges, each with whether it goes back (host.rspasses them all instead of only the withheld ones).Shadow::copy_back_markedwith the newonlyargument; the ranges are cut with a newsubtracthelper).Marks still do not tell lists apart: a page that a withheld list and another list both wrote through views goes back unless the withheld list declared it (the existing shortcut, left as is).
Testing
shadow::tests::a_withheld_range_does_not_hold_back_a_valid_write_on_its_page: declares a valid range and a withheld one on the same marked page, plus a valid one on the next page. It fails with the old whole-page skip (the valid write on the shared page reads back[0, 0]) and passes with the change.shadow::tests::subtract_cuts_ranges_and_joins_overlapscovers the range helper.shadow::tests::a_page_that_went_back_in_part_takes_the_next_marked_writes_back: after a partial copy-back the page stays changed with no saved bytes; a second marked submission on it, refreshed as a marked view is (whole pages), takes the page, and its shader writes plus a title write made during the run reach title memory. With the refresh left out, the second write is lost, so the test would catch a path that skipped it.cargo test -p victory-gpuon an RTX 5070 Ti (driver 621.24): all pass exceptdescriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, which fail the same way onmain(the NVIDIA 1,000,000-descriptor heap cap, #1835).cargo clippy -p victory-gpu --all-targets, with and without--features diagnostics: clean.Not covered
Rebased onto
13f91ca0a5be3csupersedes it: only what programs using title memory write is withheld.0a5be3c, a range is withheld because of the program that declared it, not the whole list. The definition above is updated to match. The marked-page fix itself is unchanged: a withheld range still must not hold back the valid writes on its 64 KiB page.host.rsnow passes all ofbacktocopy_back_marks. The separatewithheldlist (and its slot inrelease_later) is gone.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:48:41Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Withheld range on a marked page doesn't hold back valid writes — part of the withheld-range cluster with #1998 and #2004 (fixes issue #1976): three PRs attacking the same bug; maintainer should pick one. This one looks the most targeted.
Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-25T02:28:11Z.
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.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T02:37:41Z.
I found one more case on your exact
1c2c216036. The marked-page path subtracts withheld ranges, but the snapshot fallback can still copy the overlap of an allowed range and a withheld range into title memory.5b6583d is one commit on your head. Its WARP regression submits two actual buffer copies through VIctory. List A writes two 0x5a5a5a5a words, then B writes two 0xa5a5a5a5 words starting at A's second word. With B withheld, the original head retired [0x5a5a5a5a, 0xa5a5a5a5, 0] to title memory. The fix retires [0x5a5a5a5a, 0, 0] and all three GPU-copy words stay intact. When both lists are allowed, all three words retire.
The focused test passed 10/10 after the fix. The full WARP GPU suite passed 149 tests with 2 ignored, including your marked-page regression. Strict GPU Clippy and asset policy passed.
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:11:56Z.
Thanks @andrewpozdnakov7-jpg, that's a real hole, and thanks for the clear reproduction.
82ef681fixes it. Your commit was a useful reference, but I wrote my own version so I could test it here.Host::executenow collects, per copy, the ranges withheld lists declared in the submission.Shadow::copy_backleaves those bytes alone in game memory and keeps the GPU's bytes for them in the copy, askeep_writesdoes. A 64 KiB piece containing withheld bytes is no longer marked current, since the copy and game memory differ there.The new test
a_withheld_lists_bytes_stay_out_of_an_overlapping_copy_backfollows your scenario. List A writes three dwords and list B writes two, starting at A's third. With B withheld, game memory gets A's first two dwords and keeps 0 under B's, while the copy holds all four. With both allowed, all four go back. Before the change, B's first dword reached game memory. Tested on an RTX 5070 Ti: theshadow::tests pass, and the fullvictory-gpurun has only the two NVIDIA heap-limit failuresmainhas (#1835).@catminou4: on the #1998 and #2004 cluster, this branch now covers both the marked-page and snapshot paths for #1976.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:25:31Z.
Automated triage for the maintainers.
Needs work: needs the maintainer's decision. Thanks for the test and the explanation. Your argument holds up against
main. A marked UAV view is refreshed by whole pages (page_rangeindraw.rsandbindless.rs), and that reachesShadow::update.Tracked::take(watch.rs) then takes and guards those pages and removes them from the changed set. So the nextcopy_back_markedsees either an unchanged page or a saved snapshot, and thesaved.is_none() && changedearly return isn't reached.a_page_that_went_back_in_part_takes_the_next_marked_writes_backchecks this, and it fails when theupdatestep is removed. Leaving the page changed instead of callingtakenis the right choice, because the copy and title memory differ outside the ranges that go back.I no longer see a correctness problem. What remains is that #1998 fixes #1976 in the same functions, and only a maintainer can choose between the two. CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T06:47:53Z.
Thanks for the review. I added the test you suggested in
487598d6:shadow::tests::a_page_that_went_back_in_part_takes_the_next_marked_writes_back. It passes on this branch with no code change. Here's why.The first half of your description is right. On the partial path,
copy_back_markedtakes the page's saved bytes (shadow.rs:506) and returns without callingtaken(shadow.rs:539). Its own write into title memory also marks the page changed (watch::writing,watch.rs:807). So after a partial copy-back the page is changed and has no snapshot. The test asserts this:!copy.clean()after the first submission.The second half doesn't happen in a real submission, because the page doesn't stay changed until the next copy-back. Every marked UAV view is refreshed by whole pages before its lists run:
page_rangeatdraw.rs:937(root views),draw.rs:1905(table views) andbindless.rs:321(heap hulls).Shadow::updateathost.rs:2442.Tracked::takethen takes and guards every whole page in the range, which removes it from the changed set (watch.rs:516).So when the next submission's
copy_back_markedruns, the page is either unchanged (title memory equals the copy from before) or the title wrote it during the run, after it was armed again. In the second case the guard saved its bytes, sosavedisSome. Either way the early return atshadow.rs:507is not reached. The test runs this second submission the way a marked view is prepared (page_range,update,writing(.., true)), with a shader write and a title write on the page during the run. Both reach title memory. With theupdatecall removed, the shader write is lost ([0x5a, 0x5a]instead of[0xc3, 0xc3]), so the test does catch the case you describe if a path ever skips the refresh.I left the page changed on purpose rather than calling
taken. Outside the ranges that go back, the copy keeps the withheld bytes and title memory keeps its own, so the page isn't equal to title memory. Callingtakenwould stop the next refresh from copying title writes made there during the run. The withheld range is retaken afterwards in any case (memory.rs:335-339, called fromhost.rs:1405), and that marks the page changed too.The choice between #1986 and #1998 is yours.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.