Skip to content

Windows in card memory the CPU maps on 16 GB cards too, not only on small hosts (VICTORY_WINDOWS_BAR_MB=4096 when unset) - #2313

Merged
trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
wildheathen:windows-bar-default
Nov 30, 2026
Merged

trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
wildheathen:windows-bar-default

Conversation

@wildheathen

@wildheathen wildheathen commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What it changes

With VICTORY_WINDOWS_BAR_MB unset, windows outside buffers go to card memory the CPU maps (D3D12_HEAP_TYPE_GPU_UPLOAD) only on hosts with a small shared GPU budget (4096 MiB) or under 24 GB of RAM (3072 MiB, #1520, #1640). Other hosts keep them in shared GPU memory, which is physical RAM.

This gives 4096 MiB to hosts whose card has a budget of 14 GiB or more (16 GB cards). 8 and 12 GB cards keep it off as before: their render targets, texture floor and card copies arrive after the windows, and the existing guard (a fifth of the card's budget free) does not count them. Small hosts are unchanged, and an explicit value (0 included) decides as before. The default is moved into window_mapped_default, with a unit test.

window_mapped_for also returns at once when the card has no memory the CPU maps (no resizable BAR), instead of counting the window in WINDOW_MAPPED_BYTES and asking the host for a buffer it cannot make. That was already the case for small hosts without a resizable BAR.

How it was tested

main, unset (2 runs) main, VICTORY_WINDOWS_BAR_MB=4096 (2 runs) this branch, unset (2 runs)
Shared GPU memory of the process 6.72 / 6.54 GB 4.36 / 4.95 GB 4.47 / 4.66 GB
Card's own memory of the process 9.76 / 9.62 GB 11.62 / 11.81 GB 11.73 / 11.87 GB
Private bytes 26.94 / 26.56 GB 26.41 / 27.18 GB 26.67 / 26.94 GB
Median fps in the world 15.1 / 16.9 17.5 / 18.8 16.9 / 16.0
  • The shared GPU memory, which is system RAM the card uses, is 1.6-2.4 GB lower in all four runs with windows in card memory, and the card's own memory 1.9-2.3 GB higher. This card had the room (9.7 of 14.85 GiB before).
  • Available RAM in these first runs followed the other programs open on the PC (1.16 / 1.17 GB without, 2.82 / 2.44 GB with the switch, 1.85 / 1.08 GB with this branch): see the pairs below for a clean measurement.
  • fps: no claim. The alternated pairs were 2 fps higher with the switch, the two later runs were not; 3-minute runs vary by several fps.
  • Picture: saved frames of the same scenes compared, no missing objects or wrong colours. The log shows card memory the CPU maps supported=true.
  • Not tested on AMD or on cards under 16 GB (which this leaves off). Title: AMD RX 7800 XT results: ~16 fps, frame time dominated by host copies (+ WC_BAR breaks rendering on AMD) #1231 reports VICTORY_WINDOWS_BAR_MB=1024 alone on an RX 7800 XT as "no visible change"; its breakage came with VICTORY_WC_BAR=1, which this does not touch.
  • For shader changes, the wave sizes tested: none (no shader changes).
  • cargo test for the crate it touches: victory-gpu lib, 915 passed, 1 failed in the full run (host::menu::tests::a_change_is_saved_at_once_however_the_game_was_started), which passes when run alone and tests the F1 menu settings file, not this code. Clippy: no warnings in the changed lines.

Calibration of the counters (synthetic, no game)

A small local test on the same PC makes one 1 GiB buffer at a time, maps it, writes every byte, and reads the process and DXGI counters after each step:

1 GiB buffer Private bytes Working set DXGI local DXGI non-local / GPU shared usage Available RAM
plain process memory, written +1 GB +1 GB 0 0 -1 GB
custom write-back L0 (the layer's shared buffers, where windows go today) +1 GB +1 GB, from creation 0 +1 GB -1 GB
GPU_UPLOAD (where this puts windows) +1 GB 0 +1 GB 0 0
UPLOAD +1 GB 0 +1 GB 0 0
  • Private bytes count card memory too (commit charge), so they cannot show this change.
  • The shared GPU usage of an L0 buffer is the same physical pages as its working set: the two must not be added.
  • So each window moved from L0 to GPU_UPLOAD takes its pages out of the process's physical memory. In the first runs, with other programs open, the working set did not fall clearly (19.1-19.7 GB against 19.3-20.4 GB); the pairs below, with the PC otherwise idle, show it.
  • On this PC (resizable BAR, driver 621.24) an UPLOAD heap buffer also lands in card memory.

Three alternated pairs with this branch (physical RAM)

Same exe (this branch on 829188e9 + #2048 + #2133), 3-minute runs, base = VICTORY_WINDOWS_BAR_MB=0, on = nothing set, order base/on three times, other programs closed. Means from 40 to 100 s after the first world frame:

Pair Working set (base -> on) Available RAM Shared GPU memory Card's own memory Median fps in the world
1 22.09 -> 18.96 GB 1.07 -> 3.46 GB 6.88 -> 4.40 GB 9.29 -> 11.79 GB 18.3 -> 19.3
2 20.63 -> 19.33 GB 2.11 -> 3.69 GB 6.77 -> 4.65 GB 9.43 -> 11.80 GB 20.9 -> 23.9
3 20.97 -> 19.31 GB 2.08 -> 3.67 GB 6.74 -> 4.69 GB 9.42 -> 11.77 GB 18.4 -> 22.7
  • Working set 1.3-3.1 GB lower and available RAM 1.6-2.4 GB higher in all three pairs: with the PC not shared with other heavy programs, the physical saving shows. (In the earlier runs above, other programs were open and available RAM followed them.)
  • fps higher in all three pairs (+1.0, +3.0, +4.3), but base runs alone spread by 2.6 fps, so I only note the direction.
  • Pages read back from disk did not change in a consistent way (2,811 / 4,088 / 3,277 per second without, 2,112 / 6,040 / 3,156 with, over the same window). The process's page faults (mostly soft) were about 15 % higher with windows in card memory.
  • An independent measurement on the same card in the Whiplash research forum (RTX 5080 16 GB, 7800X3D, 32 GB, Series X 1440p DLSS Quality, one run per mode, 28/11) found the same direction with VICTORY_WINDOWS_BAR_MB=2048: frame time 48.0 -> 40.2 ms, MakeResident total 13.6 -> 8.9 s, peak working set about 1.9 GB lower in a 0-2048 MB sweep.

Not changed here

The 80 % guard in window_mapped_for is the existing one: it does not follow VICTORY_TEXTURE_ROOM_PERCENT (74 % with multi-frame generation in play-foxhound.ps1), as on small hosts today; making it do so would change those hosts too, so it is left for a separate change. A window in this memory that a GPU write is declared on (root or table UAV, an on-card copy) goes through the deferred-write path, which reads it back across the bus; the code notes no shader writes a window in this title, and diagnostic switches (VICTORY_UPLOAD_CHECK, VICTORY_REFRESH_CHECK, VICTORY_FACE_WATCH) read it too. VICTORY_WINDOWS_OWN=1 needs VICTORY_WINDOWS_BAR_MB=0 to keep two-sided windows on these hosts, as on small hosts today.

Checked for overlap

…mall hosts (VICTORY_WINDOWS_BAR_MB=4096 unset)

With VICTORY_WINDOWS_BAR_MB unset, hosts with 24 GB of RAM or more kept
windows outside buffers in shared GPU memory. Those whose card has a
budget of 14 GiB or more (16 GB cards) now get the 4096 MiB cap that
hosts with a small shared budget already get. Small hosts keep 4096/3072
as before (trustno1-coder#1520), other cards keep it off, and an explicit value, 0
included, decides as before. window_mapped_for also returns at once
without card memory the CPU maps, instead of counting the window and
asking the host for a buffer it cannot make.

RTX 5080 16 GB, 32 GB RAM, Series X 1440p DLSS Quality, 3-minute runs:
shared GPU memory of the process 6.72/6.54 GB without, 4.36/4.95 GB with
the switch and 4.47/4.66 GB with this default; the card's own 9.76/9.62
-> 11.62-11.87 GB; picture unchanged in the saved frames.
@github-actions github-actions Bot added the pr-performance Pull request: makes it faster or use less memory label Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-performance] Windows in card memory the CPU maps on 16 GB cards too, not only on small hosts (VICTORY_WINDOWS_BAR_MB=4096 when unset) Windows in card memory the CPU maps on 16 GB cards too, not only on small hosts (VICTORY_WINDOWS_BAR_MB=4096 when unset) Nov 29, 2026
@wildheathen
wildheathen marked this pull request as ready for review November 29, 2026 12:45
@Ondra97

Ondra97 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Independent placement check on an RTX 4070 Ti SUPER (driver 621.40, 32 GB system RAM). I tested the existing VICTORY_WINDOWS_BAR_MB path on the same diagnostic binary, with explicit 0, 1024 and 4096 MiB values. Series X 2560×1440, DLSS Performance, RT requested and FG off. Emulator image, shader and PSO caches started empty for each run. The existing driver cache was left in place. The binary includes #2263, #2148, #2188 and the diagnostic build fix from #2386.

The GPU upload heap reported supported=true. Here are the final placement census snapshots, taken during late startup at roughly 5,500–5,900 draws/frame. The snapshots have different live window populations.

GPU upload cap Active loose windows in RAM Active loose windows in VRAM Peak DXGI shared Minimum DXGI local headroom
0 2,508 MiB 2,560 MiB 7,581 MiB 5,779 MiB
1024 2,024 MiB 3,582 MiB 6,918 MiB 3,028 MiB
4096 388 MiB 4,516 MiB 4,290 MiB 1,453 MiB

No sampled DXGI local usage exceeded budget. The 4096 probe also activated all 53 builder stages and completed its 30-second post-activation observation without a device fault. It remained in cold compilation. This confirms that the mapped placement is real on a second 16 GB NVIDIA model. These are cold diagnostic samples, so a steady gameplay FPS or visual parity claim would need a separate paired run.

Release follow-up with explicit 4096 MiB on the same startup stack, without the diagnostic build fix and instrumentation. In the seven-minute empty-cache probe, peak DXGI shared usage was 4,058 MiB and all 200 local samples remained within budget. There was no device fault. The final workload still rendered at 0.8 FPS with 2,505 pending PSOs and the window showed a black loading screen at the visual check. Memory placement improved in the diagnostic series, while cold gameplay remains unverified.

@schoperena

Copy link
Copy Markdown

Independent check of this change on a different 16 GB card: RTX 5060 Ti 16 GB on PCIe 4.0 x8, Ryzen 7 5800X, 32 GB DDR4-3200. It holds here too, and the frame rate goes up as well. (AI-assisted with Claude Code: the runs, the log parsing and this write-up. Every number below comes from the layer's own log lines.)

Rig and settings

  • RTX 5060 Ti 16 GB, driver 621.40, PCIe 4.0 x8 (the card's own width), B550 board. Resizable BAR on (CSM off, Above 4G Decoding on): nvidia-smi BAR1 total 16,384 MiB, log card memory the CPU maps supported=true, budget ~14.9 GB.
  • Ryzen 7 5800X, 32 GB DDR4-3200, Windows 11 Pro 26300. The title's Xbox Series build v1.0.2.1.
  • main at 41adb551, release build. Series X, 2560x1440 (VICTORY_NATIVE_SIZE=2560x1440, the monitor is 2560x1080), DLSS Quality, frame generation off, ray tracing off, warm shader cache and pipeline library. The launcher's own switches otherwise (VICTORY_WC_NO_BACK=1, _MIN_KB=1024, VICTORY_ALLOCATOR_TRIM=1, ...).
  • Scripted 7-minute runs: VICTORY_KEYS presses Enter every 4 s from 8 to 140 s (continue the last save), then the game runs by itself until closed at 420 s. Same save each time (the prologue cell and its first scripted scenes). Nothing else open; PC untouched.
  • Numbers from the layer's own lines, counted from the first frame of 500 draws or more: host: N fps ... (one sample every ~5 s), memory now: committed ..., process memory: ..., and whether textures picked by index: the card has no room for more; they wait appeared. Percentiles are of the ~5 s samples.

VICTORY_WINDOWS_BAR_MB, everything else as on main (VICTORY_WC_BAR unset)

"none" is main at 41adb551 as it is. The other four runs used one build: 41adb551 plus a default equivalent to this PR's but with 6144 (budget 14 GiB or more and card memory the CPU maps → 6144). The 4096 runs set VICTORY_WINDOWS_BAR_MB=4096 explicitly, which overrides that default, so they behave as main with the switch; the 6144 runs left it unset and the log printed the default's line, so the default path was taken.

none (main, unset) 4096 (a) 4096 (b) 6144 (a) 6144 (b)
World samples 72 74 74 74 74
Mean fps 16.6 19.6 19.7 18.7 20.4
Median fps 17.4 20.3 20.5 19.6 21.8
Mean of the last 30 samples 17.9 21.0 21.0 20.0 22.2
10th percentile fps 13.0 16.4 16.8 14.0 16.4
Lowest sample 4.6 11.1 13.1 9.4 9.5
ms a frame preparing (CPU) 48.9 39.6 38.5 41.4 37.8
ms a frame on the GPU 0.9 0.6 0.4 0.9 0.8
Card's own memory, peak / budget (MB) 12215 / 14929 13379 / 14957 13339 / 14958 13188 / 14929 12984 / 14958
Shared with the card, peak / last (MB) 9047 / 7327 6752 / 4742 6730 / 4725 6328 / 4424 6210 / 4300
Commit, peak (MB) 30904 29979 29861 29341 28879
Working set, peak (MB) 24678 22032 23306 22412 22377
Texture line reached no yes yes no no

What I read from it:

  • 4096 against none: +3 fps (16.6 → 19.6/19.7), the preparing time 9-10 ms shorter, shared memory 2.3 GB lower at the peak and 2.6 GB lower at the end, commit ~1 GB lower, working set 1.4-2.6 GB lower. Same direction as your RTX 5080 numbers, and here the frame rate moved clearly too. (The "none" column is a single run: a second one was stopped early because the PC ran low on memory, which is itself the problem this fixes.)
  • 6144 against 4096: no difference in frame rate (within run-to-run noise), shared memory a further 0.4-0.5 GB lower, commit 0.5-1 GB lower, and in both 6144 runs the texture line was not reached, where it was in both 4096 runs. Small, but the same in both pairs. With 6144 the card's own peak was still under 13.2 GB of 14.9.
  • No crash, no device loss, no 0x8007000E in any of these runs. The run script takes a desktop screenshot every 30 s; the ones I looked at (the same moment of the same scene, with none and with the windows in card memory) showed the same, correct picture. I did not watch every run live, so a flicker between screenshots would not have been seen.

So I'd suggest 6144 for the big-card branch instead of 4096, if it holds on your 5080 as well. It is a one-line change to window_mapped_default plus its test; I have it as a commit on top of this branch and can open it as a PR against yours or against main, whichever you prefer.

For comparison, with VICTORY_WC_BAR=1 added (same rig, one run each)

none WC_BAR + 3072 WC_BAR + 6144 WC_BAR + 6144 (default path)
Mean fps 16.6 19.1 19.9 19.7
Median fps 17.4 19.9 20.9 20.6
Shared with the card, peak / last (MB) 9047 / 7327 6876 / 4821 5595 / 3893 5685 / 3742
Commit, peak (MB) 30904 30069 28422 28679
Texture line reached no yes no no

VICTORY_WC_BAR=1 adds nothing measurable on top of the windows in frame rate here (19.1-19.9 with it, 18.7-20.4 without), and about 0.6 GB less shared memory; given #553's flicker I would not touch its default.

@trustno1-coder
trustno1-coder merged commit 9942e97 into trustno1-coder:main Nov 30, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request: makes it faster or use less memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants