perf(gpu): range-filter CARDED in send_copied, reclaim idle ReBAR windows, and align mapped VRAM limits #3889

Closed
qlfu wants to merge 2 commits from upstream-pr/3889 into main
qlfu commented 2026-11-30 10:36:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T10:36:33Z.


Summary

Four targeted improvements in crates/victory-gpu/src/shadow.rs measured on Series X gameplay (1440p DLSS Balanced, RTX 4070 Ti 12 GB + Ryzen 7 5700X, base 41adb551):

  1. Range-filter CARDED before Weak::upgrade in send_copied: Store (start, end, Weak<Shadow>) in CARDED so send_copied(dst, len) only upgrades Weak references whose [start, end) overlaps [dst, dst + len) instead of upgrading and dropping ~3,500–4,100 Arc<Shadow>s on every Step::Copy.
  2. Apply VICTORY_CARD_WINDOWS_IDLE_MS to ReBAR-mapped windows (s.mapped) in let_go_idle: Previously let_go_idle checked only s.card.is_some(), leaving idle VICTORY_WINDOWS_BAR_MB (D3D12_HEAP_TYPE_GPU_UPLOAD) windows pinned in VRAM for the 5-minute RAM timeout while active gameplay windows spilled to shared system RAM over PCIe.
  3. Honor window_card_percent(budget) and resource::card_copy_fits in window_mapped_for and wc_mapped_for: Replaces the hardcoded budget / 10 * 8 (80%) check with budget / 100 * window_card_percent(budget) plus crate::resource::card_copy_fits(budget, used, size). Behavior on <= 12 GiB cards with VICTORY_CARD_WINDOWS_PERCENT unset remains 80% (now also bounded by room_line), while 16/24 GB tiers (89%/91%) and explicit VICTORY_CARD_WINDOWS_PERCENT overrides allow newly arrived hot gameplay windows to refill evicted ReBAR slots without starving textures.
  4. Finer parallel split in Shadow::take_all: Lower LONG (1 MiB -> 256 KiB) and PART (256 KiB -> 64 KiB) so medium refreshes fan out across worker threads instead of stalling one core.

Measured Results (90s Series X Native 1440p DLSS Balanced, RTX 4070 Ti 12 GB + R7 5700X)

All runs 0 WARNs, 0 ERRORs, clear-weather matched (180-pipe ~2.0 ms):

Metric Before (122438.log, WINDOWS_BAR=2560 + WC_BAR=1) After (130827.log, + this PR + IDLE_MS=5000) Delta
Native FPS (med / mean / p90 / max) 25.30 / 26.29 / 31.7 / 45.0 25.60 / 26.50 / 34.4 / 46.4 +0.30 med / +0.21 mean / +2.7 p90
Submitting thread all (med / mean) 29.05 / 30.41 ms 28.35 / 29.21 ms -0.70 med / -1.20 mean ms
copies and fills (cf med) 3.30 ms 1.80 ms -1.50 ms
GPU cardmeter title (med) 30.00 ms 29.50 ms -0.50 ms
Idle ReBAR windows (diag: 125039 vs 130632) 49 idle (316 MB) 0 idle (0 MB) -316 MB reclaimed; active PC-RAM windows 2690 -> 2242 MB (-448 MB)

