GPU: a withheld range holds back only its own bytes of a marked page (#1976) #2002
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2004"
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 Jitheswar on 2026-11-25T02:44:31Z.
Fixes #1976. Claimed on #1633 at 02:21:19 UTC.
Bug:
copy_back_marksskips a whole 64 KiB marked page when any withheld range (a list whose shaders read memory with no copy) overlaps it. So another list's valid write on that page never reaches title memory, because the later per-rangecopy_backhas no snapshot for marked pages. This is exactly @yualk's fixture: same-page marked + miss retires00 00 00 00for both ranges.Fix: one page bit can't say whose write a byte is, so
copy_back_markednow takes the page's withheld byte ranges as holes:keep_writesleaves them and as the whole skipped page used to be.Test:
shadow::tests::a_withheld_range_holds_only_its_own_bytes_of_a_marked_page(synthetic, no game data):Without the fix it fails at step 1 (
[0,0,0,0]instead of[5a,5a,5a,5a]), the issue's symptom.Compared with the two other open PRs for this issue. I ran the same test against each one's head on the same machine:
0vs5a)0vs3c)0vs3c)withheld_ranges_are_cut_out_without_losing_the_gaps:(131122, 131152)vs(131122, 131172))The "next marked write" row is the case I got wrong first myself: leaving the page not taken keeps it marked as changed, and its next marked copy-back is then kept back as a title-changed page. Happy to have this folded into whichever PR the maintainers prefer.
Checked on an RTX 3050 6 GB Laptop (Linux, Proton 11, vkd3d-proton, real device):
victory-gputests: 130 passed / 14 failed. The 14 are identical to plain940d32fon this host (the view heap is capped at 1,000,000, plus vkd3d root-signature refusals).-D warningsis clean, with and withoutdiagnostics.cargo xtask policypasses. rustfmt adds no new differences.main(VRAM), so the world's marked pages weren't exercised in-game.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:48:44Z.
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 holds back only its own bytes of a marked page (fixes #1976) — third PR in the cluster (#1986, #1998, #2004); all three should be compared and one chosen.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T02:47:03Z.
Independent run on Windows 10 19045 with an RX 7800 XT (RDNA3), your head at the time of writing:
shadow::tests::a_withheld_range_holds_only_its_own_bytes_of_a_marked_page— ok.shadow::tests— 5 passed, 0 failed.So the same-page case behaves the same on AMD as in yualk's NVIDIA/WARP fixture: the valid write at 64 and 128 reaches title memory, the withheld 4 bytes stay in the copy and out of title memory, and the no-withhold case publishes both pages.
On the code: clipping
holesper page (a.max(page)/(a+n).min(page+PAGE)) and testing them per byte is the only thing that can be right with one page bit, and theNone(no snapshot) branch keeps the “what differs is the shaders’” rule while skipping held bytes. Nothing I would change.(The one failing test in
victory-gpu --features diagnosticson this host is unrelated: the placed-view sharing test needsID3D12Device10, absent on the Windows 10 system runtime — tracked in #1999/#2005.)Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T03:01:29Z.
RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC. No game files, unit tests only. Head
c14029d(base940d32f),cargo test -p victory-gpu --lib, run twice: 142 ok, 2 fail both times. The 2 are the view heap cap tests thatmainalready fails on NVIDIA (#1744). The newshadowtests pass.One note: in one earlier combined run (
-p victory-gpu -p victory-shader)bindless::tests::heap_views_are_currentfailed once (round 0, dword 0,left: 0,right: 1064). It passed 3 times alone and in the 2 runs above, so it looks intermittent. I cannot say if this PR is involved.#1998 covers the same issue (#1976); it also passes here.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Imported from Marvisak/VIctory. Originally posted by BaggyALPHA on 2026-11-25T03:13:31Z.
I tested the next-refresh concern raised above on Windows/RTX 3080 with the same synthetic fixture on
940d32f+ this PR (c14029d) and separately on940d32f+ #1998 (3385794).This PR failed 3/3: the refresh copied zero bytes and the second copy-back overwrote the title-side value with the previously withheld bytes. #1998 passed 3/3 and all seven shadow tests passed with the added probe.
As a causal check, I locally prevented this PR from calling
takenwhen a page has holes. The new test passed, but the existing fixture's second write then failed in its sequence without an intervening refresh. So the guard is diagnostic evidence, not a complete patch by itself. This fixture tests the next-submission issue specifically. All inputs were synthetic, with no game files used.AI-assisted (OpenAI Codex).
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T03:08:40Z.
Triage verdict — Consolidate with #1998 (
c14029d)Evidence
c14029d,copy_back_markedleaves the withheld bytes different in the shadow, then still callst.takenfor a full page. It also writes the entire page span from a title snapshot, including the holes. A title write into a hole after that snapshot could be overwritten even though the GPU bytes there were withheld.Checks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T03:34:54Z.
Correction to my verification above: I only checked the first submission and the full-page/no-withhold cases, which pass. @jeremygold02's next-refresh fixture (a title-side write into a withheld range, then a refresh and a second copy-back) fails 3/3 here — the unconditional
t.takenfor a page with holes lets the withheld bytes come back later. So "nothing I would change" was too strong.@Halfect's #1998 keeps the same regression and only marks a page taken when no withheld range was left different; it passes that fixture on an RTX 3080 (jeremygold02) and its six shadow tests pass on my AMD host. That is the one I would land for #1976.
Imported from Marvisak/VIctory. Originally posted by Jitheswar on 2026-11-25T06:51:56Z.
Thanks @BaggyALPHA, @jeremygold02 and @Calvix2k. You're right: calling
t.takenon a page with holes lets the withheld bytes come back after a refresh and overwrite the title's write. The comparison table in my description is also out of date: #1998's current head handles the "next marked write" row I listed as lost.I checked #1998 at
b49aa3fon my machine (RTX 3050 6 GB Laptop, Linux, Proton 11, vkd3d-proton): all 7shadow::testspass, 3 runs out of 3, includinga_title_write_does_not_suppress_the_next_marked_submissionanda_withheld_range_does_not_suppress_the_pages_other_writes(the same-page fixture this PR added).So #1998 covers everything this PR does and the case it gets wrong. I'm closing this in its favour for #1976.
AI-assisted (Claude Code).
Pull request closed