GPU: two partial refreshes of one page make it count as current, so a whole-page refresh is skipped and marked writes are dropped #2473
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#2473
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@BastienRodz on GitHub · 2026-11-25 14:19 UTC · original
What happens
Batch::flush(crates/victory-gpu/src/host.rs) keeps, as a copy's current range for the submission, the union of the ranges it refreshed whenever they touch (from <= b && a <= to). Take two flushes of one submission that each refresh only part of a 64 KiB tracked page, say[p, p + 4 KiB)and then[p + 4 KiB, p + 64 KiB).Tracked::takecopies each part, and the page stays changed and unguarded ("A page whose part in the tracked memory lies only partly in [from, to) is copied in part and stays changed",watch.rs). The union[p, p + 64 KiB)still counts as current, so a later refresh of the whole page in the same submission (Batch::add) is skipped and the page is never taken.After the submission, if shaders marked that page,
copy_back_markedfinds it changed with nothing saved and keeps the title's bytes, which drops the shaders' writes (copy_back_pagedoes the same for page-table writes). A synthetic run shows it: two partial flushes, then a whole-page refresh and a marked write, andcopy_back_markedreturns 0.Expected
A page should count as current only if one refresh covered it whole, so that a later whole-page refresh still takes it. Ranges that meet at a page boundary (whole pages) can keep merging.
Where
crates/victory-gpu/src/host.rs,Batch::flush, withBatch::add's skip of current ranges. #1818, #2349 and #2428 each reworkcurrentinto range sets; the same rule applies there.AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
github-bot referenced this issue2026-11-26 05:08:40 +00:00
@Marvisak on GitHub · 2026-11-25 15:56 UTC · original · edited 2026-11-26 06:48 UTC
Automated triage for the maintainers.
Still on
main(63bcca4),crates/victory-gpu/src/host.rs:Batch::flushmerges each refreshed range intocurrentwhenever it touches what is already there, whether or not the ranges cover whole tracked pages.Batch::addthen skips any refresh insidecurrent.Tracked::takeincrates/victory-gpu/src/watch.rsleaves a page that is only partly in range changed and unguarded, so two adjacent partial refreshes make the whole page count as current without it ever being taken.Open PRs, all conflicting with each other in
host.rs: #2474 (joinscurrentranges only when their overlap holds a page boundary; smallest change), #2540 (a set of whole pages per copy) and #2428 (a larger performance rework using the same join rule as #2474).New since the last triage: a comparison on an RTX 4070 against
main63bcca4found all three merge cleanly and pass each other's tests, but #2540's regression test also passes on unpatchedmain(an earlyshadow.clean()return means nothing is flushed), so it needs a test that fails onmain; one of #2428's tests has the same problem. #2474's test fails onmainand passes with the fix.Generated by Claude Code
@shawshanker18 on GitHub · 2026-11-25 16:41 UTC · original
Tested both fixes for this, each merged onto
main(67e8ae1), on Windows 11 with an RTX 4050 Laptop. Command:cargo test -p victory-gpu --lib.partial_flushes_do_not_hide_a_whole_page_refreshpasses; no failures beyondmain's 2 (NVIDIA view-heap cap).partial_refreshes_do_not_make_a_page_currentpasses; same 2.#2474 changes one condition:
currentranges are joined only when their overlap holds a page boundary.I checked that this keeps the property the issue asks for: every whole page inside
currentwas taken whole by a single refresh.U(current) and a new refreshRcovers a pagePwhole, and they were joined at a boundaryC.Ccannot lie strictly insideP.C <= P.start, both ranges containC, and the one that ends at or pastP.endstarts at or beforeC. So it coversPwhole.C >= P.end, the same argument holds from the other side.U, the property holds by induction.#2540 keeps a set of whole pages per copy instead. It is more code, and partial ranges never count as current, so a repeated partial refresh within a submission is no longer skipped (a small amount of extra work, no correctness difference).
#2474's test also checks the end result: the marked write reaches title memory.
@pawrenity on GitHub · 2026-11-26 04:06 UTC · original
Comparative check of the three open PRs for this issue. All runs were against
mainat63bcca4on an NVIDIA GeForce RTX 4070 with Windows 11, usingcargo test -p victory-gpu --lib -- --test-threads=1andcargo clippy -p victory-gpu --all-targets -- -D warnings. On this cardmainitself has 2 failures (descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, the NVIDIA view-heap cap). Every run below has those same 2 and no others.For the cross-tests, the batch tests that only use
Batch::add/flushwere copied word for word into one module and run on each tree. Each test's "no host GPU" earlyreturnwas changed to apanic!, so a test cannot pass by skipping.mainwithout the fixmain-D warningsmain0de4743marked write goes back, left 0, right 655363a2279fhost::batchtests)a_page_copied_in_two_halves_is_refreshed_whole(left 0, right 65536).a_page_between_flushed_ranges_is_refreshed_when_asked_foralso passes onmain, so it is not a regression test for this issue. The purepush_range/push_copiedtests do not compile without the PR.push_copied, which uses the same join rule as #2474.67f4bb4partial_refreshes_do_not_make_a_page_currentpasses on unpatchedmainThe three PRs conflict with each other in
crates/victory-gpu/src/host.rs(git merge-treereports a conflict for every pair).Why #2540's test passes on
main. The test callscopy.update(pool, len)first, which takes the page and guards it. The two partialbatch.addcalls then return at theif shadow.clean() { return; }check at the top ofBatch::add(host.rs, onmain), so nothing is flushed andcurrentstays empty. The title write that follows makes the page changed, and the whole-page refresh copies it whether or not the fix is present. The fix itself is correct: it only ever refreshes more, and all four cross-tests pass with it. Two smaller notes: pages are recorded by raw 64 KiB boundaries, so the edge pages of a copy that is not page-aligned never count as current (extra copies, not a correctness problem), and the test never frees its pool or drops its copy.Join rule. #2474 (
host.rs,Batch::flush) and #2428 (push_copied) both join two ranges only whenmax(a, from).div_ceil(PAGE) <= min(b, to) / PAGE. With that rule, every whole page inside a joined range was covered whole by one flushed range. On all three PR trees, the end-to-end test from #2474 passes: two partial flushes, a whole-page refresh, a marked shader write, thencopy_back_markedreturns the page.Recommendation. If this issue is fixed on its own, #2474 is the smallest change: one condition, with an end-to-end regression test that fails on
mainand passes with the fix. #2428 contains the same fix inside a larger performance change. If the maintainers want that change, it closes this issue too, and #2474 would then be redundant. #2540 fixes the bug, but its test would need a scenario that fails onmain(for example, #2474's sequence) before it adds regression coverage.AI-assisted (Claude Code).