Repository navigation
GPU: free host textures only after running submissions, and make them on first use - #431
AntoninMichelq wants to merge 2 commits into
Conversation
The title's descriptor writes and texture releases reach the host at once, from its own threads, while the host runs a submission for most of a second in the world. A descriptor slot rewritten then dropped the resource it held, and a released title texture dropped its host copy, while the running submission still read them: device-removed data showed a page fault inside a freed 1024x1024 BC7 texture, about 65 s into the world (DXGI_ERROR_DEVICE_HUNG, RX 7600). Those objects now go to a retired list tagged with the submission count and are dropped when that submission has been waited for (at once if none is running). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
The world's peak counted 3,630 host textures, 8.9 GB, against a 7 GB video memory budget on an 8 GB card: the driver moves the excess to system memory, where it counts against the commit limit. A texture the title makes and the GPU never uses (no view, target, copy or barrier) now costs nothing; the creation state and clear value are kept for the copy made on first use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
|
Verified Not covered: a title freeing and re-creating textures across submissions (no game data here); the suite has no synthetic case for that lifetime. |
|
NVIDIA / Linux data point for this, since it was tested on an RX 7600. RTX 5080 16 GB, CachyOS, proton-cachyos (vkd3d-proton 3.2.0), Series X 1.0.2.1, diagnostics build of
AI-assisted (Claude Code); numbers from the run's log and |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 23ced70 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed). Not tested in game, so I can't confirm the DRED fault or the memory numbers.
Retirement:
executeholdssubmittedfrom start to finish, so submissions are serial.STARTEDis incremented under that lock, andFINISHED/buryrun after the wait with no early return in between. An object retired while submission N runs is tagged N and dropped after N's wait.- If the wait fails (the "host submission not waited for" path),
burystill drops. That only happens after device removal, so it is acceptable. - Objects retired when no submission is running are dropped at once, so nothing waits on a submission that never comes.
Lazy host copies:
OnceLock::get_or_initmakes the first use race-free across title threads.made_withcopies the 20-byte clear value during the call, as it must.Droptakes the copy withtake().flatten(), so a texture that was never used creates nothing on release.texture_atcallshost()and so creates the copy on an address lookup. That is correct, though it means address lookups count as "first use".
No issues found.
AI-assisted (Claude Code).
…nning submissions, and make them on first use Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows 11 / AMD Radeon RX 6750 XT (RDNA2, 12 GB) validation update:
This confirms a Windows build/test integration only. I did not run the title or exercise the GPU lifetime path, so this is not an in-game validation of the fix on the RX 6750 XT. |
|
Native Windows in-game comparison on an RTX 5070 Ti 16 GB (621.24), Windows 11 26300.9974, Ryzen 7 9850X3D and 32 GB of RAM. Both diagnostics builds used
Both runs were stopped by the same 3 GiB system commit-headroom guard. One run per build, with extra debug logging of shadow allocations in the control. The figures come from Windows process and GPU process memory counters. The samples show lower dedicated GPU memory and private bytes near world entry. They do not isolate the reason for the private-byte difference or establish a frame-rate improvement. AI-assisted (Codex, with Claude reviewing the memory paths). |
|
checked: #431 on RDNA3 | base: result: the longest run we have had: 11 min 39 s in the first mission's intro cutscene (0–1 fps, about 900–6,000 draws/frame), against 2 min 39 s – 5 min 16 s with #609 + #568 + #67 on the same base and machine. It still ends in a device removal of the same family: The freed allocations now include a title buffer (a shadow copy), which #609 retires but #431 does not. Locally I ported #609's two AI-assisted (Claude Code). |
|
follow-up: #431 + #609's buffer/staging retirement | base: result: 18 min 29 s (2,160 frames) in the first mission's intro cutscene, against 11 min 39 s with #431 alone on the same base and machine, and no "inside freed" signature any more. Neither #431 nor #609 alone got rid of it here. What was ported (only these two, everything else is #431 as is): // texture.rs
#[cfg(windows)]
impl Drop for Staging {
fn drop(&mut self) {
crate::host::retire(self.buffer.clone());
}
}
// shadow.rs
#[cfg(windows)]
impl Drop for Shadow {
fn drop(&mut self) {
crate::host::retire(self.buffer.clone());
}
}The run then ends with a different removal, not a freed allocation: That dispatch reads a 768x768 texture and writes a 384x384 one (format 10), so it looks like a downsample pass. Skipping it with AI-assisted (Claude Code). |
|
Independent run of this PR on an RTX 4060 Ti (driver 32.0.16.1656), Windows 11, Ryzen 9 5900X: 15 minutes 12 seconds in the world with no device removal. Before it, the same tree and machine had not survived past 8 min 37 s, and the two runs before that ended at 2 min 27 s and 3 min. Build: the integration tree at Run: diag ( What it looked like before, same machine, same tree, no PR: two removals with two different DRED stops - a Caveat: one run, and the removal was never deterministic on this card, so this is "did not reproduce in 15 minutes", not "fixed". It does move the failure well past every previous run here. It does not change the picture: the world is still black, 170 programs still refuse to translate, and the frame is 2.5-3.4 s at 0.3-0.4 fps in this build - but it is 15 minutes of a frame that runs, which is the first time this machine has produced one. |
…+ Marvisak#1418) + shader stack No textual conflict; checked with cargo check --workspace --all-targets and the full test suite (RTX, WARP, all features) when first merged on the previous Marvisak#1511 head (289f241); this replay with cargo check --workspace --all-targets --all-features, and the full suite at the end of the line.
|
For anyone merging this onto r4tedx's integration/testers: it has one conflict there, in
Built and run in a diagnostics build of integration/testers update 8 with Xeltax/VIcky's commits and this PR, on an RTX 3050 6 GB with 7.9 GB of RAM, in Series S: at about 95 s, still on the loading screen, the process held about 2.6 GB of dedicated GPU memory, and where earlier runs without it, on Xeltax/VIcky alone, had crashed around world entry, the first run with it drew the world for about 4.5 minutes. Note This comment was written by an AI agent (Opus 5.5, Claude Code). |
|
Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1526. Two halves: retiring host objects until running submissions finish exists in main (host::retire/release_retired, slots and lists hold their textures); making host textures on first use is #1526, which also keeps barriers from creating them and has tests. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
…make them on first use Conflict in resource.rs: the base (AnyXboxX) builds a depth/UAV twin with the host copy at creation; Marvisak#431 makes the host copy lazily. Kept Marvisak#431's OnceLock + made_with and moved the twin construction into Resource::host(), so the twin is made with the host copy on first use. host_unordered now goes through host() too.
…sak#67; docs and results
|
@Marvisak the triage above may have missed that #1526 is closed too: its author closed it at 2026-11-24 22:01 UTC as a duplicate of this PR (comment). So the two closed each other, and no open pull request now makes host textures on first use. Checked on Why it matters on small cards, from the runs already posted here: on a 6 GB / 16 GB laptop, this PR took the story load's private memory from 22.7 to 18.2 GB and the GPU memory spilled into RAM from 7.2 to 3.7 GB. 0xKaji measured ~7.85 → ~5.39 GiB of host textures on an 8 GB card. That spill is what pushes these machines to out-of-memory (this laptop blue-screened in the NVIDIA driver at ~24 GB private on 16 GB RAM tonight, on Could this be reopened (it needs a rebase onto current AI use: Claude Code (Claude Opus 5.5) checked the PR states and |
|
Opened the port as #1969 (first-use half only; the retire half is in AI use: Claude Code (Claude Opus 5.5) wrote this. |
Ports the first-use half of Marvisak#431 (AntoninMichelq) onto current main; the other half (freeing host objects only after running submissions) is already in main. A title texture's host copy was made when the title created the resource. Most are never used by a list, and on small cards the rest spills into system RAM: with Marvisak#431 on the older base, a 6 GB / 16 GB laptop's story load went from 22.7 to 18.2 GB private and from 7.2 to 3.7 GB of GPU memory in RAM. `Resource::host` now makes it on first use (a view, a target, a copy, a barrier: every `host_resource` / `host_copy` / `host_transition`), from the creation state and clear value kept with the resource, and registers the texture by memory then. Paths that must not create one (`current`, `alias_source` while it holds `TEXTURES_AT`, `Drop`) read `host_made`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts first use (the first-use half of Marvisak#431)
Requested by 4nto · project thread
Summary
Two changes to host texture lifetimes. Together they stop a GPU hang in the world and halve host texture memory on an 8 GB card.
DXGI_ERROR_DEVICE_HUNG. These objects now go to a retired list, tagged with the submission count. They are dropped once that submission has been waited for, or right away if none is running.OnceLock).What changed
host.rs:retire()and the retired list, emptied after each waited submission.descriptor/host.rs:HostHeap::keepretires the old resource instead of dropping it.resource.rs:Resource.hostbecomes aOnceLockmade byhost()on first use, from the keptmade_with(state, clear value).Dropretires the host copy.This overlaps a little with #135, which keeps replaced resources for some frames. This PR covers texture releases and slot rewrites tied to the submission that reads them, and does not depend on #135.
How it was tested
cargo check --tests -p victory-gpuandcargo check -p victoryforx86_64-pc-windows-msvc(withCARGO_FEATURE_PURE=1) pass.Where 3D rendering stands on an RX 7600 (Windows 11)
These observations come from the integration stack (upstream main plus many open PRs), not from this branch alone.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66