Hardware ray tracing: drop host structures of console structures the title wrote over (VICTORY_HW_RT_REUSE=1, off by default, on #342) #374
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!374
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-374"
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?
@LOCKhart07 on GitHub · 2026-12-03 21:08 UTC · original
LOCKhart07:rt-reuse→main· +26462 −140 · 38 files · 14 commits · draftDraft, on #342. The diff against
mainholds all of #342; what this adds on top is one commit plus the merge (git diff rt-all...rt-reuse: 7 files, about 4,900 lines, most of it counters).The problem
The title frees no memory when it is done with a bottom-level structure. It writes the next one over its bytes. The layer dropped a host structure only when the title freed the memory under it, or when a later build's asked size covered it, so the host structure of a written-over one stayed for good, keyed by an address nothing names any more. This is the pile #342 notes under "Long sessions still fill the card": host structures grew to about 2.5 GB in ten minutes of driving.
The change (
VICTORY_HW_RT_REUSE=1, off by default)Placed::wrote).reuse_step,Reuse::landed,Ledger::drop_write). Its memory goes as with freed title memory, once nothing in flight holds it.Reading the header from the CPU a moment later does not work: the title's builder writes it on the card, and short-lived memory already holds other bytes by then. Sizes read that way gave a few structures of 40 MB and more, and wrong verdicts.
What a wrong drop would look like
Measured
One session of 11 minutes of driving, hardware ray tracing on, 2560x1440, same machine as #342, with
VICTORY_HW_RT_DEMOTE=1andVICTORY_HW_RT_PACK=1:Also in the diff
VICTORY_HW_RT_NAMED=1andVICTORY_HW_RT_NAMED_DUMP=1: counters only, the measuring that led here (which structures the top-level ones still name, and which are written over). Nothing reads them but the report.VICTORY_SHARED_LEDGER=1: counters only, what of the memory shared with the card is the layer's own.Checked
victory-gputests after the merge with #342's branch:hwrt::94 passed (4 new for this change),host::89 passed and 4 ignored,pool::18 passed. No warnings.hwrt.rskeeps this branch's side,descriptor/host.rskeeps main's walk of the due slots.Not done
reuse_stepis timed apart and was not it; frames like it are in sessions without the switch too. Which step it was is not known yet.docs/SETTINGS.mdhas no row for the switch.🤖 Generated with Claude Code
@DrArroway on GitHub · 2026-12-03 22:28 UTC · original
40-minute real-play validation of the merged build on RDNA 2, directly comparing against our 47-minute
#342run withoutVICTORY_HW_RT_REUSEon the same machine and settings.Setup & build
AMD Radeon RX 6900 XT (1002:73bf)(RDNA 2, 16 GB VRAM), Ryzen 9 7900X (12C/24T), 62 GiB RAM, CachyOS kernel7.3.7-1-cachyos,GE-Proton11-15-x86_64, repo-patched Mesa (deps/mesa-inst) + vkd3d-proton.main(95858c5) +#342+#374merged cleanly with 0 conflicts (56.5 sincremental release build, 0 warnings; existing#342shader/pipeline caches stayed valid).VICTORY_OUTPUT=2560x1440,VICTORY_FSR_4K=quality,VICTORY_FIDELITYFX_FRAMEGEN=1,VICTORY_FIDELITYFX_FRAMEGEN_DIRECT=1,VICTORY_UI_PLANE=3840x2160,VICTORY_HW_RT=1,VICTORY_HW_RT_DEMOTE=1,VICTORY_HW_RT_PACK=1,VICTORY_HW_RT_REUSE=1,VICTORY_SHARED_LEDGER=1,VICTORY_PLACED_COPIED=1,VICTORY_PARTS_ONE_CALL=1,VICTORY_KEEP_HOST_BUFFERS=1,VICTORY_SKIP_BINK=1(VICTORY_HW_RT_LEAN_BUILDERleft off so the title's builder writes every console BVH header).Before vs After (
#342alone vs#342+#374)#342alone (47 min)#342+#374(VICTORY_HW_RT_REUSE=1) (40 min)0 -> 10,490 MB(20,999compacted BLASes)510–928 MB(853 MBend,1,410 MBpeak;10,089compacted =679 MB)vram)22,046 MBpeak)13,472–14,140 MB(15,028 MBpeak /15.5–15.8 GBbudget)0x887A0005+SQC (data)page fault at 47m0GPU errors,0kernel faults (ended at 40m on unrelated#57/#142+0x2626877hang)tools/session-fps.sh22.6med /22.5avg (24.9early ->21.3late)24.2med /24.3avg (415samples; no late-session drop — 2nd half hit27.1med real FPS)VICTORY_HW_RT_REUSE=1parity & overhead (40 minutes)2,206,882asked for (0missing title copy,0no slot),2,206,304landed (2,031,469of a write no longer at its address,0no structure's header),174,835extents known (10,213noted at end,0waiting).53,226overwritten structures (31,628 MBof host structures) (0as their own header landed,7,296older ones no longer standing,24writes over their own source not judged).0):000of340,000,997hardware RT lossesline:0reuse_steptook1,016 mstotal across 40 minutes (longest single step2,517 us).VRAM / shared memory timeline &
VICTORY_SHARED_LEDGER=10 MB(0m) →510 MB(5m) →922 MB(10m) →838 MB(15m) →588 MB(20m) →594 MB(25m) →928 MB(30m) →788 MB(35m) →853 MB(40m).12,476 MBat5m→15,134 MBat25m→16,506 MBat40m, peak17,151 MB), matching the note under "Not done".VICTORY_SHARED_LEDGERsample (at25m):shared in use 14,933 MB=8,775 MBtitle memory in RAM +1,670 MBour mapped buffers (51,091buffers:1,216 MBtexture staging,189 MBshared buffers,103 MBlist scratch,94 MBhost RT on processor heap,30 MBother uploads,24 MBremap tables,12 MBread-backs) +4,486 MBunnamed (vkd3d/driver,3,081host list command allocators alive,471lists not reset for >60 s, oldest1,482 s).@khift363 on GitHub · 2026-12-04 06:54 UTC · original
I have been running this on my personal build for a bit, tracking your various changes, and the difference in both speed and quality is incredible. However, this version has a memory leak - but of a different version. Specifically, the shared GPU memory continues to grow as the play session goes on, until it eventually obliterates the frame rate. Disabling native RT via this branch eliminates the leak. The total VRAM in use remains extremely stable over time - but the proportion of VRAM allocated to shared GPU memory grows without bound.
I also believe the leak is related to speed - it seems to build up much faster when driving around in town versus driving in the countryside, on a boat, or doing more stationary activities.
Either way, I just want to reiterate - this is a huge win on both quality and speed, just gotta nail down that memory leak.
github-bot referenced this pull request2026-12-04 11:01:55 +00:00
@LOCKhart07 on GitHub · 2026-12-04 11:46 UTC · original
From what I found yesterday, it's seemingly to do with the game never marking memory for free up. The console just overwrites that memory whenever it needs, which victory does not seem to be track. Good place to start if someone wants to point their clanker at it
@Luxuride on GitHub · 2026-12-04 12:20 UTC · original
The mechanism is well argued and the counters are exactly what a maintainer would ask for — but as a 26,462-line draft that also contains the whole hardware-RT stack, it cannot be reviewed. Please split it.
Three things that matter more than the size:
VICTORY_HW_RT,_ARENA,_DEMOTE,_LEAN_BUILDER,_LIFT,_NAMED,_NAMED_DUMP,_PACK,_REFIT,_REUSE,_WHY, andgit diff <base> pr/374 -- docs README.mdis empty, whiledocs/SETTINGS.mddocuments 81 other switches. That is the cheapest fix in the stack and it is the one thing a user cannot work around.packed_extentdecides what gets dropped, from a number nobody cross-checks.crates/victory-gpu/src/hwrt.rs:2473accepts any header whose low 16 bits are 6 and whose node count fitsEXTENT_MOST—(version == 6 && nodes > 0 && len <= EXTENT_MOST).then_some(len)— and every live structure sharing a byte with that extent is dropped. Your own note says CPU-side size reads produced "a few structures of 40 MB and more, and wrong verdicts", and the sanity helper that exists (copy_size_trusted,hwrt.rs:2485) is#[cfg(test)]only. Make the extent bound part of the production guard.Minor:
Reuse::landedtreats "same address, header landed after a later write" as a silent no-op — correct — but it also drops theolderentries it collected on the way without telling anyone, so the ledger keeps structures the model has forgotten. A counter there is nearly free.Land the stack's clean head first, then reopen the reuse commit alone. It is ~4,900 lines where most is counters and tests, and it deserves to be read.
@LOCKhart07 on GitHub · 2026-12-04 14:34 UTC · original
Split as asked: the reuse commit alone is
rt-7-reuseon my fork (3,500 lines with its tests and the two counting-only switches), on top of the six branches under it (bottom at #468).On your points:
rt-7-reusefrom my fork, play withVICTORY_HW_RT=1 VICTORY_HW_RT_REUSE=1, and post the lasthardware RT title bytes written againandhardware RT losseslines. The first now also says how many extents were held against a bound and how many were refused, which is the number the new guard needs.On the minor point:
Reuse::landeddoes not drop older entries untold. Nothing noted shares a byte with a later write's bytes, so a late header finds none before its own address, and in every other case the older ones are returned and dropped from the ledger (or counted as no longer standing). I added the counter anyway (headers landed after a later write's) and a test that says so.Two things that rode in this commit and need no ray tracing are out of it: the card-address ranges said when the device is lost (
rt-8-ranges, now behindVICTORY_REMOVAL_RANGES, off by default) and the shared memory ledger (rt-9-ledger,VICTORY_SHARED_LEDGER, off by default), each its own branch with its switch documented.This one can be closed.
github-bot referenced this pull request2026-12-04 17:15:51 +00:00
@DrArroway on GitHub · 2026-12-04 17:41 UTC · original
@LOCKhart07 Here is a 63m 44s real-play test on your exact
LOCKhart07/VIctory-xmemrt-7-reuse(621120b) branch — clean voluntary exit,0errors.Setup
AMD Radeon RX 6900 XT (1002:73bf)(RDNA 2, 16 GB VRAM), Ryzen 9 7900X (12C/24T), 62 GiB RAM, CachyOS kernel7.3.7-1-cachyos,GE-Proton11-15-x86_64, repo-patched Mesa (deps/mesa-inst) + vkd3d-proton.LOCKhart07/VIctory-xmemrt-7-reuse @ 621120b747ee8f38096460686184a9b060baea63; release build in60 s(0 warnings);./run.sh shaders VICTORY_HW_RT=1(25,694cached in95 s);./run.sh warm VICTORY_HW_RT=1(94,440 / 94,440pipelines in69 s,0bad,0refused).VICTORY_OUTPUT=2560x1440,VICTORY_FSR_4K=quality,VICTORY_FIDELITYFX_FRAMEGEN=1,VICTORY_FIDELITYFX_FRAMEGEN_DIRECT=1,VICTORY_UI_PLANE=3840x2160,VICTORY_HW_RT=1,VICTORY_HW_RT_DEMOTE=1,VICTORY_HW_RT_PACK=1,VICTORY_HW_RT_REUSE=1,VICTORY_PLACED_COPIED=1,VICTORY_PARTS_ONE_CALL=1,VICTORY_KEEP_HOST_BUFFERS=1,VICTORY_SKIP_BINK=1.Verbatim final lines (at
63m 44s)Summary
163,887known extents,32,021were checked against the write's upper bound and2,040(6.4%) exceeded it and were safely refused (not judged);landed after a later write's at their address: 0.49,612overwritten BLASes (18,243 MB) dropped;0copies/updates of dropped structures;0of615,452,503instances missing a host BLAS;0across all loss counters;reuse_steptotaled1,724 msacross 64 minutes (2,350 uslongest).513–797 MB(740 MBat end,1,113 MBpeak;6,938compacted BLASes =576 MB).13,888–14,688 MB,14,204 / 15,489 MBat end,15,204 MBpeak).16,057 MBmid-session and settled back down to14,449 MBat exit.tools/session-fps.sh(583samples):27.6median /26.6avg real FPS (6.8 msavg preparing,1.3 msavg copy; 2nd half reached30.4median real FPS across all gameplay samples).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.