GPU: take back the dynamic descriptor slots of lists that ran when a heap runs short #688
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!688
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-688"
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?
@iurysf on GitHub · 2026-11-24 06:55 UTC · original
iurysf:dynamic-slot-reclaim→main· +504 −20 · 5 files · 3 commits · openRebased onto main
58fed37, which now includes #336, so this is a single commit on main. Tests after the rebase:cargo test -p victory-gpu -- --test-threads=1gives 54 passed, 1 ignored. Clippy-D warningsis clean, with and without diagnostics, andcargo xtask policyis ok.A list holds the dynamic descriptor slots its draws took until the title resets it. Submissions are waited for (
Host::executewaits on its fence withINFINITE), so once a list has run, the GPU no longer reads those slots. On a capped view heap, though, the dynamic pool fills within seconds of entering the world and every further table is refused, so the draw or dispatch is dropped. On NVIDIA that cap is 1,000,000 slots, 65,536 of them dynamic (with #336). On an RTX 4070 we seedropped=65536andno free dynamic descriptor slots.Existing PRs enlarge the pool (#135, #336, now merged), fix the search (#251), share identical tables (#562) or drop the draw (#336). None gives back slots that are no longer read.
Change
HostHeap::dynamichas no room,State::take_dynamictakes back the slots of the oldest list that already ran (descriptor::lease), one list at a time, and retries. Nothing changes while the heap has room.Lease::startandreclaimshare one lock.On the GPU (RTX 4070, driver 32.0.16.2101, base main
d2a4bae+ #493 + #483, default loop limit, 300 s, two runs):Risks
Tests: 5 new unit tests (without
reclaim2 fail; withstartdisabled 3 fail).cargo test -p victory-gpu -- --test-threads=1: 47 passed, 1 ignored (plus the load-flakyframetest, see the separate PR). Clippy-D warningsis clean;cargo xtask policyis ok.No game data used. AI-assisted.
dynamicand give itpush, so code written for the slot list compiles 5c7da7572d@MartinIndra02 on GitHub · 2026-11-24 09:19 UTC · original
Independent Windows + NVIDIA Ampere verification for
bf4e37e:621.24), Ryzen 7 5800X3D, Rust 1.98.1 (x86_64-pc-windows-msvc).cargo test -p victory-gpu --lib -- --test-threads=1: 54 passed, 0 failed, 1 ignored (all 5 newdescriptor::lease::testsanddraw::testspass).No game data used. AI-assisted; tests run on my machine.
@justr4mzi on GitHub · 2026-11-24 09:22 UTC · original
Tested PR #688 (
bf4e37ed) on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2) and Rust 1.98.1 (x86_64-pc-windows-msvc), compared againstmain(02f404e) as baseline.Test results (
victory-gpu)main(02f404e, baseline):cargo test -p victory-gpu -- --test-threads=1->49 passed, 0 failed, 1 ignored(with--features diagnostics:52 passed, 0 failed, 1 ignored).bf4e37ed):cargo test -p victory-gpu -- --test-threads=1: 54 passed, 0 failed, 1 ignored (all 5 new tests indescriptor::lease::testsanddraw::testspass).cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 57 passed, 0 failed, 1 ignored.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy:153 files ok.bf4e37edfast-forwards from02f404ewith#696and#706in its branch history; the 5 new GPU lease/draw tests are specific to#688.AI-assisted test execution (reviewed locally).
@geiyiliyabumo on GitHub · 2026-11-24 09:24 UTC · original
Independent Windows + AMD RDNA4 verification of
bf4e37ed9merged withmain(8e79c80, clean merge): PASS.26100), AMD Radeon RX 9060 XT (driver32.0.32029.2010), Rust1.98.1(x86_64-pc-windows-msvc).cargo xtask policy→asset policy: 154 files okcargo clippy --workspace --all-targets --locked -- -D warnings→ pass (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings→ pass (0 warnings)cargo test --workspace --locked→ 316 passed, 0 failed, 6 ignored (all 5 newdescriptor::lease::tests::*anddraw::tests::*pass under default parallel test execution)VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked→ 55 passed, 0 failed, 1 ignored on RX 9060 XT (0.20s), zero debug-layer messagesVICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked→ 55 passed, 0 failed, 1 ignored on WARP (0.20s), zero debug-layer messagesFINISHEDandLease::rangesis consistent (FINISHED→rangesinreclaimandfinish's prune path;finish's early emptiness check dropsrangesbefore lockingFINISHED), andtake()ensures reset/dropped leases are never double-released.AI-assisted; synthetic tests only, no game files.
@iurysf on GitHub · 2026-11-24 11:48 UTC · original
In-game measurement. RTX 4070 (driver 32.0.16.2101, view heap capped at 1,000,000, so 2^16 dynamic slots). Base = main
58fed37+ #493 + #483, which keeps this GPU alive in the world. 300 s runs, warm cache, default loop limit,DRED=1+GPU_TIMING=1, idle CPU, 2 runs per variant, interleaved.Indirect draws/dispatches dropped because
preparefails, summed over each run's reports, mean of 2 runs:indirect kind 10: prepare failed)kind 2)kind 0, #255)no dynamic slots for its tables(last logged count)prepare→bind→tablessetstable_failedwhenHostHeap::dynamichas no room (the #336 path), so "prepare failed" on indirect draws is largely dynamic-slot exhaustion. Reclaiming the slots of lists that already ran roughly halves the indirect mesh drops.prepare, and the two together remove most of #255's drops.AI-assisted.
@iurysf on GitHub · 2026-11-24 12:24 UTC · original
Two updates.
1. Compatibility with #493. #493 adds
self.dynamic.push((key.0, index, 1))inroot_srv_table, which didn't compile against this PR's renamed field. The new commit3eb8bd2keeps the field nameddynamic(now theArc<Lease>) and givesLeaseapush, so #493 merges and builds unchanged. Checked by mergingpull/493/headonto this branch and running a diag build with diagnostics, which passes. Alsocargo test -p victory-gpu -- --test-threads=1gives 54 passed, and clippy-D warningsis clean.2. What actually makes
dynamic()fail on NVIDIA. I instrumentedHostHeap::dynamicon main58fed37+ #493 + #483 and ran it on the RTX 4070 for 300 s. Every failure was fragmentation, not exhaustion. The requested tables were 4–9 slots, with 325–2,217 slots free in total, but the longest contiguous free run was only 3–8 (range 65,536). No "exhausted" and no "refused outright" cases appeared. That explains why reclaiming lists here helps (−45% indirect mesh drops) but doesn't remove the drops. The bigger lever is the allocator itself: size-class free lists for small tables, or coalescing on release. #251 (searching across the cursor) may cover part of it, and I haven't measured it yet.AI-assisted.
@rpmaster2 on GitHub · 2026-11-24 09:32 UTC · original · edited 2026-11-24 12:31 UTC
Cross-check on Radeon RX 9070 XT 16 GB (RDNA4), Adrenalin 26.11.2 (32.0.32029.2010), Windows 11 26300, Ryzen 5 5600, 32 GB RAM, diag build,
VICTORY_D3D12_DRED=1.Base
main@58fed37(already carries #336's 2^18 dynamic slots and the drop), this branch merged on top, 480 s per run, alternating:So on this host the change neither regresses nor prevents the removal; 5/5 runs die at frame 1100-1300. Earlier 200-240 s runs of both binaries survived only because they were shorter than the crash window - that was my mistake, not evidence of a fix.
The removal is also no longer about slots:
no free dynamic descriptor slotsappears 0 times in every run above, with or without this PR. DRED names a different cause:Across the five runs the fault lands inside a freed host texture: 1024x1024 f98/f99, 2048x2048 f98, 512x512 f29 (flags 0x1), 256x256 f99, always
type 34. In two runs the stopped list is7d85c9cab3c80721, whose tables come from shaderf0c7efd2aceb2aaaand name placed SRVs. The log also reportsa title texture was released while a list not yet reset names its host copybefore the removal.That points at a stale descriptor / use-after-free on a released texture, which #609 targets; I am testing #609 on the same host and will report there. Nothing here needs a change from you - this is only to keep the slot-exhaustion theory from being credited with a fix it does not provide on RDNA4.
Separately, the world stays black for a different reason: 426 shaders refuse translation (354 compute, 38 pixel, 30 mesh, 4 vertex), so their draws are dropped.
No game data in this report: counts, formats, shader hashes and error strings only.
AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.
@erLCoder on GitHub · 2026-11-24 13:08 UTC · original
Independent descriptor-lease tests on GTX 1660 Ti (6 GB), NVIDIA 581.42, Windows 10 22H2 19045.6466, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. Base
58fed37(includes #336), tested PR revision bf4e37e; the PR has since advanced. I added test-only checks requiring NVIDIA LUID 00000000:00017c52 so the two heap fixtures cannot silently skip device creation.cargo test --offline --locked -p victory-gpu --features diagnostics --lib descriptor::lease -- --nocapture --test-threads=1: 3 passed, 0 failed, 0 ignored, 55 filtered.cargo test --offline --locked -p victory-gpu --features diagnostics --lib draw::tests -- --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored, 56 filtered. Both four-slot heap tests confirmed the NVIDIA LUID. They cover completed lease reclamation, running/reset lease protection and allocation retry. Actual GPU re-execution of a reclaimed title command list, real exhaustion, dropped commands and image quality remain untested.Codex prepared the worktree, ran the tests and drafted this report.
@erLCoder on GitHub · 2026-11-24 14:52 UTC · original
Retested updated head
3eb8bd287e949fb80d7d50233897474c4cfe6c70against the earlierbf4e37eresult. The one new commit renames the stored lease todynamicand adds tuple-takingLease::push, withadddelegating to it; this preserves the calling shape needed by the root-SRV work.On Windows 10 22H2, GTX 1660 Ti, NVIDIA 581.42, Rust 1.98.1 and Agility SDK 1.620.2:
descriptor::leasepassed 3/3;draw::testspassed 2/2; the fullvictory-gpulibrary suite with diagnostics passed 57, failed 0, ignored 1. The two heap fixtures were locally instrumented to require D3D12 adapter LUID00000000:00017c52; both printed that LUID, matching the physical NVIDIA probe (software flag 0). This prevents a silent no-device pass. The tests show no regression in their coverage, not proof of real workload reclamation or image correctness. No title run or re-submitted GPU command-list validation was performed for this update.Codex prepared the worktree, ran the tests and drafted this report.
@iurysf on GitHub · 2026-11-24 19:40 UTC · original
Update: two races in the reclaim, found in review, are fixed in
2e42e8b(mainffe310emerged in first, asde20aea; the old head built on a base with thelowers(&words)clippy error).finished()re-read the list after it ran.ExecuteCommandListscalledfinished(l)afterhost.execute, which readsl.state.lease()again. If another thread saw the list's bottom-of-pipe write and reset it in between, the new, not yet submitted lease went into the finished queue and could have its slots taken back (or, after aRelease,lwas freed). Nowlist::starttakes the list'sArc<Lease>before the execution, and only those leases are finished afterwards. Nothing readslistsor the list state afterhost.execute.finish()put the lease in the queue while the second submission could still be running.Leasenow counts submissions in flight (under the queue's lock), andreclaimonly takes a lease with none.Tests:
overlapping_submissions_keep_slots_until_all_finish(fails on the old head: "still running in the second submission") andfinishing_a_started_submission_does_not_reclaim_a_reset_lists_new_slots(reset and release afterstart).cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsclean,cargo test --workspace --lockedpasses (victory-gpu 57 + 1 ignored).AI-assisted.
@Marvisak on GitHub · 2026-11-25 00:35 UTC · original · edited 2026-11-25 16:00 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/list.rs,crates/victory-gpu/src/queue.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
@r4tedx on GitHub · 2026-11-26 06:14 UTC · original
We ran a reclaim of our own on a capped NVIDIA view heap (1,000,000 views, 65,535 dynamic slots), built the way this PR describes. It hit the case the triage flagged, so here is what we found and the rule we settled on, in case it helps this PR along.
Lists submitted again before a reset
The title does submit lists again without resetting them. On our play build, the slot line counts "lists submitted again before a reset" every few seconds. In each 10-minute run it added up to 2,063-3,016 such submissions, about one a frame. In our first run with the reclaim (DP1), none of those lists had been taken back at the time, so nothing was lost: 0 lists not run across all 102 slot lines. That was luck. It held only because the take-backs happened to hit lists the title was done with.
Our rule: a list that the title has submitted again since it last ran, without a reset, is never taken back.
ranflag, set when one of its submissions finishes. When the list is submitted again andranis already set, the lease is markedagain. A reset clears both, because the lease is emptied and starts over.againstays out of the queue of finished lists, andreclaimskips it. Its slots stay with it until the title resets it, as on main.lostpath (refusing to run a list whose slots were taken back) is still there as a guard.In this PR's
descriptor/lease.rs, that would mean the following (a sketch, not tested on this head):again: AtomicBooland aran: AtomicBoolonLease;start: ifran, setagain;finish: setran, and ifagain, don't push the lease ontoFINISHED;reclaim: skip leases markedagain;take: clear both flags.All of this happens under the
FINISHEDlock thatstartandreclaimalready share.In-game counts (RTX 5070, our play build, 10 minutes a run)
Local title data was used for these runs; only counts and timings from the logs are given here.
The play build carries other unmerged changes. These counts are about the reclaim only.
The release path
This PR's
HostHeap::releaseonly clears the slots' flags (afillovern). It doesn't walk the free run beside them, so the cost we bounded on our side doesn't apply here. Our walk came from our own bound on the longest free run (taken to skip searches that can't succeed), which this PR doesn't have.Related
Our commits
They don't apply to this branch. Ours is a separate implementation: the lease lives in
draw.rson a later main. A merge-tree preview of each commit onto39e68e2cconflicts indescriptor.rs,descriptor/host.rs,draw.rs,host.rsandqueue.rs. So the rule above is the useful part, and we're glad to test a rebased head of this PR with it.AI-assisted
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.