GPU: refreshes of two parts of one page do not make it current whole #2474
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!2474
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2474"
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
BastienRodz:gpu/batch-partial-page-merge→main· +42 −3 · 1 files · 1 commits · openWhat's wrong
Batch::flushmerged a copy's refreshed ranges into its current range whenever they touched. Two flushes of one submission can each refresh part of a 64 KiB page. Neither takes the page then:Tracked::takeleaves a partly covered page changed and unguarded. Their union still counted as current, soBatch::addskipped a later refresh of the whole page and the page was never taken. If shaders marked it,copy_back_markedthen found it changed with nothing saved and dropped their writes (copy_back_pagetoo).What the fix does
One condition in
Batch::flush: a refreshed range joins the current one only when the two meet across a page boundary (max(a, from).div_ceil(PAGE) <= min(b, to) / PAGE). Otherwise the larger one is kept, as before. Every page inside the current range has then been covered whole by one refresh. Whole-page refreshes still join; two halves of one page no longer do.Tests
New
host::batch::partial_flushes_do_not_hide_a_whole_page_refresh: two partial flushes of a page, then a whole-page refresh, a marked shader write andcopy_back_marked. It also checks that whole pages meeting at a boundary still merge, with nothing copied twice.main(940d32f) it fails:marked write goes back,left: 0,right: 65536.host::batch::,shadow::andwatch::pass (14, 1 benchmark ignored). Run under Wine 10 with vkd3d-proton 3.1 on llvmpipe; the test returns early without a host device.Not tested
No title run, and no AMD/NVIDIA GPU. How often a submission refreshes one page in parts and then whole is not measured. #1818, #2349 and #2428 each rewrite
currentas range sets and will conflict with this one-line change. Whichever lands, the rule is the same: touching ranges inside one page are not a whole-page refresh.Fixes #2473
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code
@kotekompotek on GitHub · 2026-11-25 14:28 UTC · original
Verified the merge condition carefully — it is exactly right:
max(a,from).div_ceil(PAGE) <= min(b,to)/PAGE): then every page in the union was covered whole by at least one of the two refreshes, so the union'stakenclaim is honest.takeguards the page, and marked writes go back. That is the reported failure exactly.Note the issue's caveat that #2428's disjoint-range rework has the same hole: its
push_range(gap=0)merges touching ranges incurrent, so two halves of one page still coalesce into full-page coverage. Whichever of these lands second, the touching-merge inpush_rangeneeds the same whole-page condition.The test pins it end-to-end: partial flushes → whole-page refresh actually flushes →
copy_back_markedreturns the page.@BastienRodz on GitHub · 2026-11-25 15:47 UTC · original
Rebased onto main
da82e44(main reworked themod batchtests; ours now sits at the end of it). The one-condition fix inBatch::flushapplied as is. On the new main the test still fails without it (left: 0,right: 65536) and passes with it.@Marvisak on GitHub · 2026-11-25 18:30 UTC · original
Automated triage for the maintainers.
This PR changes one condition in
Batch::flush(crates/victory-gpu/src/host.rs). A refreshed range now joins the copy'scurrentrange only when the two share a page boundary. Before, any touching ranges joined. I checked it againstTracked::takeinwatch.rs, which guards only pages covered whole and leaves a partly covered page changed. On main, two halves of one 64 KiB page merged into acurrentrange that covered the page, soBatch::addskipped a later whole-page refresh and the page was never taken. With the new condition, every page inside a merged range is covered whole by one of the two refreshes. Whole pages meeting at a boundary still merge, and not merging only costs a re-check, sincetakecopies only changed pages.The new test
batch::partial_flushes_do_not_hide_a_whole_page_refreshcovers the failing sequence and uses existing test helpers. It returns early without a host device, so CI alone does not show it ran. The author reports it fails on main and passes with the fix. As the PR body says, it will conflict with the open range-set reworks (#1818, #2349, #2428), which need the same rule.CI:
checkpassing.Generated by Claude Code
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.