Verification

  • cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1 shadow:: -> 72 passed, 0 failed (5 ignored)
  • cargo +1.98.1-x86_64-pc-windows-msvc check -p victory-gpu --all-targets --all-features --locked -> exit 0, zero new warnings
  • git merge-tree --write-tree 41adb551 HEAD -> clean merge (MERGEABLE)
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5563575007 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3889). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-30T10:36:33Z. --- ## Summary Four targeted improvements in `crates/victory-gpu/src/shadow.rs` measured on Series X gameplay (`1440p DLSS Balanced`, RTX 4070 Ti 12 GB + Ryzen 7 5700X, base `41adb551`): 1. **Range-filter `CARDED` before `Weak::upgrade` in `send_copied`:** Store `(start, end, Weak<Shadow>)` in `CARDED` so `send_copied(dst, len)` only upgrades `Weak` references whose `[start, end)` overlaps `[dst, dst + len)` instead of upgrading and dropping ~3,500–4,100 `Arc<Shadow>`s on every `Step::Copy`. 2. **Apply `VICTORY_CARD_WINDOWS_IDLE_MS` to ReBAR-mapped windows (`s.mapped`) in `let_go_idle`:** Previously `let_go_idle` checked only `s.card.is_some()`, leaving idle `VICTORY_WINDOWS_BAR_MB` (`D3D12_HEAP_TYPE_GPU_UPLOAD`) windows pinned in VRAM for the 5-minute RAM timeout while active gameplay windows spilled to shared system RAM over PCIe. 3. **Honor `window_card_percent(budget)` and `resource::card_copy_fits` in `window_mapped_for` and `wc_mapped_for`:** Replaces the hardcoded `budget / 10 * 8` (`80%`) check with `budget / 100 * window_card_percent(budget)` plus `crate::resource::card_copy_fits(budget, used, size)`. Behavior on `<= 12 GiB` cards with `VICTORY_CARD_WINDOWS_PERCENT` unset remains `80%` (now also bounded by `room_line`), while 16/24 GB tiers (`89%`/`91%`) and explicit `VICTORY_CARD_WINDOWS_PERCENT` overrides allow newly arrived hot gameplay windows to refill evicted ReBAR slots without starving textures. 4. **Finer parallel split in `Shadow::take_all`:** Lower `LONG` (`1 MiB -> 256 KiB`) and `PART` (`256 KiB -> 64 KiB`) so medium refreshes fan out across worker threads instead of stalling one core. ## Measured Results (90s Series X Native 1440p DLSS Balanced, RTX 4070 Ti 12 GB + R7 5700X) All runs `0 WARNs`, `0 ERRORs`, clear-weather matched (`180-pipe ~2.0 ms`): | Metric | Before (`122438.log`, `WINDOWS_BAR=2560` + `WC_BAR=1`) | After (`130827.log`, + this PR + `IDLE_MS=5000`) | Delta | |---|---|---|---| | **Native FPS (med / mean / p90 / max)** | `25.30` / `26.29` / `31.7` / `45.0` | **`25.60` / `26.50` / `34.4` / `46.4`** | **`+0.30` med / `+0.21` mean / `+2.7` p90** | | **Submitting thread `all` (med / mean)** | `29.05` / `30.41 ms` | **`28.35` / `29.21 ms`** | **`-0.70` med / `-1.20` mean ms** | | **`copies and fills` (`cf` med)** | `3.30 ms` | **`1.80 ms`** | **`-1.50 ms`** | | **GPU `cardmeter` title (med)** | `30.00 ms` | **`29.50 ms`** | **`-0.50 ms`** | | **Idle ReBAR windows (`diag`: `125039` vs `130632`)** | `49` idle (`316 MB`) | **`0` idle (`0 MB`)** | **`-316 MB` reclaimed; active PC-RAM windows `2690 -> 2242 MB` (`-448 MB`)** | ## Verification - `cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1 shadow::` -> **72 passed, 0 failed** (5 ignored) - `cargo +1.98.1-x86_64-pc-windows-msvc check -p victory-gpu --all-targets --all-features --locked` -> **exit 0**, zero new warnings - `git merge-tree --write-tree 41adb551 HEAD` -> clean merge (`MERGEABLE`)
qlfu commented 2026-11-30 14:30:30 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T14:30:30Z.


Updated window_line, window_mapped_for, and wc_mapped_for in shadow.rs after live 12 GiB RTX 4070 Ti + DLSS Frame Generation 2x testing showed no room, new textures wait across 47-81% of gameplay:

  • window_mapped_for (VICTORY_WINDOWS_BAR_MB) and wc_mapped_for (VICTORY_WC_BAR=1) now call window_line(...) with card_room_kept() + targets_room_kept(memory) and room_line(budget), matching window_room_for.
  • window_line now respects cap.saturating_sub(kept) so render-target/buffer room kept under a lowered frame-generation texture line (80% 2x / 74% 3x) is no longer overridden back up to 80%.
  • Verified: cargo test -p victory-gpu --lib --locked shadow:: -- --test-threads=1 (72 passed, 0 failed) + clean merge-tree onto 41adb551.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7281483789 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3889#issuecomment-7281483789). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-30T14:30:30Z. --- Updated `window_line`, `window_mapped_for`, and `wc_mapped_for` in `shadow.rs` after live 12 GiB RTX 4070 Ti + DLSS Frame Generation 2x testing showed `no room, new textures wait` across 47-81% of gameplay: - `window_mapped_for` (`VICTORY_WINDOWS_BAR_MB`) and `wc_mapped_for` (`VICTORY_WC_BAR=1`) now call `window_line(...)` with `card_room_kept() + targets_room_kept(memory)` and `room_line(budget)`, matching `window_room_for`. - `window_line` now respects `cap.saturating_sub(kept)` so render-target/buffer room kept under a lowered frame-generation texture line (`80%` 2x / `74%` 3x) is no longer overridden back up to `80%`. - Verified: `cargo test -p victory-gpu --lib --locked shadow:: -- --test-threads=1` (72 passed, 0 failed) + clean `merge-tree` onto `41adb551`.
trustno1-coder commented 2026-12-01 18:47:56 +00:00 (Migrated from github.com)

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


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:7321565769 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3889#issuecomment-7321565769). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:47:56Z. --- 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!3889
No description provided.