GPU: keep valid marked writes beside withheld ranges #1998
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!1998
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1998"
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?
@Halfect on GitHub · 2026-11-25 02:37 UTC · original
Halfect:fix/marked-withheld-same-page→main· +389 −98 · 3 files · 3 commits · openWhat
Fixes #1976.
copy_back_marksno longer skips a whole 64 KiB page when a missed list's range overlaps it. It now subtracts the withheld ranges and letscopy_back_markedprocess the rest of the page.writingsaves the submission's host bytes as its comparison baseline; an existing title-side snapshot still takes precedence.Regression coverage
saved, another title write between submissions, and a later marked write without an intervening refresh. It checks publication of the later GPU write, preservation of the newer title bytes, and that old withheld bytes do not reappear.Checks
b49aa3f: success.b49aa3f.cargo xtask policy: 182 files ok.git diff --check: clean.victory-gpuon main (host_resourceis unavailable inresource.rs), so local execution was limited to platform-independent checks. GPU execution of the expanded fixture remains to be established by an independent Windows/GPU run.No title executable, world run, or game data was used. AI-assisted (Kimi).
@DesertGamer on GitHub · 2026-11-25 02:40 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:42 UTC · original
Independent Windows verification on RTX 3080. At
1d8754a, the GPU-backed same-page test passes. Restoring the old whole-page skip locally makes that same test fail on the valid write assertion, confirming it exercises the changed path.The failing
withheld_ranges_are_cut_out_without_losing_the_gapsassertion has a one-line expected-value error. The withheld interval[page + 80, page + 120)clips to[page + 80, page + 100), so the second surviving interval ends atpage + 80:With only that expected value corrected locally,
cargo test -p victory-gpu --locked -- --test-threads=1passed 147 tests, 0 failed, 2 ignored. The test tree used upstream940d32f, this PR, #1963 for the neighboring copy-back regressions, and #1751 for the known NVIDIA descriptor-heap failures. All inputs were synthetic.AI-assisted (OpenAI Codex).
@welisonzika14-jpg on GitHub · 2026-11-25 03:01 UTC · original
RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC. No game files, unit tests only.
cargo test -p victory-gpu --lib, run twice.3385794(base940d32f): 143 ok, 2 fail. The 2 are the view heap cap tests thatmainalready fails on NVIDIA (#1744).withheld_ranges_are_cut_out_without_losing_the_gapspasses.1d8754athat same test failed here every time (left: [(131072, 131082), (131122, 131152)],right: [... (131122, 131172)]). The new head fixed it.#2004 covers the same issue (#1976); it also passes here, see there.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
@jeremygold02 on GitHub · 2026-11-25 03:14 UTC · original · edited 2026-11-25 03:23 UTC
Triage verdict — Preferred starting point, needs a regression test (
3385794)Evidence
3385794’s outside-withheld spans as the basis for the #1976 fix. This keeps the writes themselves out of the holes and avoids declaring a divergent page current. There is a second-submission case I’d check before merging:copy_back_markedconsumest.saved(page), then leaveschangedset when holes preventtaken. If the title had changed the page and a later mark arrives without a fresh saved snapshot or intervening full refresh, thesaved.is_none() && t.changed(page)branch can skip the later copy-back.Checks and limits
cargo test --locked -p victory-gpu --lib withheld -- --test-threads=1reported both selected tests passing on this head, including the corrected CPU interval test. The same-page test can return early if D3D12 setup is unavailable, so that local output alone does not establish GPU execution.Next step
This verification was AI-assisted.
@Calvix2k on GitHub · 2026-11-25 03:34 UTC · original
Independent run on Windows 10 19045, RX 7800 XT (RDNA3), your head
3385794:cargo test -p victory-gpu --features diagnostics --lib shadow::— 6 passed, 0 failed, includingwithheld_ranges_are_cut_out_without_losing_the_gapsanda_withheld_range_does_not_suppress_the_pages_other_writes.That is the same result @jeremygold02 got on an RTX 3080 for the next-refresh case that #2004 fails 3/3: your
takencondition ("only when no withheld range was left different") is what makes the second submission not resurrect the withheld bytes. I closed none of these; but from my side this is the implementation to pick for #1976, and #2004's regression idea is already covered here bywithheld_ranges_are_cut_out_without_losing_the_gaps.@Halfect on GitHub · 2026-11-25 06:04 UTC · original
Addressed the second-submission review concern in
b49aa3f.saved, another title write between submissions, then a later marked write with no intervening refresh. It asserts both that the later GPU write is published and that the old withheld bytes do not replace the newer title bytes.writingnow saves the submission's host bytes as its comparison baseline. An existing title-side snapshot still takes precedence; thetakenguard for withheld pages remains unchanged.cargo xtask policypasses (182 files), andgit diff --checkis clean. macOS compilation still stops only at main's existingresource.rs:284host_resourceerror. Windows CI is running; GPU execution of the expanded fixture remains to be established by that run or an independent Windows/GPU run.@Calvix2k on GitHub · 2026-11-25 08:14 UTC · original
Re-verified on
b49aa3f, Windows 10 19045 / RX 7800 XT:cargo test -p victory-gpu --features diagnostics --lib shadow::— 7 passed, 0 failed, including the interleaving case where a title write lands in a withheld range between two submissions.That was the gap in #2004 and it is covered now. From my side this is ready for a maintainer; #2004 is closed, so there is only one implementation left to review.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:56 UTC · original
I compared the two copy-back cases on WARP at the current heads of #1986 and #1998.
82ef681passes the original overlapping snapshot fixture and its own overlap test. With this PR's follow-up fixture adapted to #1986's declaration API, the first write goes back and the next marked write remains zero instead of0x77777777.b49aa3fpasses that follow-up. The original snapshot fixture still copies the first overlapping withheld word0xa5a5a5a5into title memory.1dbad74 ports my earlier
5b6583dsnapshot fix and regression directly ontob49aa3f665964a9e687b475e30e296cee4271ffd, using your existingoutside_withheldhelper. With the follow-up, the same snapshot test keeps both withheld words in the host copy only, and the second marked submission still writes0x77777777. The full WARP GPU suite goes from 149 passed / 1 failed / 2 ignored to 150 passed / 0 failed / 2 ignored. Strict GPU Clippy in both modes and the staged asset policy passed.If you include the follow-up or its regression, please preserve the Git author when cherry-picking it. If you fold it into your own commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@Halfect on GitHub · 2026-11-25 09:12 UTC · original
Thanks @andrewpozdnakov7-jpg — I cherry-picked
1dbad74as2679f3a, preserving your Git authorship.This adds the snapshot-backed overlapping-withholding regression and keeps withheld intervals out of snapshot copy-back while allowing the surviving ranges to retire normally.
CPU-only validation on
2679f3a:cargo test --locked -p victory-gpu --lib withheld_ranges_are_cut_out_without_losing_the_gaps: 1 passed, 0 failed.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 182 files ok.git diff --check: clean.I did not execute the new GPU-backed regression locally; that remains for Windows CI or an independent Windows/GPU run.
@Marvisak on GitHub · 2026-11-25 09:17 UTC · original · edited 2026-11-26 00:22 UTC
Automated triage for the maintainers.
Merge candidate. Re-reviewed after the rebase onto
f3578e3. The PR fixes #1976.copy_back_marksincrates/victory-gpu/src/shadow.rsno longer skips a whole page that a withheld list overlaps.copy_back_markedandcopy_back_or_notnow retire only the spansoutside_withheldreturns, and a page with a hole is not markedtaken. A page that is already changed and has no title-side snapshot gets the submission's host bytes as its baseline (Tracked::save_host,or_insert).disarmclears that baseline after every submission, so a stale one can't carry over. The per-byte merge still goes through main'smerge_writeback, and #2377'spartial_refresh_under_marked_range_updates_saved_bytesis kept. The mark-bitmap tests now hold the submission lock, a#[cfg(test)]accessor inhost.rs.One thing for the reviewer: the rebase removes main's coarse rule in
Host::executethat withheld any ordinary range overlapping a withheld range of the same copy. It changes the assertion in main'swithholding::only_programs_using_title_memory_are_withheldfrom(0, 0)to(0x44, 0x44). That follows from the byte-exact exclusion and reads correctly to me, but it reverses a decisionmainmade recently. The GPU runs in the thread (RTX 3070, RX 7800 XT, WARP) were on earlier heads. The author's run on this head covers the fullvictory-gpulib suite with no new failures.On your reply: thanks for the careful rebase notes and for keeping the co-author's commit intact.
CI: passing (
check).Generated by Claude Code
@upipibi on GitHub · 2026-11-25 10:13 UTC · original · edited 2026-11-25 10:50 UTC
@Halfect Windows GPU run of
2679f3a, as you asked: RTX 3070 (Ampere, driver 616.56, Windows 11).snapshot_copy_back_keeps_overlapping_withheld_bytes_on_the_gpu,a_withheld_range_does_not_suppress_the_pages_other_writes,a_title_write_does_not_suppress_the_next_marked_submission,withheld_ranges_are_cut_out_without_losing_the_gaps) with--test-threads=1: 4 passed, 0 failed in 3 of 3 runs.cargo test -p victory-gpu --locked(parallel), 3 runs. Every run failsdescriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, the NVIDIA heap-cap pair thatmain940d32ffails here too (1 run). Two runs had one more failure each:watch::tests::writes_through_another_mapping_mark_the_tracker(watch.rs:858,left: []). It passes alone 3 of 3, on this PR and onmain.shadow::tests::a_withheld_range_does_not_suppress_the_pages_other_writes, atshadow.rs:1306: "the valid write on the shared page goes back",left: [0, 0, 0, 0],right: [90, 90, 90, 90].Rates (measured afterwards, same build):
--test-threads=1: 0 failures in 20 more runs (23 in total);shadow::andwatch::together, parallel (cargo test -p victory-gpu --lib -- shadow:: watch::): 0 failures in 20 runs;victory-gpusuite on this PR: 10 more runs. Beyond the heap-cap pair,a_withheld_range_does_not_suppress_the_pages_other_writesfailed in none of them (1 of 13 in total), and one run had twowatch::failures (writes_mark_every_tracker_of_their_page,writes_through_another_mapping_mark_the_tracker);main940d32f,watch::alone, parallel: 0 failures in 20 runs.Counted by script over the logs (corrected; I first wrote 4 of 13 and 7%): on this PR, 3 of 13 full parallel runs had an extra failure beyond the heap-cap pair (4 failures in all:
watch::in 2 runs, one of them with two, anda_withheld_range...in 1). Onmain940d32f, 0 of 11 runs. If 3 bad runs were spread at random over all 24, all 3 landing on this PR has a probability of about 14%, so this can't be told apart frommain. The extra failures came only under the full parallel suite, never withshadow::andwatch::on their own.AI-assisted (Claude Code). Synthetic tests only.
@Halfect on GitHub · 2026-11-25 10:42 UTC · original
Thanks @upipibi — that single parallel failure was a real find, and the "passes alone 3 of 3" detail is what pinned it down. Root-caused and fixed in
329c162.Root cause (test isolation, not the copy-back logic). The written-pages bitmap is process-wide, and
copy_back_marksconsumes every set bit, mapping each to its owning copy. Production runs all copy-backs under the submission lock (Host::execute: "one submission at a time from preparation to copy-back"), but the shadow tests set bits and callcopy_back_marksdirectly, outside that lock. In a parallel run, another test's submission — or one of the other mark tests — can consume this test's bits first and copy its page back with the caller's (empty) withheld list; the test's owncopy_back_marksthen finds nothing set. Depending on timing that shows up either as the valid write missing (your run 3) or as the withheld bytes leaking. The race needs two mark-bit tests live at once, which is why it only appears with this PR's added tests and only under parallel scheduling.Fix. The three tests that set bits (
marked_pages_go_back_by_the_bytes_the_gpu_changed,a_withheld_range_does_not_suppress_the_pages_other_writes,a_title_write_does_not_suppress_the_next_marked_submission) now hold the submission lock for their whole body — the same serialization production copy-backs run under. The snapshot fixture goes throughHost::execute, which takes the lock itself, so it needs nothing. No production code changes behavior (+19lines, test-only besides a#[cfg(test)]accessor).Validation on this head (Windows, NVIDIA):
--test-threads=1: 5 passed, 0 failed (the fifth is the range helper).cargo test -p victory-gpu --lockedfull parallel suite, 12 consecutive runs: 0 shadow/watch failures.draw::,bindless::,indirect::,pipeline::library,host::list_scratch, the NVIDIA descriptor heap-cap pair) reproduce identically on unmodifiedmain940d32fbuilt and run the same way (12 runs; same families, same or higher counts), so they are the pre-existing NVIDIA parallel class, not this PR. Your run-1watch::tests::writes_through_another_mapping_mark_the_trackerflake belongs to that class too — this PR doesn't touch the tracking/aliasing paths it exercises.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 182 files ok.git diff --check: clean.If you're willing, a repeat of your parallel RTX 3070 run on
329c162would be the confirmation that counts — your environment is the one that caught it.@upipibi on GitHub · 2026-11-25 10:48 UTC · original · edited 2026-11-25 11:18 UTC
@Halfect Repeated at
329c162on the same RTX 3070 (driver 616.56), same build setup:cargo test -p victory-gpu --lockedfull parallel suite, 10 runs, plus the four new tests with--test-threads=1, 3 runs.a_withheld_range_does_not_suppress_the_pages_other_writespassed in all 10 parallel runs here (before: 1 of 13; p ≈ 0.57, so this alone can't show the fix, though it agrees with it). The four new tests single-threaded: 4 passed, 0 failed, 3 of 3.watch::failure each, beyond the heap-cap pair:watch::tests::kernel_reads_into_guarded_blocks_after_opening(watch.rs:792): "the kernel does not fault into our handler"watch::tests::writes_through_another_mapping_mark_the_tracker(watch.rs:858):left: [],right: [(1892664541184, 1892664606720)]main940d32fshowed nowatch::failure in 11 full parallel runs. Counted by script (corrected; I first wrote 3 of 13): before this commitwatch::failures were in 2 of 13 PR runs, at329c162in 2 of 10. Against 0 of 11 onmain, 2 of 10 has a probability of about 21% of being chance, so it can't be told apart frommain. Your machine showed none in 12. I haven't looked into the cause.AI-assisted (Claude Code). Synthetic tests only.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 10:58 UTC · original
I independently checked
329c162on forced WARP with 16 test threads. All three marked copy-back tests passed in 60 of 60 full GPU suite runs. The eight shadow tests also passed together with one thread. The one additional failure wasbindless::tests::heap_views_follow_writes_through_another_mapping, with the0versus1064result already recorded in #2252. I did not reproduce the separate watch failures in these WARP runs.On the old
2679f3atree, the withheld-range test failed once in a 60-run parallel batch. I also forced a second bitmap consumer after the first mark in that exact fixture and read[165, 165, 165, 165]from bytes that should have stayed zero. The submission lock in329c162covers that interleaving.For the remaining watch failures, #1913 covers a known test fixture that can retain a watch on a freed pool and applies cleanly alongside
329c162. The original GPU snapshot commit2679f3ais still the direct parent. If the contribution is squashed, please retain:Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted. Synthetic tests only.
@Halfect on GitHub · 2026-11-25 11:33 UTC · original
Thanks @upipibi for the rerun on the same RTX 3070 — the target test passing in all 10 parallel runs plus the single-threaded 3/3 is the confirmation I was after, and the statistical framing (2 of 10 vs 0 of 11, ~21% chance) correctly says the remaining
watch::flakes can't be told apart frommainhere. Those two tests exercise watch/aliasing paths this PR doesn't change; as @andrewpozdnakov7-jpg notes, #1913 covers a known fixture that can retain a watch on a freed pool, which is the plausible candidate for that class and applies cleanly alongside this head.Thanks @andrewpozdnakov7-jpg for the forced-WARP 60/60 verification and for reproducing the bitmap-consumer race on the old tree — that's a clean confirmation of the root cause. On attribution: your snapshot fix stands as its own commit
2679f3aon this branch with your Git authorship intact, and if the branch is ever squashed I will retainCo-authored-by: andrewpozdnakov7-jpg <[email protected]>in the final message.Nothing further from my side; ready for review.
@Halfect on GitHub · 2026-11-25 17:45 UTC · original
Rebased onto current main
13f91caand pushed57969ea; the branch merges cleanly again. Main's memory-withholding work landed since the last head, and the rebase reconciles this PR with it:copy_back_markskeeps main's two-bitmap collection andmemory_withheldhandling; the per-page whole-skip is replaced with this PR's per-range filtering, so a page another list also marked still gets its valid writes back beside the withheld ranges. Main's newmarks_of_shaders_using_title_memory_are_held_backandwhat_a_frame_withholds_leaves_the_copies_at_its_endtests are kept and pass.copy_back's exclusion (outside_withheld) retires exactly the allowed bytes, so the coarse suppression loop is removed andonly_programs_using_title_memory_are_withheldnow asserts the finer outcome — the ordinary range overlapping a withheld one goes back without the withheld bytes (0x44at the non-overlapping part) instead of being withheld with it. Flagging this explicitly for review since it adjusts one assertion of a test main landed.snapshot_copy_back_keeps_overlapping_withheld_bytes_on_the_gpu(kept with @andrewpozdnakov7-jpg's authorship) now marks list B's write as a memory writer, which main'smissed && memorygating requires for withholding, and registers the miss only in the withheld iteration — a list with no miss registered is immune to the frame-global withholding latch, which a parallel suite run otherwise leaks across tests (it failed the control iteration here before this fix).Validation on
57969ea(Windows, synthetic tests only):cargo test --locked -p victory-gpu --lib -- --test-threads=1 shadow:: withholding: 13 passed, 0 failed.cargo test --locked -p victory-gpu --lib: 196 passed, 3 failed — the same three failures unmodified13f91cashows on this machine in the same run (192 passed): the NVIDIA descriptor heap-cap pair anddraw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view. No new failures.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 184 files ok.git diff --check: clean.AI-assisted (Kimi).
@Machad3x on GitHub · 2026-11-25 18:26 UTC · original
Setup: RTX 3080 Ti (driver 621.24), Windows 11, a local stack of open PRs merged with main
67e8ae1.On a stack with
7ef96fa(#2280) andb6e75cf(#2409), 6b8d12e conflicts inshadow.rs(copy_back_marked, rewritten aroundput_back) and in a doccomment in
watch.rs. Not tested here.Written with Claude Code; tested locally.
@Halfect on GitHub · 2026-11-25 19:05 UTC · original
Thanks @Machad3x for the stack check. The conflicts you hit are against two still-open PRs (#2280's
copy_back_markedrewrite aroundput_back, #2409'swatch.rsdoc comment), not againstmain— this head (57969ea) rebases cleanly onto currentmain13f91ca. Whichever of the three lands first, I'll rebase this one onto the result.@andrewpozdnakov7-jpg on GitHub · 2026-11-25 19:18 UTC · original
I reran the adapted snapshot copy-back test on 57969ea. On the exact parent 6b8d12e, the held-overlap case copies [A, B, 0] to title memory. With 29bf5b1 in the branch, it copies [A, 0, 0] and the GPU copy still contains [A, B, B]. The no-withholding control copies [A, B, B] on both. Six paired WARP runs gave the same result; the serial GPU suite passed 202 tests with one ignored in each debug setting.
Authored adaptation 29bf5b1 preserves the Git author. Please keep it if the series is rebased again, or add this trailer if it is folded into a different commit:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@Halfect on GitHub · 2026-11-25 19:32 UTC · original
Thanks @andrewpozdnakov7-jpg for re-running the adapted test on
57969eaand confirming the held-overlap case ([A, 0, 0]to title memory, GPU copy retaining[A, B, B], control unchanged). Noted on the attribution: if the series is rebased again I will keep29bf5b1intact with your authorship; if it is ever folded into another commit I will add theCo-authored-by: andrewpozdnakov7-jpg <[email protected]>trailer. Nothing further from my side on this head.@Halfect on GitHub · 2026-11-25 22:40 UTC · original
Rebased onto current main
f3578e3and pushedf3b2a18; the branch merges cleanly again. Main'smerge_writebackrefactor (#2054 follow-through) and the new saved-bytes work (#2239/#2377/#2455) landed since the last head, and the rebase reconciles this PR with them:copy_back_or_notandcopy_back_markedstill retire exactly the rangesoutside_withheldreturns; the per-byte merge now goes through main'smerge_writebackhelper (identical semantics, as its own oracle test pins). Thesyncedpush stays gated on a fullPIECEpiece witht.taken(&synced): a page with a withheld hole never forms a full piece, so it is not marked current — the same outcome main's whole-page filter gives for ordinary ranges.partial_refresh_under_marked_range_updates_saved_bytes(#2377) passes here, adapted only for this PR'swithheldparameters (&[]).watch.rsdoc now covers both sources of saved bytes: the armed first write and the host baseline of an already-changed page.29bf5b1keeps @andrewpozdnakov7-jpg's Git authorship through the rebase, as requested.Validation on
f3b2a18(Windows, CPU-only, synthetic tests only):cargo test --locked -p victory-gpu --lib -- --test-threads=1 shadow:: withholding: 15 passed, 0 failed.cargo test --locked -p victory-gpu --lib: 229 passed, 3 failed — the same three failures unmodifiedf3578e3shows on this machine in a separate worktree just now (225 passed): the NVIDIA descriptor heap-cap pair anddraw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view. No new failures.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 190 files ok.git diff --check: clean.AI-assisted (Kimi).
@catminou4 on GitHub · 2026-11-25 02:48 UTC · original · reviewed
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Keep valid marked writes beside withheld ranges — same cluster as #1986/#2004 (issue #1976); duplicate effort, reconcile before merge.
@fuzeofficlal on GitHub · 2026-11-26 16:40 UTC · original · requested changes
Checked out
f3b2a181677531d73a6ea683cf08819a5306f5demerged cleanly onto63bcca43and verified on Windows 11 with both an RTX 5090 (VICTORY_D3D12_DEBUG=1) and WARP (--features diagnostics,VICTORY_D3D12_DEBUG=1).What looks good
outside_withheld(crates/victory-gpu/src/shadow.rs:940-967) across bothcopy_back_or_not(shadow.rs:432-517) andcopy_back_marked(shadow.rs:532-581) behaves cleanly:n == PIECEensures only whole, non-withheld 64 KiB pages are passed tot.taken, andmerge_writebacksynchronizeshosteven when no GPU bytes changed on a follow-up submission.cargo xtask policy(191 files ok),cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features), and all30/30shadow:: watch:: withholding::tests pass on both RTX 5090 and WARP with D3D12 Debug Layer enabled.[PAGE - 16 .. PAGE + 16)), a concurrent armed title write, and a second submission where page 0 hashost == before(verifying title writes are pulled into host, old withheld bytes do not leak, and both pages return clean) also passed on both adapters.Blocking issue: per-page lock churn and throwaway 64 KiB allocations in
Shadow::writing(crates/victory-gpu/src/shadow.rs:337-350)In the
markedbranch ofShadow::writing:Three things compound here on large shared shadows (such as the 174 MiB / 2,784-page GPU heap whose root UAVs are pushed repeatedly per submission by
draw.rs:924-925without deduplication inHostList::defer_gpu_writeathost.rs:2080-2091):self.changed.0(Mutex<BTreeSet<usize>>) once per page (2,784mutex round-trips per declaration), bypassingt.clean().vec![0; PAGE]andcopy_from_slice(host)run unconditionally beforeTracked::save_host(crates/victory-gpu/src/watch.rs:614-622) checks.entry(page).or_insert(bytes).batch.flush()deletes them: inprepare(crates/victory-gpu/src/host.rs:2351-2358),marked == trueskipsbatch.flush(), so pages dirtied by the title since the previous submission are still int.changedduring allshadow.writing(..., true)calls in that submission, get snapshotted intosaved.bytes, and are then immediately evicted whenbatch.flush()runstake_split()->self.changed.taken(page).Benchmarking 50 marked
writing(base, 174 MiB, true)calls on a 174 MiB (2,784-page) write-watched shadow in--releaseon this machine (Ryzen 9 9950X):origin/main(63bcca43): 16 us clean (~0.3 us/call), 1 us with 200 dirty pages (~0.02 us/call).f3b2a181): 1,073 us clean (21 us/call, ~67x slower), 17,369 us (17.4 ms) with 200 dirty pages (347 us/call, ~640 MiB of throwaway 64 KiB allocations and copies across 50 declarations).Compare
watch.rs:109-111(which movedSaved::armedto sorted runs because 30 us/declaration on the 174 MiB heap was already too hot) andshadow.rs:318-321(which pools snapshots to avoid per-submission allocation churn).Suggested fix
Move the dirty-page baseline capture into a single range helper on
Tracked(e.g.,save_missing_host(from, to, |page| ...)):self.clean().[from, to)to[self.start, self.end), acquireself.changed.0once, and iteratechanged.range(first..last).self.changed.1once and only invoke the closure / allocate a 64 KiBBox<[u8]>when!saved.bytes.contains_key(&page).Optionally, avoiding host-baseline capture for pages that already have a pending whole-page refresh in
batch(or running it afterbatch.flush()) would also eliminate the one-time throwaway snapshot of title-dirtied pages thattake_split()immediately discards.(Minor non-blocking note: in
copy_back_marksatshadow.rs:1029,*a < page + PAGE && page < a + ncan match a zero-length withheld rangen == 0inside a page, leavingheldnon-empty and conservatively skippingt.taken; adding*n > 0avoids that.)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.