fix(gpu): raise 12GB VRAM window gate to 88% to prevent premature shared-memory spill #2988

Closed
Luca121 wants to merge 1 commit from upstream-pr/2988 into main
Luca121 commented 2026-11-29 19:13:38 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Luca121 on 2026-11-29T19:13:38Z.


Summary

On 12 GB GPUs (DXGI budget ~10.8–11.2 GiB, e.g. RTX 4070 / 4070 Super / 4070 Ti / 3080 12 GB), shadow.rs previously fell into the _ => 80 catch-all in default_window_card_percent(budget) (designed for 8 GB cards) and hardcoded budget / 10 * 8 (80%) in window_mapped_for and wc_mapped_for, while also double-gating window_room_for with || !crate::resource::card_copy_fits(budget, used, size):

  1. default_window_card_percent 10–12 GiB tier (88%):

    • 16 GB cards (> 12 GiB) get 89% and 24 GB cards (>= 20 GiB) get 91%, while 12 GB cards (~11,229 MiB DXGI budget) dropped all the way to 80% (~8,800 MB).
    • Once open-world streaming crosses 80% VRAM (~8.8 GB on a 12 GB card), window_room_for rejected all new vertex/index/constant shadow windows from their dedicated window_card_most (1,010 MB) allowance and spilled them to SHARED system RAM over PCIe, even with >2.2 GB of VRAM budget remaining.
    • Fix: Add mb if mb >= 10 * 1024 => 88 to default_window_card_percent(budget) (leaving 8 GB cards at 80%), and align window_mapped_for and wc_mapped_for to budget / 100 * 88.
  2. Remove redundant !card_copy_fits veto in window_room_for:

    • window_line(budget, percent, kept, crate::resource::room_line(budget)) already caps window allocations at resource::room_line(budget) with a floor of share(percent.min(80)).
    • The additional || !crate::resource::card_copy_fits(budget, used, size) check unconditionally vetoed window_line's 80% floor whenever VICTORY_TEXTURE_ROOM_PERCENT was set below 80% (e.g. 78%), preventing windows from using even the baseline 80% line that window_line explicitly preserves (tested by window_line_keeps_the_room_held_for_targets).

Hardware Telemetry (RTX 4070 Ti 12 GB, 32 GB RAM)

  • Before this fix, once VRAM crossed 80.0% (~12 minutes into open-world driving), shadows card shrank from 1,912 MB → 1,413 MB as all new neighborhood shadow windows were refused from VRAM and forced into SHARED system memory over PCIe.
  • With the 88% gate (window_card_most still strictly capped at 1,010 MB), shadows card remains resident in VRAM (~1,897 MB) across 15–30 minute open-world drives with 0 OOMs and 0.0 ms lists in the air.

