Bound the DXR cache of decoded meshlet indices #4578

Closed
tyr0nsur wants to merge 1 commit from upstream-pr/4578 into main
tyr0nsur commented 2026-11-30 23:07:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T23:07:29Z.


Related to #4314.

What it changes

The DXR meshlet path caches a committed upload buffer for each decoded index stream. Until the title frees the source address, cache entries can accumulate as the scene changes. The existing BLAS budget covers acceleration structures. These upload buffers are separate.

Bound the decoded index cache to 256 MiB of buffer allocation sizes, using the standard 64 KiB alignment for these committed buffers. At the limit, release the oldest entries from earlier frames and leave room for subsequent misses. A miss can still use its upload buffer for the recording when the cache is full of buffers used this frame. Hits update recency under the read lock. Skip caching a decode when the title freed memory since its lookup. Concurrent misses can share the winner's entry. A recording keeps its existing reference to the buffer and evicted entries are retired outside the cache lock.

Log the current cache count and bytes. The existing decoded-MB field is cumulative decode work and includes quant24 vertices as well as indices. #4314 shows budget pressure on a 5070 Ti, but its release log cannot identify this cache's live size or attribute the local VRAM growth to it.

How it was tested

  • Windows 11 / RTX 4060 8 GiB. Ran title-independent tests. The reported profile was RTX 5070 Ti, Series X, 4K output, DLSS Quality, hardware RT on and frame generation off.
  • Tests check the cap, least-recently-used eviction, release after a title free, and skipping oversized allocations and decodes that overlap a free.
  • cargo test -p victory-gpu --features diagnostics --locked --lib hwrt::tests:: -- --test-threads=1 passed (21 tests). The staged asset-policy check passed.
  • A play run with the new cache line is still needed to measure retained upload memory and decode cost after trimming.

Checked for overlap

  • #3706 budgets BLAS results. #4144 adds a cache for GPU-clamped static index buffers and changes the decoded cache's invalidation lock scope. This PR caps the existing CPU-decoded meshlet upload cache.

Developed with Codex and reviewed with Claude Opus 5.5.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5575427317 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4578). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-11-30T23:07:29Z. --- Related to #4314. ## What it changes The DXR meshlet path caches a committed upload buffer for each decoded index stream. Until the title frees the source address, cache entries can accumulate as the scene changes. The existing BLAS budget covers acceleration structures. These upload buffers are separate. Bound the decoded index cache to 256 MiB of buffer allocation sizes, using the standard 64 KiB alignment for these committed buffers. At the limit, release the oldest entries from earlier frames and leave room for subsequent misses. A miss can still use its upload buffer for the recording when the cache is full of buffers used this frame. Hits update recency under the read lock. Skip caching a decode when the title freed memory since its lookup. Concurrent misses can share the winner's entry. A recording keeps its existing reference to the buffer and evicted entries are retired outside the cache lock. Log the current cache count and bytes. The existing decoded-MB field is cumulative decode work and includes quant24 vertices as well as indices. #4314 shows budget pressure on a 5070 Ti, but its release log cannot identify this cache's live size or attribute the local VRAM growth to it. ## How it was tested - Windows 11 / RTX 4060 8 GiB. Ran title-independent tests. The reported profile was RTX 5070 Ti, Series X, 4K output, DLSS Quality, hardware RT on and frame generation off. - Tests check the cap, least-recently-used eviction, release after a title free, and skipping oversized allocations and decodes that overlap a free. - `cargo test -p victory-gpu --features diagnostics --locked --lib hwrt::tests:: -- --test-threads=1` passed (21 tests). The staged asset-policy check passed. - A play run with the new cache line is still needed to measure retained upload memory and decode cost after trimming. ## Checked for overlap - [x] #3706 budgets BLAS results. #4144 adds a cache for GPU-clamped static index buffers and changes the decoded cache's invalidation lock scope. This PR caps the existing CPU-decoded meshlet upload cache. Developed with Codex and reviewed with Claude Opus 5.5.
TechnoStone commented 2026-11-30 23:53:52 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by TechnoStone on 2026-11-30T23:53:52Z.


