GPU: retain page-table layout and copies for lists bound to a released view heap #3106
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!3106
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3106"
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?
@fuzeofficlal on GitHub · 2026-11-26 08:17 UTC · original
fuzeofficlal:fix/gpu-page-table-layout-retention→main· +501 −49 · 3 files · 1 commits · openProblem
Command lists that use title memory already keep the host
ID3D12DescriptorHeap(draw::State::bind_heaps) and the page-tableID3D12Resource(memory::bind) alive across descriptor-heap release. However,memory::bindonly stored the raw heapkey: usizeinStep::Memory,defer_missed, anddefer_after, and completion callbacks looked up the table'sLayoutinSHAREDbykeyafter execution.When a title releases a view heap (
descriptor::Heap::drop->memory::release(key)) while bound command lists are still pending or executing on the GPU:Sharedimmediately dropsShared.layout.copies: Vec<Arc<Shadow>>. If a buffer named in the retained page table was also unregistered, itsID3D12Resourcecan be freed while the GPU still accesses it through the retained page table and descriptor heap.withholding()poisoning:defer_missedcallslayout(key)and gets an emptyLayout::default(), causinghas_missedto returntruefor every marked page (settingMISSED_INand withholding all title-memory writes for the current and next frame), whiledefer_afterdrops all written pages and counts them as missed regions.prepare(key)seeswith_heap(key)returnNoneand skips refreshing dirty copies still named in the retained page table, so shaders read stale host-copy contents.descriptor::Heapstoreshost: OnceLock<Option<HostHeap>>inline insideBox<Heap>, allocating a new heap at the releasedBox<Heap>address reuses bothkeyand theHostHeappointer (s.host). An old bound list'spreparecan rewrite the new heap's page table, and itsdefer_missed/defer_afterdecode its dirty bitmap against the new heap'sLayout—silently dropping writebacks or targeting the wrong copy/page.Shared::newleft the page-table buffer zero-filled before the firstprepare, so if its heap was released before any submission prepared it, lookups evaluatede.x == 0and indexed descriptor slot 0 instead ofself.null.Fix
Shared.layoutinArc<Mutex<Arc<Layout>>>and pass an opaquememory::Binding(carryingkeyand a clone of that shared handle) toHostList::defer_memory,defer_missed, anddefer_after.memory::prepare, identify the liveSharedentry with*k == binding.key && s.host == host && Arc::ptr_eq(&s.layout, &binding.layout). Because the liveBindingkeeps theArcallocation alive, a newShared::newat the samekeyand inlineHostHeapaddress can never alias it. When the heap has been released or replaced,preparefalls back tobinding.layoutso dirty copies in the retained table are still refreshed.(null, 0)entries) inShared::newso even a never-prepared released table routes every lookup to the null descriptor pair, matchingLayout::default().host::withholding::only_programs_using_title_memory_are_withheldwithmemory::tests::gpu_test_lock()so parallel test execution does not race on globalMISSED_IN.Verification
crates/victory-gpu/src/memory.rs(all 3 fail on63bcca43and pass with the fix):memory::tests::a_released_view_heap_keeps_its_layout_and_copies_for_bound_listsmemory::tests::a_new_heap_at_a_released_key_does_not_steal_a_bound_lists_layoutmemory::tests::an_unprepared_released_heap_routes_reads_to_null_and_marks_a_missVICTORY_D3D12_WARP=1 cargo test -p victory-gpu --locked --features diagnostics: 249 passed, 0 failed (verified across 5 consecutive parallel runs).memory/descriptor/withholdingtests passed.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warnings.cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.@Dukestar69 on GitHub · 2026-11-26 08:29 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-gpu --lib memory:: -- --test-threads=1: 10/11 passed on RTX 5090 and WARP (all 3 new released-view-heap tests pass:a_new_heap_at_a_released_key_does_not_steal_a_bound_lists_layout,a_released_view_heap_keeps_its_layout_and_copies_for_bound_lists,an_unprepared_released_heap_routes_reads_to_null_and_marks_a_miss; the only failure is pre-existing#1744lists_share_a_table_and_copies_keep_their_views).cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed on RTX 5090.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly retains page-table layout and copies for command lists still bound to a released view heap and prevents a new heap at a reused key from stealing them.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Marvisak on GitHub · 2026-11-26 08:32 UTC · original
Automated triage for the maintainers.
Verdict: needs work. CI
checkpasses.This PR changes
crates/victory-gpu/src/memory.rsso a list holds aBinding(key plus a sharedArc<Mutex<Arc<Layout>>>) in place of the bare heap key.prepare,defer_missedanddefer_afterthen keep using the table's layout aftermemory::release. I checked it against main:layout(key)does returnLayout::default()once theSHAREDentry is gone, so a list submitted after its heap was released loses its refreshes and copy-backs and counts every mark as a miss. The diagnosis reads as correct.What it needs:
shadow::unregister, and your first test assertstitle() == 0x33after the buffer was released. All the scenarios in the description are synthetic. Please show a run log where the title releases a view heap while a list bound to it is still unsubmitted or executing (for example, a debug line inreleasewhen a bound list exists). That would show the path is real and that writing back into released buffers is wanted.Shared::new(level 1 to block 0, block 0 to(null, 0)) is small and stands on its own. As a separate PR it could be reviewed quickly.gpu_test_lockchange tohost::withholding::only_programs_using_title_memory_are_withheldis a separate test fix as well.With that evidence, or with the PR narrowed to the parts the evidence supports, this would be reviewed for merge.
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.