fix(gpu): never tell a many-views block clean #428
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!428
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-428"
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?
@Luxuride on GitHub · 2026-12-04 02:21 UTC · original
Luxuride:fix/gpu-many-views-not-clean→main· +55 −0 · 2 files · 1 commits · merged 2026-12-05 17:27 UTCWhat is wrong
coveris documented as the place that decides whether a range may be told clean (crates/victory-gpu/src/watch.rs:2296-2303):It implements that by walking
elsewhere(...), butcrates/victory-gpu/src/inplace.rs:655leaves out pages shown in very many views:For a page with more than
MANY_VIEWS(64) views,elsewhereyields nothing,cover's loop body never runs,allstaystrue, andguard_sharedrecords the block clean (crates/victory-gpu/src/watch.rs:2194-2199) althoughprotect_aliaswas never called for those views. They stay writable (pinned by the existing testa_page_of_many_views_is_guarded_one_view_at_a_time), so a write through one of them raises no guard page, the block keeps answering "not written" (guarded_clean), andinplace::follow_texture(crates/victory-gpu/src/inplace.rs:553-556) skips itswrites(...)— the card keeps the pre-write bytes, i.e. a stale texture block, with no diagnostic.The sibling path already re-checks this for itself:
inplace::texture_stamp(crates/victory-gpu/src/inplace.rs:583) testsp.shown.len() <= crate::watch::MANY_VIEWS.The change
crates/victory-gpu/src/inplace.rs— one query next topages_of:crates/victory-gpu/src/watch.rs— one predicate abovecover, one condition added inguard_shared's clean insert:A block of such a page is simply never told clean; it is re-covered (and re-asked) at the next asking. That is the safe direction — more syncing for pages with 65+ views, never a missed write. The other two clean-insert sites (
protect_here,protect'snote) are deliberately untouched: they mark a range clean only after having protected that whole range.Validation
The module is Windows-only (guard pages,
VirtualProtect), so its tests cannot run on this Linux host:cargo clippy -p victory-gpu --target x86_64-pc-windows-msvc --lib: no errors, the 27 pre-existing style warnings unchanged.cargo check -p victory-gpu --tests --target x86_64-pc-windows-msvc: the added test type-checks.a_page_of_many_views_is_not_cleanablepins the predicate:cleanableis true for a two-view page, false once 64 more views are made. It is a unit test of the new gate rather than a guard-page test, because the latter needs a Windows host.Overlap
I checked every open PR that touches
crates/victory-gpu/src/watch.rsandinplace.rs(the guard-bitmap and ray-tracing series): none adds or changesMANY_VIEWS,cover,elsewhere, or a clean insert. No issue mentions the many-views case.@Kal0s-design on GitHub · 2026-12-04 03:00 UTC · original
Ran this natively on Windows 11 (MSVC) with real D3D12, one NVIDIA desktop card plus WARP, against the merge base.
The gate does what it says for the branch it sits in. I got there with a local test (not pushed). Two real views of a pagefile section plus 62 registered filler views, so the page has 64 views and
coverstill walks it. Guardone, which leavestwoprotected as an alias but not clean. Then map a third real view, which takes the page to 65.views_mappeddoesn't open anything at that point becauseviews_of_sectionalready skips pages pastMANY_VIEWS. Guardtwo, write through the third view, guardtwoagain. On the base the last guard returns nothing becausetwowas told clean inguard_shared. With this PR it reports the page. So that's a fail on base and a pass here.The case I'd expect to be more common is still open though. On a page that already has more than
MANY_VIEWSviews, the firstguardof a view sends the block throughprotect_claimed->protect_here->protect_mapped, andnotesets the clean bit there.coverfinds nothing inelsewhereand leaves that bit alone. Second local test, same setup asa_page_of_many_views_is_guarded_one_view_at_a_time. Guardonetwice (the second returns nothing), write throughtwo, which is still writable, then guardoneagain. It returns nothing on the base and on this branch too. I printed the clean bit right after the first guard and it's set on both. So the line in the description saying those two sites only mark a range clean after protecting the whole range doesn't hold for these pages, because the other views were never protected.What I tried locally was putting the check into
coverinstead, so every caller gets it:With that, both local tests pass, and so do
a_page_of_many_views_is_guarded_one_view_at_a_timeand your new test. The block just reads as written at every asking. The fullvictory-gpulib suite with it applied gives the same result as your branch (same 5 known failures, nothing new). It also adds oneviews()lookup per block on every protect run, which might matter on big runs. A cheaper check is probably possible.On impact,
texture_stampnever seals a many-views page, so the texture upload path copies and hashes those levels anyway. I'd expect the visible effect to be in whatguard/writesreport for that view rather than in a stale texture. I didn't trace a real case of that.The new test
a_page_of_many_views_is_not_cleanabledoesn't build on the base sincecleanableisn't there. It pins the predicate and doesn't exercise the guard path.Other runs on this branch
cargo test -p victory-gpu --lib(4 threads, skippingdescriptor::tests::views_die_with_their_resource) gave 340 passed, 5 failed. Those 5 are the ones that already fail on main on this machine, the twoindirect::tests::host_list_*, twopipeline::hostlibrary loads and the flakywatch::tests::the_rest_of_the_one_asking_has_a_number_of_its_own.watch::five times each. The flaky test failed 2 of 5 on the base and 1 of 5 here. I don't read anything into that difference.views_die_with_their_resourcealone crashes with 0xc0000005 5 of 5 on both, so nothing changed there.--all-targetshas the same warnings before and after, nothing new.AI-assisted: yes
07a3bf1f1btoa5e6ee1f4fa5e6ee1f4fto4850199638@Luxuride on GitHub · 2026-12-04 11:12 UTC · original
Thank you — the second case is real and the PR as pushed was not enough. I have adopted your shape:
covernow starts withso every caller gets it, including
protect_run->protect_here, which is exactly the path that set the bit on a pageelsewherenever walked. Thecleanablegate onguard_shared's own insert stays, because that insert happens after itscovercall and would otherwise put the bit straight back; the two together are what your two local tests check.I kept the predicate test and added your guard-path assertion to the existing many-views test instead: after one
guardof a view of a 66-view page,guards().cleanmust not hold the block — the same check you printed by hand, now pinned.On the
views()cost: yes, one lookup per block on every protect run, and I do not have a cheaper correct one either — the block has to know how many views its page has at that moment, and that set changes under it. If it shows up on a big run, the fix is a cached count per page, which is a different (and bigger) change.On impact, I agree the visible effect is more likely in what
guard/writesreport for a many-views view than in a stale texture; I could not trace a stale-texture case either, and the description now says the guard's answer rather than a texture.4850199638to009e89213a