Repository navigation
GPU: retain and retire released host textures, staging, shadow buffers, and descriptor resources across submissions - #609
Conversation
1b6d967 to
2a76496
Compare
…rs, and descriptor resources
2a76496 to
6d8c72b
Compare
|
Tested Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 CI's commands, on the merge
One problem:
Smaller notes
Not tested: the DRED page fault from #557 (needs the title); no game data used. AI-assisted (Claude Code) ran the checks and drafted this comment. |
|
checked: #609 on RDNA3 | base: result: the first mission's intro cutscene runs (0–1 fps), then the device is removed after 5 min 16 s with the signature #609 targets: At 0–1 fps the cutscene makes about 13 submissions a frame, so For comparison on the same machine and base, #431 + #568 + #67 (without #609) ran 11 min 39 s; details on #431. Run-to-run duration varies (2.5–6 min with the same build), so treat the timings as a weak signal. AI-assisted (Claude Code). |
alexander-src
left a comment
There was a problem hiding this comment.
Reviewed and locally tested 6d8c72b merged cleanly onto main 8e79c80 (Windows 11 26200, RTX 5090 driver 621.24, Rust 1.98.1):
cargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passcargo test -p victory-gpu --locked -- --test-threads=1: 51 passed, 0 failed, 1 ignored
A few code-level issues worth addressing before merge:
-
release_late()blocks every background thread onHost::submittedfor the full GPU wait (and risks re-entrant deadlock).
release_late()callscurrent_submission(), which locksh.submitted(crates/victory-gpu/src/host.rs:264-268).Host::execute()holdsself.submitted.lock()across the entire submission, includingWaitForSingleObject(self.event, INFINITE)(host.rs:496-607), which lasts 0.5–1.8 s per world frame. That stalls any recording or streaming thread hittingHostHeap::keep,HostTexture::drop,Staging::drop, orShadow::dropuntil the GPU submission finishes, and makes anyDropfiring whileself.submittedis held (e.g. anArc<Shadow>/Arc<Staging>whose last reference drops insideHost::execute) self-deadlock on the non-reentrantMutex. Tracking the submission counter in anAtomicU64(read withOrdering::Acquireincurrent_submission(), updated insideHost::execute) avoids both. -
Empirical status against #557.
Independent RX 9070 XT DRED runs in #557 (comments by@KingKaomand@h0useadv, including testing this PR directly) still hit the freed-texture page fault withRETAIN_SUBMISSIONS = 3, and the latestkept-scan shows the faulted texture already hadarc=1and zeroHostHeap::keptslots 3.2 s before the fault (consistent with unbounded root-SRV reads past a shadow buffer into freed VRAM holes, which #493 addresses). So this probably shouldn't claimFixes #557unless narrowed to the real cross-thread recording/descriptor-replacement hazard. -
Diff noise.
The branch includes unrelated rustfmt reformatting acrossdescriptor/host.rs,host.rs,resource.rs, andshadow.rs, which makes review and rebasing harder.
AI-assisted code review and local test run; no game data.
|
Thanks for putting this together! Looking through the diff, locking
Static code review only (not executed on hardware); AI-assisted. |
|
Tested PR #609 (
AI-assisted verification and stack testing (reviewed locally). |
|
Tested on RDNA4: Radeon RX 9070 XT 16 GB, Adrenalin 26.11.2 (32.0.32029.2010), Windows 11 26300, Ryzen 5 5600, 32 GB RAM. Diag build, A/B, identical start state:
Both end in
The PR does get further: in the same window it wrote a new checkpoint save, and Context from six earlier runs (3x One correction to my earlier wording in #597, in case it misled anyone: the The crash is deterministic here (every run within 8 minutes, frames 1090-1290), so any probe is easy to check. If you want, I can run with extra logging you point me at, or capture the draws of the stopped list. No game data: texture sizes, formats, shader hashes and counters only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine. |
|
More data, and it does not support the window being the problem. I built this branch locally with
The 64-window removal has the same signature again: So a 64-submission window makes the removal rarer in one run and not in the next; the stale reference either outlives a much longer window than 3, or it comes from a path that does not go through If it is useful, I can instrument locally: print every No game data: sizes, formats, hashes, counters only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine. |
…s (PR Marvisak#693) Allocate Shadow host copies in D3D12_HEAP_TYPE_DEFAULT VRAM and stage dirty 64 KiB page uploads and pre/post GPU-write readbacks through pooled 4 MiB StagingArenas, integrated with bindless prepare (Marvisak#413), page-coalesced refreshes (Marvisak#393), and lock-free retirement (Marvisak#609). Update raw_view_tests::unknown_stride_reads to stage via DEFAULT buffers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on AMD (RDNA3), where Setup: AMD Radeon RX 7900 XTX 24 GB, driver 32.0.32029.2010; Ryzen 7 9800X3D, 32 GB; Windows 11 10.0.26300. Diag build of this PR's head
For comparison, #431 on the same machine and method had no freed-resource fault in three runs, and two of them lasted the full 180 s. Details are on that PR. AI use: Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above. |
|
Tested this PR (head 6d8c72b) on an RX 9070 XT (RDNA 4) with an i5-14600KF, in a diag build with VICTORY_D3D12_DRED=1. It doesn't stop the world crash on this card. On main and with this PR alike, the title loads into the world, runs for a while, then the device is removed by a page fault inside freed textures while mesh shaders draw:
Time in the world before the crash varies from about 15 s to 2.5 min across my runs; with this PR it was 83 s, so no visible change. I can run another build or turn on GBV if that would help. |
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
GPU: count a refresh that copies nothing as skipped in the copy statistics
Summary
Fixes #557.
When the title streams textures or reuses title buffer ranges, it drops CPU-side objects as soon as recording completes. On PC D3D12, dropping the corresponding host resources immediately deallocates GPU virtual address ranges and underlying physical memory, while GPU work (particularly multi-list submissions, indirect draws, and mesh
ExecuteIndirectdispatches reading via descriptor tables) may still be executing or queued on the GPU. This resulted in DRED page faults:Root Cause & Solution
Resourcedroppedself.host: Option<Arc<HostTexture>>. When no active command list named the texture (e.g. indirect mesh draws or compute shaders reading via bindless descriptor heaps),HostTexturewas freed immediately on the CPU. ImplementedDrop for HostTextureto forward itsID3D12Resourcetocrate::host::release_late.texture::forgetremoved entries fromSTAGING, droppingStagingand releasing upload buffers whileCopyTextureRegionmight still be in-flight. ImplementedDrop for Stagingto forward its buffer torelease_late.shadow::unregisterdropped title buffer shadows. ImplementedDrop for Shadowto forwardshadow.buffertorelease_late.HostHeap::keepnow routes displaced resources torelease_lateinstead of inline CPU destruction.RETIREMENT_QUEUEincrates/victory-gpu/src/host.rswith a submission retirement window (RETAIN_SUBMISSIONS = 3). Resources are held across multi-list submissions and drained only after the GPU fence has confirmed execution past their retirement window.Verification
host::tests::deferred_retirement_retains_resources_across_submissionsadded and passing.cargo test -p victory-gpu -- --test-threads=1: 44 passed, 0 failed, 1 ignored.cargo clippy -p victory-gpu --lib -- -D warnings: 0 warnings.cargo clippy -p victory-gpu --features diagnostics --lib -- -D warnings: 0 warnings.cargo run -p xtask -- policy: 151 files ok.