Testing

  • Updated and ran shadow::window_tests::window_line_keeps_the_room_held_for_targets, window_room_follows_the_budget, and arenas_do_not_use_the_windows_room (cargo test --locked -p victory-gpu --lib).
  • Verified in live open-world gameplay on RTX 4070 Ti (12 GB VRAM).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5554144509 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2988). Originally posted by [Luca121](https://github.com/Luca121) on 2026-11-29T19:13:38Z. --- ## Summary On 12 GB GPUs (DXGI budget ~10.8–11.2 GiB, e.g. RTX 4070 / 4070 Super / 4070 Ti / 3080 12 GB), `shadow.rs` previously fell into the `_ => 80` catch-all in `default_window_card_percent(budget)` (designed for 8 GB cards) and hardcoded `budget / 10 * 8` (`80%`) in `window_mapped_for` and `wc_mapped_for`, while also double-gating `window_room_for` with `|| !crate::resource::card_copy_fits(budget, used, size)`: 1. **`default_window_card_percent` 10–12 GiB tier (`88%`):** - 16 GB cards (`> 12 GiB`) get `89%` and 24 GB cards (`>= 20 GiB`) get `91%`, while 12 GB cards (`~11,229 MiB` DXGI budget) dropped all the way to `80%` (`~8,800 MB`). - Once open-world streaming crosses 80% VRAM (~8.8 GB on a 12 GB card), `window_room_for` rejected all new vertex/index/constant shadow windows from their dedicated `window_card_most` (`1,010 MB`) allowance and spilled them to `SHARED` system RAM over PCIe, even with >2.2 GB of VRAM budget remaining. - **Fix:** Add `mb if mb >= 10 * 1024 => 88` to `default_window_card_percent(budget)` (leaving 8 GB cards at `80%`), and align `window_mapped_for` and `wc_mapped_for` to `budget / 100 * 88`. 2. **Remove redundant `!card_copy_fits` veto in `window_room_for`:** - `window_line(budget, percent, kept, crate::resource::room_line(budget))` already caps window allocations at `resource::room_line(budget)` with a floor of `share(percent.min(80))`. - The additional `|| !crate::resource::card_copy_fits(budget, used, size)` check unconditionally vetoed `window_line`'s 80% floor whenever `VICTORY_TEXTURE_ROOM_PERCENT` was set below 80% (e.g. `78%`), preventing windows from using even the baseline 80% line that `window_line` explicitly preserves (tested by `window_line_keeps_the_room_held_for_targets`). --- ## Hardware Telemetry (RTX 4070 Ti 12 GB, 32 GB RAM) - Before this fix, once VRAM crossed `80.0%` (~12 minutes into open-world driving), `shadows card` shrank from `1,912 MB` → `1,413 MB` as all new neighborhood shadow windows were refused from VRAM and forced into `SHARED` system memory over PCIe. - With the `88%` gate (`window_card_most` still strictly capped at `1,010 MB`), `shadows card` remains resident in VRAM (`~1,897 MB`) across 15–30 minute open-world drives with `0` OOMs and `0.0 ms` `lists in the air`. --- ## Testing - Updated and ran `shadow::window_tests::window_line_keeps_the_room_held_for_targets`, `window_room_follows_the_budget`, and `arenas_do_not_use_the_windows_room` (`cargo test --locked -p victory-gpu --lib`). - Verified in live open-world gameplay on RTX 4070 Ti (12 GB VRAM).
DoubleD17 commented 2026-11-30 07:58:31 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T07:58:31Z.


We ran a test of this PR on a 12 GB card, on current main (41adb551 with this PR merged).

We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms.

CPU prep (ms/frame) main at that point fps main at that point
round 1 64.8 60.7 13.9 14.6
round 2 63.8 60.0 13.3 15.2
mean difference +3.9 ms −8.6 %

No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR.

Memory in the last 100 s of each run: shared 8.8 and 8.4 GB and dedicated 10.8 and 10.7 GB, against 8.5 to 9.0 GB and 10.6 to 10.8 GB on main. So on this card we see no less spill to shared memory.

Picture: in round 1, one frame (of 160) had the island trees and the potted plants missing. They were back in the next frame. We now see it on main too (1 frame in 3,160 tonight, against 7 in 4,240 on PR builds), so it is not this PR alone; it looks like the one-frame gap in #1165.

Setup:

  • Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11;
  • Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off;
  • the PR merged locally onto main 41adb551 (only its own commits on top), against 41adb551 itself;
  • a warm-up run per build, then 150 s runs in two rounds (the second in reverse order), with five main runs spread through the session;
  • every run starts from the same save, restored before each run;
  • CPU prep is the median of the submitting thread's 5 s lines, fps the median of the host's 5 s lines, on the light-view seconds after the first 20 s; each run is compared with main's runs interpolated in time.

Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame.

AI Assisted

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7272338522 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2988#issuecomment-7272338522). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-30T07:58:31Z. --- We ran a test of this PR on a 12 GB card, on current main (41adb551 with this PR merged). We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms. | | CPU prep (ms/frame) | main at that point | fps | main at that point | |---|---|---|---|---| | round 1 | 64.8 | 60.7 | 13.9 | 14.6 | | round 2 | 63.8 | 60.0 | 13.3 | 15.2 | | **mean difference** | **+3.9 ms** | | **−8.6 %** | | No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR. Memory in the last 100 s of each run: shared 8.8 and 8.4 GB and dedicated 10.8 and 10.7 GB, against 8.5 to 9.0 GB and 10.6 to 10.8 GB on main. So on this card we see no less spill to shared memory. **Picture:** in round 1, one frame (of 160) had the island trees and the potted plants missing. They were back in the next frame. We now see it on main too (1 frame in 3,160 tonight, against 7 in 4,240 on PR builds), so it is not this PR alone; it looks like the one-frame gap in #1165. **Setup:** - Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11; - Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off; - the PR merged locally onto main 41adb551 (only its own commits on top), against 41adb551 itself; - a warm-up run per build, then 150 s runs in two rounds (the second in reverse order), with five main runs spread through the session; - every run starts from the same save, restored before each run; - CPU prep is the median of the submitting thread's 5 s lines, fps the median of the host's 5 s lines, on the light-view seconds after the first 20 s; each run is compared with main's runs interpolated in time. Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame. AI Assisted
Luca121 commented 2026-11-30 20:11:52 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Luca121 on 2026-11-30T20:11:52Z.


Closing to keep the PR queue clean — will focus on real-hardware A/B testing on current main instead.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7290552910 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2988#issuecomment-7290552910). Originally posted by [Luca121](https://github.com/Luca121) on 2026-11-30T20:11:52Z. --- Closing to keep the PR queue clean — will focus on real-hardware A/B testing on current main instead.

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!2988
No description provided.