Hi, this PR solves vram leakage with enabled DXR, but still game can crash after a short car/boat trip (without this commit it crashed as soon as leaving house/loading other save/starting new game)
9800X3D, 48 GB, 4070TiS
crashes.log
victory-nvidia-20261201-025054.log

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7295653313 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4578#issuecomment-7295653313). Originally posted by [TechnoStone](https://github.com/TechnoStone) on 2026-11-30T23:53:52Z. --- Hi, this PR solves vram leakage with enabled DXR, but still game can crash after a short car/boat trip (without this commit it crashed as soon as leaving house/loading other save/starting new game) 9800X3D, 48 GB, 4070TiS [crashes.log](https://github.com/user-attachments/files/35648250/crashes.log) [victory-nvidia-20261201-025054.log](https://github.com/user-attachments/files/35648251/victory-nvidia-20261201-025054.log)
paales commented 2026-12-01 01:41:09 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by paales on 2026-12-01T01:41:09Z.


Written by 🤖:

Tested together with #4337, #4170 and #4144 on an RTX 5070 Ti 16 GB (https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337#issuecomment-7297773692). No crash and no lost card in 6 runs with VICTORY_HW_RT=1, 2 of them a save that ends on the boat (82 s). The meshlet index cache stays under its bound: at most 230 MB kept of 256 MB in the cutscene, 231 MB in the save. The cherry-pick onto #4337 conflicts in the HwRtManager fields (shown beside MeshletCache) and in title_memory_freed; both sides stay.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7297778200 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4578#issuecomment-7297778200). Originally posted by [paales](https://github.com/paales) on 2026-12-01T01:41:09Z. --- _Written by 🤖:_ Tested together with #4337, #4170 and #4144 on an RTX 5070 Ti 16 GB (https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337#issuecomment-7297773692). No crash and no lost card in 6 runs with `VICTORY_HW_RT=1`, 2 of them a save that ends on the boat (82 s). The meshlet index cache stays under its bound: at most 230 MB kept of 256 MB in the cutscene, 231 MB in the save. The cherry-pick onto #4337 conflicts in the `HwRtManager` fields (`shown` beside `MeshletCache`) and in `title_memory_freed`; both sides stay.
tyr0nsur commented 2026-12-01 01:50:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-12-01T01:50:18Z.


I checked TechnoStone's attached play log. The 15 meshlet-cache samples peak at 231 MiB of the 256 MiB cap. The last sample reports 190 MiB, about 2.3 s before the relay reports device removal (0x887A0005). The closest DXGI sample, 82 ms before that error, reads 12,819 MiB local use against a 14,621 MiB budget. The log shows the cap holding through the sampled interval, with the run still ending in device loss.

#4337 is relevant to that remaining failure. The six successful runs above tested it in a stack with other changes. The useful follow-up for this 4070 Ti SUPER report would be the same save and settings with this cache PR in both runs and only #4337 added in the second.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7297950432 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4578#issuecomment-7297950432). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-12-01T01:50:18Z. --- I checked TechnoStone's attached play log. The 15 meshlet-cache samples peak at 231 MiB of the 256 MiB cap. The last sample reports 190 MiB, about 2.3 s before the relay reports device removal (`0x887A0005`). The closest DXGI sample, 82 ms before that error, reads 12,819 MiB local use against a 14,621 MiB budget. The log shows the cap holding through the sampled interval, with the run still ending in device loss. #4337 is relevant to that remaining failure. The six successful runs above tested it in a stack with other changes. The useful follow-up for this 4070 Ti SUPER report would be the same save and settings with this cache PR in both runs and only #4337 added in the second.
trustno1-coder commented 2026-12-01 18:37:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:37:21Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321233199 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4578#issuecomment-7321233199). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:37:21Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!4578
No description provided.