GPU: a submission refreshes a copy's ranges disjoint, not their span #2428
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!2428
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2428"
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?
@borosf on GitHub · 2026-11-25 13:20 UTC · original
borosf:vibe/disjoint-refresh-ranges-842ca5→main· +247 −47 · 1 files · 8 commits · openSummary
Batchmerged every refresh of a buffer copy across a submission into one[min, max]span, so lists asking for distant small parts of one copy (constant buffers through the bindless hulls, heap table ranges, recordedStep::Refreshes) copied everything between them out of title memory. The dossier counts this line as most ofpreparing(~860 ms of a ~1,900 ms Series S world frame; copies ~270 MB ≈ 440 ms).current) is a disjoint set too, so ranges already brought up to date are skipped more often than before.push_range), model-checked against a brute-force coalescer over thousands of random range sequences; unit tests cover the coalescing/bridging rules, and an integration test shows two distant refreshes of one watched copy stay apart.Numbers
Model (no game data; per-frame equivalents of the submission pattern the dossier describes):
Real-world confirmation needs the diagnostics frame log (
preparingMB/ms before/after) on hardware that runs the game.Verification
cargo test -p victory-gpu --libon Intel Arc B580: 143 passed, 2 failed with only the two known Intel heap-cap failures pristine main also has, 2 benchmarks ignored. Includes the newranges_of_a_copy_stay_disjoint,distant_refreshes_of_a_copy_are_copied_apart, and the existing refresh-semantics tests unchanged.claiming: PREPARING-DISJOINT-RANGES (the dirty-range half of H-2.1; per the ledger the adjacent lanes NEW-48 / NEW-53 / GPU-SNAPSHOT-COST are correctness or copy-back redesign, not this).
@borosf on GitHub · 2026-11-25 13:30 UTC · original
Confirmed and fixed in
2b30d3e— exactly as you diagnosed:flush()was feedingcurrentthrough the same one-page coalescing aspending, so two flushed ranges a page apart covered the gap between them and a later request inside it was wrongly skipped.push_rangenow takes the merge gap as a parameter:pendingkeeps the page's coalescing,currentmerges only where flushed ranges touch, so coverage never claims a byte no flush copied. Otherwise the numbers are unchanged.Your pages-0-2-1 sequence is now the regression test
a_page_between_flushed_ranges_is_refreshed_when_asked_for(each flush copies its page), alongside a pure one for the touching-vs-gap rule (the_gap_between_copied_ranges_is_not_covered). Good catch — the fuzzing asserted range-set structure, not the copied-versus-coverage split, so this was beyond what the model could reach.CI is green on
2b30d3e, and verified after the fix on Arc B580:cargo test -p victory-gpu --lib— 145 passed with only the two known Intel heap-cap failures pristine main also has.@DrDarkDK Can you recheck on your local machine?
@kotekompotek on GitHub · 2026-11-25 14:01 UTC · original
Reviewed — the disjoint/pending split is right and fixes the reported miss:
pendingcoalesces with a one-page gap (COALESCE),currentmerges only touching ranges — so coverage can no longer claim bytes no flush copied. That is exactly the pages-0-2-then-1 failure: the old span merge madecurrentcover page 1 after copying only 0 and 2.coveredrequires the request inside ONE range, so a request spanning two adjacent copied ranges still flushes — conservative, correct.current(instead of union-if-touching-else-larger) claims strictly more coverage, which is now precise;title_writtenstill clears both maps wholesale, so the invalidation contract is unchanged.addpushing intopendingviapush_rangealso handles the request-inside-pending case by overlap merge — same as the old span merge.The two pure tests pin both invariants, and the pool tests exercise the reported ordering on a host. CI green.
@kotekompotek on GitHub · 2026-11-25 14:28 UTC · original
Follow-up from #2473/#2474: this PR's
push_range(ranges, 0, ...)merges touching ranges incurrent, which keeps the same hole #2473 describes — two partial flushes of one page ([p, p+4K) + [p+4K, p+64K)) merge into full-page coverage, so a later whole-page refresh is skipped and the page is nevertaken/guarded (marked writes then drop incopy_back_marked). #2474's fix applies here too: merge only when the intersection of the ranges contains a whole page (max(a,from).div_ceil(PAGE) <= min(b,to)/PAGE), so no union claims a page neither refresh covered whole.@BastienRodz on GitHub · 2026-11-25 14:28 UTC · original
A heads-up from #2473 / #2474. In
current, two refreshes that each cover part of one 64 KiB page (e.g.[p, p + 4 KiB)and then[p + 4 KiB, p + 64 KiB)) leave the page changed and unguarded, becauseTracked::taketakes only pages it covers whole. Onmain,Batch::flushstill joins the two touching ranges, so a later whole-page refresh in the same submission is skipped as already current, andcopy_back_markeddrops the shaders' writes to that page. As kotekompotek noted on #2474,push_range(.., gap = 0, ..)here still joins touching ranges, so the same thing happens with this PR. #2474 makes ranges join only where they meet across a page boundary. Whichever of the two lands second should keep that rule. Happy to rebase mine onto yours if this goes in first.@Marvisak on GitHub · 2026-11-25 15:33 UTC · original · edited 2026-11-25 18:28 UTC
Automated triage for the maintainers.
host.rsBatchnow keeps each copy's pending refreshes as disjoint ranges (push_range, which joins ranges within a page), instead of one[min, max]span. Coverage (current) is kept as disjoint ranges too, joined bypush_copiedonly where the intersection of two ranges contains a page boundary. I checked that rule: every whole page inside a joined range was covered whole by one flushed range, so a later whole-page request is never skipped for a page thatShadow::updatedid not guard. That also fixes the split-page case of #2473.coveredrequires the request to fit inside one range, andtitle_writtenstill clears everything. CI (check) passes, but the three host-copy tests return early without a GPU, so CI does not run them (the author reports a run on Arc B580).Notes for the maintainer:
push_copieddoc says "intersection contains a whole page", but the condition tests for a page boundary.Generated by Claude Code
@borosf on GitHub · 2026-11-25 17:15 UTC · original · edited 2026-11-25 17:18 UTC
Rebased as a merge of current main plus a re-application, since main moved the whole Batch area (texture uploads left the batch, the shadow.clean() gate landed). The disjoint-range change now sits on main's current shape: their clean-shadow shortcut stays first, and everything behind it — pending ranges coalescing within a page, coverage merging only where flushes meet — is unchanged from the reviewed semantics, with all four tests back in place (the pages-0-2-1 ordering test included). CI green on the merge head.
Re-verified after the re-application on the same Intel Arc B580 (the card that caught the coverage bug): the full victory-gpu suite passes — 197 passed, the only two failures being the known (#1744 / #1943) heap-cap tests that pristine main also fails on this card, and every one of the batch tests including the reviewer-reported ordering case green on hardware.
@Marvisak Please check it out when you have the time :)
@borosf on GitHub · 2026-11-25 18:07 UTC · original
Implemented at
3a2279f: current joins only where the ranges' intersection contains a whole page — max(a, from).div_ceil(PAGE) <= min(b, to) / PAGE, exactly as @kotekompotek wrote on #2474. My first take joined at any page-boundary touch but still merged overlaps whose intersection held no whole page, which could union two page-flanking flushes into a whole-page claim — this rules that out too. push_range(.., 0, ..) is gone from flush in favor of a separate push_copied.The pure test now pins all four cases — a page apart, meeting inside a page, overlapping without a whole page, and meeting across a boundary / overlapping by a whole page — and a_page_copied_in_two_halves_is_refreshed_whole runs the #2473 ordering on a host: the halves each copy their bytes, neither guards the page, and a later whole-page request in the same submission still refreshes. CI green on
3a2279f.Happy for #2474 to rebase onto this if it lands first — with both sides on the same rule the rebase should be a no-op for the join logic.
@BastienRodz
@DrDarkDK on GitHub · 2026-11-25 13:23 UTC · original · requested changes
I reproduced a missed refresh at
6ce364eon native Windows with an RTX 4070 Ti and WARP. In oneBatch, I requested and flushed pages 0, 2, and 1 separately, in that order.940d32f: each flush copied 65,536 bytes.6ce364e: the flushes copied 65,536, 65,536, and 0 bytes. A directShadow::updateof page 1 then copied all 65,536 bytes, confirming it was still dirty.flush()uses the same one-page gap coalescing forcurrentas forpending. After the first two flushes,currentcovers page 1 even though neither flush copied it. Couldcurrentmerge only overlapping or touching ranges, whilependingkeeps the one-page coalescing?Synthetic test only. No game data used.
AI-assisted with Codex.
@DrDarkDK on GitHub · 2026-11-25 13:38 UTC · original · approved these changes
Rechecked
2b30d3eon native Windows with the RTX 4070 Ti (driver 621.01) and WARP. Flushing pages 0, 2, and 1 separately copied 65,536 bytes each time on both adapters. In my original review of6ce364e, the third flush copied 0 bytes.The batch tests returned 7 passed and 1 benchmark ignored on each adapter. I also reran the regression with a required D3D12 buffer and verified the expected bytes on page 1 after the third flush. This resolves my earlier changes request. The test used synthetic data and covered refresh correctness.
AI-assisted with Codex.
@catminou4 on GitHub · 2026-11-25 14:11 UTC · original · reviewed
Third duplicate of the disjoint-refresh rewrite: identical comment text as #2419, which itself duplicates #2349. Whichever merges first wins; suggest closing two of the three. 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.
@ntgata1-dotcom on GitHub · 2026-11-26 07:46 UTC · original
Measured in the title: preparing 255 → 221 ms a frame (AMD RDNA4 under Wine)
Setup: RX 9070 XT (RDNA4), RADV / Mesa 26.3, Wine 11.22 with vkd3d-proton 3.1-83 from GE-Proton11-14. Diag builds on
main63bcca4, with and without this PR. Warm shader and pipeline cache, scripted input, the first mission's opening, 5-minute runs. The numbers are means over the 5-second frame lines with 1,000 draws or more (37 and 42 per run).No fault, device loss or kernel message in either run. The heavy band is only a few lines per run, so read its drop loosely. The preparing and copies drops held across the run.
Both runs had the same local changes: queues on a worker thread (local, opt-in), #3071, and a wineserver that keeps memory views in a tree. Merged for Wine: #2913, #2919, #2723, #2977, #2703, #1722, #2101, #2249; and #2644 and #454, their switches on. The "with" run also had #2705 merged, switched off.
AI-assisted (Claude Code); numbers from my own runs.
@fuzeofficlal on GitHub · 2026-11-26 12:21 UTC · original · approved these changes
Reviewed and verified at head
3a2279fdand merged ontoorigin/main(63bcca43) on Windows 11 (RTX 5090 + WARP,VICTORY_D3D12_DEBUG=1):Batch::add/flush/title_written(crates/victory-gpu/src/host.rs:2381-2434) cleanly separate pending coalescing (push_rangewithCOALESCE = PAGE,:2438-2461) from flushed coverage (push_copied,:2475-2489). Becausependingstays sorted with pairwise gaps> COALESCE, a single left-to-right sweep inpush_rangenever misses transitive merges.push_copied's join predicatelo.div_ceil(PAGE) <= hi / PAGEholds iff the intersection contains a page boundary, guaranteeing that every whole 64 KiB page inside a joinedcurrentrange was covered whole by a singleShadow::updateand therefore guarded—closing both the pages-0-2-1 gap bug and the#2473split-page hole.covered(:2464-2466) conservatively requires containment within one range,title_written()still flushes and clearscurrent, and coalescing up to one page acrosspendinginteracts safely withShadow::update/shadow.pending(strictly narrower thanmain's[min, max]span).push_copied(host.rs:2474) says "intersection contains a whole page", whereas the condition tests for a page boundary (which is the exact necessary and sufficient condition).git merge-treeagainstorigin/main(63bcca43);cargo xtask policy(184 files ok);cargo clippy -p victory-gpu --all-targets -- -D warningsclean with default features and--all-features(both at3a2279fdand merged onto63bcca43).3a2279fd: RTX 5090 (default)batch::6/6 passed; RTX 5090 +VICTORY_D3D12_DEBUG=1batch::+draw::tests17/17 passed; WARP (VICTORY_D3D12_WARP=1) +VICTORY_D3D12_DEBUG=1batch::+memory::tests+draw::tests22/22 passed.origin/main(63bcca43) withVICTORY_D3D12_DEBUG=1: RTX 5090batch::+draw::tests26/26 passed; WARPbatch::+memory::tests14/14 passed.LGTM.
@slauko on GitHub · 2026-11-26 15:39 UTC · original
Porting the disjoint half to a Linux/Wine line (RTX 3080 Ti, vkd3d-proton
ec20719, uiliannn's base) and measuring the other half, because they are two changes and not one: a copy's ranges that touch are one pass.This line had the span, and
Batch::flushthen calledShadow::updateonce per recorded range anyway. At ~5,000 draws a frame that was 34,282watch::writescalls a frame (18,887 answered from the journal, 16,395 by the kernel), 40.6–41.2 ms, and the same pages copied several times a submission where the title names overlapping views of one buffer — 166–173 MB a frame at 9.7 GB/s, though 83–85% of the sampled words were already equal.Sorting a copy's ranges and updating each run where the ranges touch (
m66, same build otherwise):writescallsTwo notes for porters:
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.