GPU: free host textures only after running submissions, and make them on first use #431
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!431
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/431/head"
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?
@AntoninMichelq on GitHub · 2026-11-24 03:16 UTC · original
AntoninMichelq:up/lazy-host-textures→main· +103 −16 · 3 files · 2 commits · closed without mergingRequested 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
@DaviTostes on GitHub · 2026-11-24 03:39 UTC · original
Verified
23ced70on Arch Linux x86_64, Windows MSVC release build under Wine 11.22 (victory-gpu,--test-threads=1): 43 passed, 0 failed, 1 ignored (same asmaind2a4bae, no new test in this head).Not covered: a title freeing and re-creating textures across submissions (no game data here); the suite has no synthetic case for that lifetime.
@desplmfao on GitHub · 2026-11-24 04:45 UTC · original
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
maind2a4bae+ this + #493 (+#336), #185, #436, #462, #440, #514 (+#464), #515, #259, #177, #151, story mode byVICTORY_KEYS. One run, 9 min (about 7 min in the world), stopped by the timer:crashes.log, no new warnings in the log.nvidia-smi, every 10 s) stayed at 9.6–9.7 GB in the world. Earlier runs on this machine without this PR were at 14–15 GB at the same point, though those were older builds of the stack, so the saving is not measured on one build.Memory allocation failed, falling back to system memorycame about as often as without it (215 vs 224 lines, in the same bursts while the world loads), so on this card those are not from running out of video memory as a whole; presumably the CPU-visible heap the shadow buffers live in. Frame time was unchanged (median 3.0 s per world frame here, which is the copy path).AI-assisted (Claude Code); numbers from the run's log and
nvidia-smi.@Mesrine67 on GitHub · 2026-11-24 06:42 UTC · original
Windows 11 / AMD Radeon RX 6750 XT (RDNA2, 12 GB) validation update:
23ced703with PR #568 head0845e8d5in a clean staged integration (treed5e66d81ff8a78307c41b6d079101b7d3859f5a7).cargo test --workspace --locked -- --test-threads=1: 268 passed, 4 ignored, 0 failed.cargo build --profile diag --locked -p victory --features diagnostics: passed.--execute: four title DLLs bound, zero missing imports; the log explicitly confirms that the title was not executed.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.
@SkillIssueXO on GitHub · 2026-11-24 09:26 UTC · original
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
main8e79c80+ #493c48b240, #20605981ddand #189d0fd9bf. Series S mode, same saved state and startup input, separate empty caches, default shader loop limit and DRED off. The second build added both commits of this PR (133609band23ced70).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).
@d1ll3x3 on GitHub · 2026-11-24 09:49 UTC · original
checked: #431 on RDNA3 | base:
main@8e79c80+ #431 + #568 + #67 (the three apply cleanly together; #431 conflicts with #609, so this run has no #609) | on: Windows 11, RX 7800 XT (RDNA3, 16 GB), 32 GB RAM, diag build,VICTORY_D3D12_DRED=1, Xbox Series 1.0.2.1result: 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
Dropimpls (ShadowandStaginghand their buffer to #431'sretire) on top of #431; one run of that went 4 min in the cutscene with no device removal before the window was closed, so not conclusive yet.AI-assisted (Claude Code).
@d1ll3x3 on GitHub · 2026-11-24 10:11 UTC · original
follow-up: #431 + #609's buffer/staging retirement | base:
main@8e79c80+ #431 + #568 + #67, plus #609's twoDropimpls ported onto #431'sretire(below) | on: Windows 11, RX 7800 XT (RDNA3, 16 GB), 32 GB RAM, diag build,VICTORY_D3D12_DRED=1, Xbox Series 1.0.2.1result: 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):
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
VICTORY_SKIP_PIPELINESgave a short run (1 min 27 s) ending in a device hang without a page fault on a mesh draw (op 42,mesh 04b9be3756e8f41c,pixel 1af4a50c7fb40c97), the kind reported in #71 and #264. Duration varies a lot between runs, so one run each is a weak signal; the "inside freed" disappearance is the solid part.AI-assisted (Claude Code).
@rocobalt1 on GitHub · 2026-11-24 11:10 UTC · original
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
2b1a569(about 50 PRs onmain) plus this branch23ced70, merged locally. One conflict, inresource.rs: the tree'sHostTexturecarries atwin(the depth+UAV mirror made byhost_twin), and moving the construction into the lazyhost()dropped it. I kept it there -made_withis read, the host texture is made on first use, andBOTH(depth|x) flags still build the twin - and it compiles and runs. If you rebase onto the tree, that is the one place to carry over.Run: diag (
--profile diag --features diagnostics),VICTORY_NO_WATCHDOG=1,VICTORY_D3D12_DRED=1,VICTORY_SHADER_LOOP_LIMIT=32, driven withVICTORY_KEYS(Enterevery 3 s for the first two minutes, then every 50 s), reached the first control prompt and stayed there.TdrDelay=60/TdrDdiDelay=60are set machine-wide on this box, so a hang here would have taken 60 s to report rather than 2 s - the run was not removed early by a short TDR.What it looked like before, same machine, same tree, no PR: two removals with two different DRED stops - a
1x1x1compute dispatch (list carrying markerSome(21), command 4 of 9, op 6) and a mesh draw (command 720 of 2201, markerSome(9), op 42, mesh38ad582f523fd7cf+ pixeld42a2d8a9d2c954a), no page fault reported in either; and one run that reached 8 min 37 s before being removed. Those are on #71 with the breadcrumbs.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.
@AntoninMichelq on GitHub · 2026-11-24 11:29 UTC · original
Thank you, that's a great data point: 15 minutes 12 seconds in the world on an RTX 4060 Ti with no device removal, where the same tree without this PR was removed after 2-9 minutes. I agree it's "did not reproduce in 15 minutes", not "fixed", given how random the removals were.
Thanks also for the note on the HostTexture twin. Upstream main has no host_twin yet, so this branch doesn't carry it. If the twin lands first, I'll keep it the way you did: made_with is read, the host texture is made on first use, and BOTH (depth|x) flags still build the twin.
@zGLados on GitHub · 2026-11-24 12:07 UTC · original
Tested
23ced703on an RX 7700 XT (RDNA3, 12 GB, driver 32.0.32015.7029), Windows 11 10.0.26300, Ryzen 7 7700X, 32 GB, title 1.0.2.1. The device removal did not reproduce in 6 minutes in the world (killed at 8 min).Both runs:
mainffe310e+ #197 (scripted keys with a pad connected), diag build,VICTORY_D3D12_DRED=1, the same scripted keys from a fresh start into the first mission.inside freed ["texture 1024x1024 f98 flags 0x0 (type 34)"](same signature as #557)inside freedlinesWith #431, the world runs at about 1.4 fps (50 frames in ~35 s, host submissions ~350 ms). The picture stays black except for the subtitles, as the README describes.
cargo test -p victory-gpu --features diagnostics: 53 passed, 0 failed. This is one run each, so I'd call it "did not reproduce in 6 minutes", not "fixed".Written by Claude Code (Claude Opus 5.5), which ran the commands; the title ran on my machine.
@erLCoder on GitHub · 2026-11-24 13:10 UTC · original
Resource regression test data point 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. A: parent
d2a4bae. B: PR23ced70, including deferred retirement and lazy texture creation.cargo test --offline --locked -p victory-gpu --features diagnostics --lib resource::tests -- --nocapture --test-threads=1— 6 passed, 0 failed, 0 ignored, 40 filtered on each revision. The tests cover resource mapping, upload footprints and transfer to a host texture. A fixture may skip its D3D12 path if device creation fails, so the counts alone do not establish that all GPU paths executed. A separate D3D12 probe identified the GTX LUID 00000000:00017c52.Paired title runs measuring dedicated/shared GPU memory, system commit, host texture count, lifetime during in-flight submissions, loading time and image quality remain pending. Codex prepared the worktrees, ran the tests and drafted this report.
@EgoraWyn on GitHub · 2026-11-24 14:26 UTC · original
Test report: NVIDIA RTX 3060 Laptop 6 GB (Ampere). With this PR the world stays inside the card's video-memory budget in both console modes; without it, it is 1–4 GB over.
Setup: Windows 11 build 26300, driver 596.21 (32.0.15.9621), i5-12450H, 32 GB RAM, title 1.0.2.1 (own copy), Rust 1.98.1, diag build, the process held to 4 logical CPUs.
Base:
mainffe310e+ #493 (c48b240) + #206 (05981dd) + #189 (b472733) + #454 (d2c93fa) + #211 (24a387d) + #492 (b57e10d) +MIN_DYNAMIC = 1 << 18(#747) + the log line of #952 (DXGI's local use and budget every 5 s). This PR at23ced70merges onto it without conflicts.VICTORY_NO_WATCHDOG=1 VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_D3D12_DRED=1, 420 s per run, scripted keys.Windows gives the process a budget of 5226 MB on this card (5994 MB).
One caution on reading the saving: host textures are now made on first use, and most world draws are still dropped on this card (wave64 mesh programs, untranslated shaders). Textures that nothing reads yet cost nothing with this PR, so the gap to the base will shrink as more of the scene is drawn.
The Series X base run started from a finished profile (the title skips its first-run setup), the other three from a fresh one; one run per cell.
AI use: Claude Code (Claude Fable 5.2) built the trees, ran the runs and wrote this report from the logs; a second tool (Codex) checked the numbers against the logs. The hardware, the title copy and the runs are the user's.
@AgneyaK on GitHub · 2026-11-24 17:41 UTC · original
Test report from a 6 GB card with 16 GB of RAM, where this PR makes the biggest difference of anything I've measured.
Setup:
mainffe310eplus the PRs from #1232 (#208, the wave64 stack, #452, #579, #472/#322/#1024, #492, #55 with the fix posted there, #602), with and without this PR (23ced70, clean merge).Get-Process,\GPU Process Memory(pid_*)\Dedicated UsageandShared Usage,\Memory\Pages Input/sec.Why it matters on this kind of machine:
Also from these runs: of the ~12 GB of write-combined committed memory in the process, VIctory's own upload buffers were only about 1.9 GB (counted locally). The rest is the driver's system-memory backing for GPU resources, which is what this PR shrinks.
Not tested: more than one run each, a release build, AMD, whether the 300 s window holds for the rest of the world load. No device removal or title stop in either run within the window.
AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title on my machine, measured and drafted this report; results are from the runs described.
RTX 4060) D3D12 compatibility, 2s TDR submissions, and 16 GB host OOM #1076@Daniel333313131 on GitHub · 2026-11-24 20:02 UTC · original
Tested on AMD (RDNA3), where
mainfaults on freed textures in the world. With this PR that fault did not come back in three runs.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
23ced70merged alone ontomainffe310e, compared withmainitself. Each run used its own emptyVICTORY_CACHE_DIR,VICTORY_D3D12_DRED=1, andVICTORY_KEYSset to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s. Method andmainnumbers as in #400.maintexture 2048x2048 f98 (type 34)×2mainmaintexture 2048x1024 f98 (type 34)main, every run was removed by 170 s.mainrun 2.mainalone range from 76 to 170 s, so this is a strong hint, not proof. Runs longer than 180 s were not tested.For comparison, #609 on the same machine and method still faulted inside freed resources in all three runs (75, 89 and 114 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.
@some-du6e on GitHub · 2026-11-24 22:22 UTC · original
For anyone merging this onto r4tedx's integration/testers: it has one conflict there, in
crates/victory-gpu/src/resource.rs. That tree makes a depth target's UAV twin at creation (host_twin,HostTexture.twin), and this PR moves the host copy to first use. What worked:host: OnceLockandmade_with, and make the twin insideResource::host()'s initializer, next to the copy: the samedesc.flags & (2 | 4) == (2 | 4)check, the twin asHostTexture { texture, state: 0.into(), twin: None }, andtwinset on the main copy.host_unorderedon that tree readsresource(this).host.as_deref()directly; it needsresource(this).host()instead.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.
@Marvisak on GitHub · 2026-11-25 00:02 UTC · original
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.
@AgneyaK on GitHub · 2026-11-25 01:44 UTC · original
@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
main940d32f:resource.rsstill makes the host texture when the title creates the resource. Only the retire/release half is inmain, as the triage says.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
mainwithout it).Could this be reopened (it needs a rebase onto current
main), or #1526? If neither author has time, I can port it ontomainwith tests.AI use: Claude Code (Claude Opus 5.5) checked the PR states and
mainand wrote this; the numbers are from the runs linked above.@AgneyaK on GitHub · 2026-11-25 01:56 UTC · original
Opened the port as #1969 (first-use half only; the retire half is in
main), with credit to this PR. Happy to close it if you'd rather rebase this one.AI use: Claude Code (Claude Opus 5.5) wrote this.
Pull request closed