GPU: release unused depth-twin scratch buffers via Weak cache and keep 1 spare placement heap #3454
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!3454
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3454"
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?
@Luislariosss on GitHub · 2026-11-27 03:09 UTC · original
Luislariosss:feat/twin-scratch-reclaim→main· +59 −17 · 2 files · 1 commits · openSummary
Reclaims idle D3D12
DEFAULT-heap memory from depth-twin scratch buffers and spare texture-placement heaps:twin.rs):SCRATCHpreviously held strongID3D12Resourcereferences for every power-of-two size class ever created, keeping all scratch buffers alive for the lifetime of the process even after the twins using them were destroyed. StoringWeak<SharedScratch>inSCRATCHandArc<SharedScratch>onTwinpreserves full sharing among live twins of the same size class while automatically releasing theID3D12Resourceonce the lastTwinreferencing it drops. Buffer creation and any duplicate drop also run outsideSCRATCH.lock().placement.rs): lowerSPAREfrom2(128 MiB of idle 64 MiBDEFAULTheaps) to1(64 MiB), returning an extra 64 MiB once textures are evicted while keeping one warm heap to avoid churn at a heap boundary.Validation
cargo test -p victory-gpu --lib -- twin:: placement::: 5/5 passed (including newshared_scratch_reuses_live_buffer_and_releases_when_last_owner_drops).cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): clean.cargo xtask policy: 191 files ok.@Luislariosss on GitHub · 2026-11-27 03:16 UTC · original
Note: the only CI failure on run \45932472460\ (231/232 passed) is the unrelated timing-sensitive test \ictory-gpu::frame::tests::waits_end_on_ticks_and_count_frames\ (this PR only touches \placement.rs\ and \ win.rs). Could a maintainer re-run the failed job?
@oni-swr on GitHub · 2026-11-27 03:27 UTC · original
WARP test report (AI-assisted with Claude; synthetic tests only, no game files)
e746a9e1986f82e907c5d9a6388affa4e1c0ea7a, base:origin/main@63bcca4(this PR's merge base)VICTORY_WARP=1,VICTORY_D3D12_WARP=1, adapter vendor 0x1414 / software flag), DXIL validatordxil.dllfrom the Windows SDK 10.0.26100VICTORY_D3D12_WARPis only honored with--features diagnostics(host.rscreate()); without itcargo test -p victory-gpu --libpicks the hardware GPU. I ran with--features diagnostics.cargo test -p victory-gpu --lib --locked --features diagnostics: 247 passed, 0 failed, 1 ignored (base: 246/0/1; +1 istwin::tests::shared_scratch_reuses_live_buffer_and_releases_when_last_owner_drops, which passes with a WARP device)waits_end_on_ticks_and_count_framespassed on base and on this head here, so it looks like the timing flake mentioned in the CI note (not caused by this change). I did not re-run clippy.Review: no failure found, one point to check. Before, the shared scratch buffer lived for the whole process, so no submission could lose it. Now the
ID3D12Resourceis released as soon as the lastTwindrops. If a recorded or running list still copies through it, that is a use-after-release unless the owningResourceis already dropped only after the GPU is done;host::retireexists for this. I did not verify the drop timing ofResource::twin, so please confirm or retire the buffer. The test returns early when there is no host device; it did run here.@futurepro62 on GitHub · 2026-11-27 08:47 UTC · original
NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head
e746a9e(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.shared_scratch_reuses_live_buffer_and_releases_when_last_owner_drops.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.