GPU: loose windows can sit in video memory the CPU writes #2875

Open
github-bot wants to merge 3 commits from github-bot/gh-2875 into main AGit
Owner

@⁠Luislariosss on GitHub · 2026-11-25 22:54 UTC · original
Luislariosss:gpu/loose-in-video-memory → main · +209 −1 · 2 files · 3 commits · open

Why

The non-local segment - the memory budget the system's memory manager gives the GPU, half of system RAM - is the ceiling every long run dies at on a machine with as much card as RAM: measured on one (16 GB card, 15.2 GB RAM, 7,465 MB budget), the segment was pinned at 103-104% in every long run, and at that ceiling the run died two ways - a host command list's Close() returning E_OUTOFMEMORY, or a staging allocation the runtime could not make feeding the title a value it dereferenced (its own missing check; our failure is the trigger either way). The loose windows are that segment's bulk (878 of them, 3,926 MB, never freed, in the run before this change), while the card's own memory sat half empty.

What

VICTORY_LOOSE_IN_GPU_UPLOAD=1 (off by default) puts each new loose window in a GPU upload heap - video memory the CPU maps write-combined, where the host has one - moving them out of the system-memory segment into the card's own. A card without the heap, or an allocation it refuses, falls back to the system-memory buffer there today. The one cost is the CPU's: reading such a window back (snapshots, copy-backs) is uncached bus traffic, so every read of one is counted and warned of once, and the periodic lines carry the count. Stacked on #2856, whose reuse and window lines this builds on.

Measured (one hardware run, same machine as above)

without with
non-local segment 7,733 of 7,465 MB (104%, pinned) 4,104 of 7,465 MB (55%)
staging buffers that failed to allocate 5,058-11,744 a run 0
committed resources returning E_OUTOFMEMORY 1,393-2,508 a run 0
either fatal failure family every long run died none
in-world samples before the run ended 14-22 48
in-world frame rate 0.22-0.48 fps average 0.48 fps average (1.8 peak)
CPU reads of write-combined windows - 90,861, counted, frame rate held
card's own memory ~50% 97% (its eviction pressure path, designed for exactly that, held the run alive)

The run outlived every same-build run before it and moved its wall to process commit (a 4 MiB host allocation failed at 28 GB of private memory): the shared segment's ceiling is gone from this machine's list of killers.

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings and the --all-features variant: clean (on the branch this stacks on; the last commit alone adds two clippy-clean files).
  • cargo test --workspace --locked: green.
  • One hardware run with the switch on (the table above) and several without (the comparison column).

No shader bytes, hashes, or program names from any title (asset policy).

**@⁠Luislariosss** on GitHub · 2026-11-25 22:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875) `Luislariosss:gpu/loose-in-video-memory` → `main` · +209 −1 · 2 files · 3 commits · open ### Why The non-local segment - the memory budget the system's memory manager gives the GPU, half of system RAM - is the ceiling every long run dies at on a machine with as much card as RAM: measured on one (16 GB card, 15.2 GB RAM, 7,465 MB budget), the segment was pinned at 103-104% in every long run, and at that ceiling the run died two ways - a host command list's Close() returning E_OUTOFMEMORY, or a staging allocation the runtime could not make feeding the title a value it dereferenced (its own missing check; our failure is the trigger either way). The loose windows are that segment's bulk (878 of them, 3,926 MB, never freed, in the run before this change), while the card's own memory sat half empty. ### What `VICTORY_LOOSE_IN_GPU_UPLOAD=1` (off by default) puts each new loose window in a GPU upload heap - video memory the CPU maps write-combined, where the host has one - moving them out of the system-memory segment into the card's own. A card without the heap, or an allocation it refuses, falls back to the system-memory buffer there today. The one cost is the CPU's: reading such a window back (snapshots, copy-backs) is uncached bus traffic, so every read of one is counted and warned of once, and the periodic lines carry the count. Stacked on #2856, whose reuse and window lines this builds on. ### Measured (one hardware run, same machine as above) | | without | with | |---|---|---| | non-local segment | 7,733 of 7,465 MB (104%, pinned) | 4,104 of 7,465 MB (55%) | | staging buffers that failed to allocate | 5,058-11,744 a run | 0 | | committed resources returning E_OUTOFMEMORY | 1,393-2,508 a run | 0 | | either fatal failure family | every long run died | none | | in-world samples before the run ended | 14-22 | 48 | | in-world frame rate | 0.22-0.48 fps average | 0.48 fps average (1.8 peak) | | CPU reads of write-combined windows | - | 90,861, counted, frame rate held | | card's own memory | ~50% | 97% (its eviction pressure path, designed for exactly that, held the run alive) | The run outlived every same-build run before it and moved its wall to process commit (a 4 MiB host allocation failed at 28 GB of private memory): the shared segment's ceiling is gone from this machine's list of killers. ### Verification - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the `--all-features` variant: clean (on the branch this stacks on; the last commit alone adds two clippy-clean files). - `cargo test --workspace --locked`: green. - One hardware run with the switch on (the table above) and several without (the comparison column). No shader bytes, hashes, or program names from any title (asset policy).
Loose windows were keyed to their exact (start, length): a memory range a wider window already spanned made its own host buffer and its own copy anyway, although one measured run saw most asks covered by a wider neighbour (36,611 reuses, 153 GB not copied). A miss now takes the first window that covers it - the shared segment these buffers fill is the one that dies (measured: its budget hit 103-104% while the card's own stayed at 50%, and the run ended in a Close() failure the old message mislabeled as an invalid command). A reuse is counted and printed with the periodic lines; a hardware-gated test pins the covering reuse and the ask past the window.
The loose windows are the shared segment's own content and are never freed; a run could not see how many there were or what they weighed. Their count and bytes join the reuse count in the periodic lines, so the next lever (freeing or merging them) starts from a measured size.
The non-local segment - half the system's RAM - is the ceiling every long run dies at, and the loose windows are its bulk (measured: 878 of them, 3,926 MB, never freed, against a 7,465 MB budget; the card's own memory sat half empty). VICTORY_LOOSE_IN_GPU_UPLOAD puts each new loose window in a GPU upload heap (write-combined, CPU-mapped) where the host has one, falling back to the system-memory buffer a card without the heap keeps. The CPU reads of such a window (snapshots, copy-backs) are uncached bus traffic: they are counted and warned of once, and the periodic line carries the count.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:29 +00:00
Author
Owner

@⁠ZeOs360 on GitHub · 2026-11-26 04:12 UTC · original

Matched on/off run of 25c02cd (merged onto main 63bcca4; diagnostics build), on a second machine: RX 7800 XT 16 GB, Ryzen 5 5600, 16 GB RAM, 64 GB page file, Windows 11. GPU upload heaps are available here (on=true). One binary, two runs from a cold start into the prologue, unattended, capped at 12 minutes; only VICTORY_LOOSE_IN_GPU_UPLOAD differs. World samples are the periodic lines with at least 500 draws.

=0 =1
run length 482 s 664 s
first E_OUTOFMEMORY 143 s none
no shared buffer lines 75,407 0
non-local segment, peak 8,114 of 7,620 MB (106%) 4,114 of 7,845 MB (52%)
card's own memory, peak 13,306 of 15,594 MB (85%) 15,608 of 15,602 MB (100%)
loose windows at the end 950 (4,329 MB) 1,444 (6,891 MB)
world fps, before 143 s (samples) 0.89 (9) 0.28 (6)
world fps, after 143 s (samples) 0.27 (47) 0.31 (59)
ms/frame on the GPU, before / after 143 s 223 / 1,150 236 / 210
ms/frame copying back, whole run 96 445
snapshots, per sample with any (58 / 79) 349 MB in 60 ms 701 MB in 2,450 ms
marked copy-back, samples with >500 pages (57 / 78) 35 us/page 161 us/page
write-combined reads counted - 91,659
how it ended title breakpoint at image+0x5149aec title breakpoint at image+0x63966f

What I read from it:

  • The non-local wall is gone here too: no allocation failed in the =1 run, while from 143 s on the =0 run failed 75k shared-buffer allocations.
  • It does not make the GPU faster: before =0 hit that wall, GPU time was the same (223 vs 236 ms/frame) and =1 ran at about a third of the frame rate. What it prevents is the collapse past the wall: =0's GPU time went to 1,150 ms/frame and its frame rate fell below =1's.
  • The cost is the CPU reading the windows: snapshots went from about 0.17 to 3.5 ms per MB, and most of those bytes come from one 64 MiB registered buffer that stays in system memory, so per byte of loose window it is slower still. The marked copy-back went from 35 to 161 us per page.
  • The counter undercounts: Shadow::copy_back_marked reads the window too (it compares the window's bytes with title memory, and loose windows are tracked) but does not call wc_read(), so that cost is not in the 91,659.
  • The card's memory held at 100% only through texture eviction past 90% of the budget, which logs nothing: the host textures made from title memory went from about 4 GB to 226 MB by the end. The loose windows grew 2.5 GB more than in =0, whose windows stopped growing when shared buffers began to fail at 143 s. A card with less memory than this one would likely hit its own wall.
  • Both runs ended at a breakpoint in the title. The +0x63966f one also ended a run of a different build (no #2875) after 9 minutes here, so I don't attribute it to this PR.

No game data, shader names or screenshots, per docs/asset-policy.md.

AI-assisted: measured and written with Claude Code (Claude Opus 5.5), cross-checked by Gemini 4 Neon. I ran both runs on my machine.

**@⁠ZeOs360** on GitHub · 2026-11-26 04:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#issuecomment-7182388439) **Matched on/off run of `25c02cd`** (merged onto `main` `63bcca4`; diagnostics build), on a second machine: RX 7800 XT 16 GB, Ryzen 5 5600, 16 GB RAM, 64 GB page file, Windows 11. GPU upload heaps are available here (`on=true`). One binary, two runs from a cold start into the prologue, unattended, capped at 12 minutes; only `VICTORY_LOOSE_IN_GPU_UPLOAD` differs. World samples are the periodic lines with at least 500 draws. | | `=0` | `=1` | |---|---|---| | run length | 482 s | 664 s | | first E_OUTOFMEMORY | 143 s | none | | `no shared buffer` lines | 75,407 | 0 | | non-local segment, peak | 8,114 of 7,620 MB (106%) | 4,114 of 7,845 MB (52%) | | card's own memory, peak | 13,306 of 15,594 MB (85%) | 15,608 of 15,602 MB (100%) | | loose windows at the end | 950 (4,329 MB) | 1,444 (6,891 MB) | | world fps, before 143 s (samples) | 0.89 (9) | 0.28 (6) | | world fps, after 143 s (samples) | 0.27 (47) | 0.31 (59) | | ms/frame on the GPU, before / after 143 s | 223 / 1,150 | 236 / 210 | | ms/frame copying back, whole run | 96 | 445 | | snapshots, per sample with any (58 / 79) | 349 MB in 60 ms | 701 MB in 2,450 ms | | marked copy-back, samples with >500 pages (57 / 78) | 35 us/page | 161 us/page | | write-combined reads counted | - | 91,659 | | how it ended | title breakpoint at `image+0x5149aec` | title breakpoint at `image+0x63966f` | What I read from it: - The non-local wall is gone here too: no allocation failed in the `=1` run, while from 143 s on the `=0` run failed 75k shared-buffer allocations. - It does not make the GPU faster: before `=0` hit that wall, GPU time was the same (223 vs 236 ms/frame) and `=1` ran at about a third of the frame rate. What it prevents is the collapse past the wall: `=0`'s GPU time went to 1,150 ms/frame and its frame rate fell below `=1`'s. - The cost is the CPU reading the windows: snapshots went from about 0.17 to 3.5 ms per MB, and most of those bytes come from one 64 MiB registered buffer that stays in system memory, so per byte of loose window it is slower still. The marked copy-back went from 35 to 161 us per page. - The counter undercounts: `Shadow::copy_back_marked` reads the window too (it compares the window's bytes with title memory, and loose windows are tracked) but does not call `wc_read()`, so that cost is not in the 91,659. - The card's memory held at 100% only through texture eviction past 90% of the budget, which logs nothing: the host textures made from title memory went from about 4 GB to 226 MB by the end. The loose windows grew 2.5 GB more than in `=0`, whose windows stopped growing when shared buffers began to fail at 143 s. A card with less memory than this one would likely hit its own wall. - Both runs ended at a breakpoint in the title. The `+0x63966f` one also ended a run of a different build (no #2875) after 9 minutes here, so I don't attribute it to this PR. No game data, shader names or screenshots, per `docs/asset-policy.md`. AI-assisted: measured and written with Claude Code (Claude Opus 5.5), cross-checked by Gemini 4 Neon. I ran both runs on my machine.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:27 UTC · original

Automated triage for the maintainers.

Needs work. The opt-in VICTORY_LOOSE_IN_GPU_UPLOAD (loose windows in a GPU upload heap, Host::loose_buffer) is reasonable and the hardware tables are encouraging, but the branch still carries both commits of #2856; please rebase once that lands so only the last commit remains. Shadow::copy_back_marked reads the window without calling wc_read(), so the new counter undercounts. The second run also showed the CPU cost (snapshots about 20x slower per MB); please note that trade-off in the README entry.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#issuecomment-7182607892) <!-- victory-triage v1 head=25c02cd2221d4effb942fb0a3dd1856e073a447b verdict=needs-work at=2026-11-26T04:27:04Z --> Automated triage for the maintainers. **Needs work.** The opt-in `VICTORY_LOOSE_IN_GPU_UPLOAD` (loose windows in a GPU upload heap, `Host::loose_buffer`) is reasonable and the hardware tables are encouraging, but the branch still carries both commits of #2856; please rebase once that lands so only the last commit remains. `Shadow::copy_back_marked` reads the window without calling `wc_read()`, so the new counter undercounts. The second run also showed the CPU cost (snapshots about 20x slower per MB); please note that trade-off in the README entry. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠AwsAli05 on GitHub · 2026-11-25 23:06 UTC · original · reviewed

I independently checked the allocation request from buffer_in on an RTX 5070 Ti with the D3D12 debug layer requested. Options16 reported GPU upload heaps supported. A 4 MiB committed GPU_UPLOAD buffer created with COMMON and ALLOW_UNORDERED_ACCESS succeeded, and Map returned a non-null pointer.

That confirms the allocation path on this device. The next useful comparison would be a matched world run with the option on and off, recording local and non-local memory along with frame time. CPU readback volume would help explain any frame-time regression, since a count of readbacks treats small and large ranges alike.

AI-assisted review and synthetic D3D12 probe.

**@⁠AwsAli05** on GitHub · 2026-11-25 23:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#pullrequestreview-6066206699) · **reviewed** I independently checked the allocation request from `buffer_in` on an RTX 5070 Ti with the D3D12 debug layer requested. Options16 reported GPU upload heaps supported. A 4 MiB committed `GPU_UPLOAD` buffer created with `COMMON` and `ALLOW_UNORDERED_ACCESS` succeeded, and `Map` returned a non-null pointer. That confirms the allocation path on this device. The next useful comparison would be a matched world run with the option on and off, recording local and non-local memory along with frame time. CPU readback volume would help explain any frame-time regression, since a count of readbacks treats small and large ranges alike. AI-assisted review and synthetic D3D12 probe.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 23:36 UTC · original · reviewed

Sound: opt-in WC-heap residency for loose windows trades uncached readback for freeing system RAM (the documented small-RAM ceiling), the OPTIONS16 probe plus allocation-failure fallback degrade safely to system memory, and WC_READS makes the cost observable. Off by default is the right rollout for a latency-sensitive path. LGTM.

**@⁠kotekompotek** on GitHub · 2026-11-25 23:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#pullrequestreview-6066488577) · **reviewed** Sound: opt-in WC-heap residency for loose windows trades uncached readback for freeing system RAM (the documented small-RAM ceiling), the OPTIONS16 probe plus allocation-failure fallback degrade safely to system memory, and WC_READS makes the cost observable. Off by default is the right rollout for a latency-sensitive path. LGTM.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 23:37 UTC · original · reviewed

Verified head 25c02cd2 cleanly merged onto origin/main (63bcca43) on Windows 11 x64 across both a GPU Upload Heaps capable adapter (NVIDIA GeForce RTX 5090, GPUUploadHeapSupported == true) and a fallback adapter (D3D12 WARP, GPUUploadHeapSupported == false), with VICTORY_D3D12_DEBUG=1.

Code Review

  • Covering-window reuse in Shadow::loose (map.range(..(start, u64::MAX)).rev()) cleanly reuses any wider loose window (including same-start wider windows) and keeps opt-in risk low via VICTORY_LOOSE_IN_GPU_UPLOAD=1 with automatic fallback to shared_buffer.
  • Minor notes (non-blocking):
    • In Shadow::update_tracked, the busy / sync_before path that reads self.data does not call wc_read(), so write-combined read accounting omits that path while copy_back_page, take_snapshot, and compare_snapshot do count it.
    • The new loose windows: ... meter log line prints unconditionally on Windows even without --features diagnostics (worth confirming that's desired alongside the existing meter output).

Local Verification (VICTORY_D3D12_DEBUG=1)

  • RTX 5090 (default): shadow::tests 10/10 passed.
  • RTX 5090 (VICTORY_LOOSE_IN_GPU_UPLOAD=1, GPU Upload Heaps active): shadow::tests 10/10 passed (including a_wider_loose_window_covers_a_later_smaller_ask and bytes_off_the_runtimes_memory_are_copied_at_each_use, zero debug-layer errors).
  • WARP (VICTORY_LOOSE_IN_GPU_UPLOAD=1, fallback path): shadow::tests 10/10 passed.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics) & cargo xtask policy (191 files ok): clean.

Looks good.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 23:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#pullrequestreview-6066498808) · **reviewed** Verified head `25c02cd2` cleanly merged onto `origin/main` (`63bcca43`) on Windows 11 x64 across both a GPU Upload Heaps capable adapter (**NVIDIA GeForce RTX 5090**, `GPUUploadHeapSupported == true`) and a fallback adapter (**D3D12 WARP**, `GPUUploadHeapSupported == false`), with `VICTORY_D3D12_DEBUG=1`. ### Code Review - Covering-window reuse in `Shadow::loose` (`map.range(..(start, u64::MAX)).rev()`) cleanly reuses any wider loose window (including same-start wider windows) and keeps opt-in risk low via `VICTORY_LOOSE_IN_GPU_UPLOAD=1` with automatic fallback to `shared_buffer`. - **Minor notes (non-blocking)**: - In `Shadow::update_tracked`, the `busy` / `sync_before` path that reads `self.data` does not call `wc_read()`, so write-combined read accounting omits that path while `copy_back_page`, `take_snapshot`, and `compare_snapshot` do count it. - The new `loose windows: ...` meter log line prints unconditionally on Windows even without `--features diagnostics` (worth confirming that's desired alongside the existing meter output). ### Local Verification (`VICTORY_D3D12_DEBUG=1`) - **RTX 5090 (default)**: `shadow::tests` **10/10 passed**. - **RTX 5090 (`VICTORY_LOOSE_IN_GPU_UPLOAD=1`, GPU Upload Heaps active)**: `shadow::tests` **10/10 passed** (including `a_wider_loose_window_covers_a_later_smaller_ask` and `bytes_off_the_runtimes_memory_are_copied_at_each_use`, zero debug-layer errors). - **WARP (`VICTORY_LOOSE_IN_GPU_UPLOAD=1`, fallback path)**: `shadow::tests` **10/10 passed**. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`) & `cargo xtask policy` (`191 files ok`): clean. Looks good.
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-26 14:21 UTC · original

A note for 8 GB cards, from reading 25c02cd2 (and an RTX 4060 8 GB test run: cargo test -p victory-gpu --lib merged onto main 63bcca4 gives 230 passed, with only the 2 known NVIDIA heap-cap failures that main also has).

loose_buffer puts every new loose window in GPU_UPLOAD while the switch is on, and only falls back when the allocation fails. On WDDM that allocation usually succeeds past the local budget, and the memory manager then demotes or evicts other resources. On this 4060 the local budget is 7,537 MB, and the README says the world wants about 10 GB, so moving the 3.9 GB of windows from your run onto the card would make the 8 GB case worse. Your 16 GB card already sat at 97 %. Could new windows go to system memory once local CurrentUsage passes a share of Budget (from QueryVideoMemoryInfo)? Or the README entry could say it is for cards with spare video memory.

AI-assisted (Claude).

**@⁠potatoe0100** on GitHub · 2026-11-26 14:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#issuecomment-7194694482) A note for 8 GB cards, from reading `25c02cd2` (and an RTX 4060 8 GB test run: `cargo test -p victory-gpu --lib` merged onto `main` `63bcca4` gives 230 passed, with only the 2 known NVIDIA heap-cap failures that `main` also has). `loose_buffer` puts every new loose window in `GPU_UPLOAD` while the switch is on, and only falls back when the allocation fails. On WDDM that allocation usually succeeds past the local budget, and the memory manager then demotes or evicts other resources. On this 4060 the local budget is 7,537 MB, and the README says the world wants about 10 GB, so moving the 3.9 GB of windows from your run onto the card would make the 8 GB case worse. Your 16 GB card already sat at 97 %. Could new windows go to system memory once local `CurrentUsage` passes a share of `Budget` (from `QueryVideoMemoryInfo`)? Or the README entry could say it is for cards with spare video memory. AI-assisted (Claude).
Author
Owner

@⁠ZeOs360 on GitHub · 2026-11-26 18:38 UTC · original

Follow-up to my matched run above: in gameplay, most of a frame went to the CPU reading loose windows the GPU wrote. Keeping those windows in system memory made frames 5.2× faster.

Same machine (RX 7800 XT 16 GB, Ryzen 5 5600, 16 GB RAM, Windows 11), diagnostics build of main 63bcca4 + 25c02cd + #2644, VICTORY_LOOSE_IN_GPU_UPLOAD=1. My earlier runs all stopped at the title's pool breakpoint from #698 after 8–11 minutes. To get past it I used #2644's VICTORY_STEP_OVER=5149aec,63966f,1fa88e4. Two runs, both to my 30-minute cap:

  • A: the build as above.

  • B: the same build plus a local experiment, which is not in this PR. A loose window is made in system memory (shared_buffer) instead of loose_buffer when the lookup that makes it is for a GPU write. Those lookups are:

    • root UAV descriptors, both root_views and the root descriptors State::bind hands to shaders that use title memory;
    • unordered and writable placed buffer views (buffer_uav, and view_copy when the descriptor is written).

    Every other window still goes to GPU upload memory.

Neither run ran out of memory, and in both I could move the character. The gameplay samples are the periodic lines with at least 4,000 draws, from 16 minutes in for A (77 samples) and from 4 minutes in for B (251 samples). B reached gameplay much earlier, and then played further into heavier scenes (more draws, larger snapshots), so the comparison, if anything, favours A. Medians:

A: #2875 as is B: written windows in system memory
ms/frame 4,816 929
preparing 2,396 367
snapshots 328 MB in 1,752 ms 488 MB in 193 ms
on the GPU 310 252
copying back 2,025 308
"copying back compared", samples where it ran (A 46, B 236) 62 MB in 1,955 ms 51 MB in 96 ms
draws/frame 4,919 6,296

What I read from it:

  • In A, most of the frame is the CPU reading write-combined memory. Snapshots are the largest part of "preparing", and the declared-range comparison makes up most of "copying back". In A's top-6 snapshot breakdown, the largest copy is a 64 MiB registered title buffer, which stays in system memory and is cheap. The others are 4 MiB loose windows, read at a median of about 47 MB/s. The comparison read about 32 MB/s.
  • B does the same work in a fraction of the time. It snapshots more bytes per frame than A, with more draws, in about a ninth of the time. GPU time is about the same in both, so the gain is on the CPU side.
  • Card memory stays within budget, and system memory has room. B's card peaked at 14,527 MB of a 15,033 MB budget, against 15,457 MB of 15,027 MB in A. Heap texture uploads fell from about 460 ms to about 20 ms per frame. The non-local segment peaked at 4,947 MB of 7,845 in B, against 4,285 in A. B ended with 1,219 loose windows (5,516 MB, in both memory kinds), against 1,686 (7,646 MB) in A.
  • B never hit the pool breakpoints. It stepped over 0 of them in 30 minutes, while A first stepped over at about 9 minutes. It's one run, but it fits the reading in #698 that the pools overflow because the opening cutscene runs slowly.

Some reads of these windows are still not counted, because they skip wc_read(). Besides Shadow::copy_back_marked (named above), sync_before and Shadow::copy (through Tracked::refreshed) also read the window's bytes without it.

The experiment does not catch every written window. A window first made by a read and written later, a window served by a wider one that already exists, and memory shaders write at computed addresses all stay in GPU upload memory. B still counted 79,219 write-combined reads, against 204,992 in A. It is a local hack, not a proposal for how to structure it. A thread-local flag around those lookups, read in loose(), is enough to try it. I can share the diff if useful.

No game data, shader names or screenshots, per docs/asset-policy.md.

AI-assisted: measured and written with Claude Code (Claude Opus 5.5), cross-checked by Gemini 4 Neon. I ran both runs on my machine.

**@⁠ZeOs360** on GitHub · 2026-11-26 18:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2875#issuecomment-7200691205) **Follow-up to my matched run above: in gameplay, most of a frame went to the CPU reading loose windows the GPU wrote. Keeping those windows in system memory made frames 5.2× faster.** Same machine (RX 7800 XT 16 GB, Ryzen 5 5600, 16 GB RAM, Windows 11), diagnostics build of `main` `63bcca4` + `25c02cd` + #2644, `VICTORY_LOOSE_IN_GPU_UPLOAD=1`. My earlier runs all stopped at the title's pool breakpoint from #698 after 8–11 minutes. To get past it I used #2644's `VICTORY_STEP_OVER=5149aec,63966f,1fa88e4`. Two runs, both to my 30-minute cap: - **A:** the build as above. - **B:** the same build plus a local experiment, which is not in this PR. A loose window is made in system memory (`shared_buffer`) instead of `loose_buffer` when the lookup that makes it is for a GPU write. Those lookups are: - root UAV descriptors, both `root_view`s and the root descriptors `State::bind` hands to shaders that use title memory; - unordered and writable placed buffer views (`buffer_uav`, and `view_copy` when the descriptor is written). Every other window still goes to GPU upload memory. Neither run ran out of memory, and in both I could move the character. The gameplay samples are the periodic lines with at least 4,000 draws, from 16 minutes in for A (77 samples) and from 4 minutes in for B (251 samples). B reached gameplay much earlier, and then played further into heavier scenes (more draws, larger snapshots), so the comparison, if anything, favours A. Medians: | | A: #2875 as is | B: written windows in system memory | |---|---|---| | ms/frame | 4,816 | 929 | | preparing | 2,396 | 367 | | snapshots | 328 MB in 1,752 ms | 488 MB in 193 ms | | on the GPU | 310 | 252 | | copying back | 2,025 | 308 | | "copying back compared", samples where it ran (A 46, B 236) | 62 MB in 1,955 ms | 51 MB in 96 ms | | draws/frame | 4,919 | 6,296 | What I read from it: - **In A, most of the frame is the CPU reading write-combined memory.** Snapshots are the largest part of "preparing", and the declared-range comparison makes up most of "copying back". In A's top-6 snapshot breakdown, the largest copy is a 64 MiB registered title buffer, which stays in system memory and is cheap. The others are 4 MiB loose windows, read at a median of about 47 MB/s. The comparison read about 32 MB/s. - **B does the same work in a fraction of the time.** It snapshots more bytes per frame than A, with more draws, in about a ninth of the time. GPU time is about the same in both, so the gain is on the CPU side. - **Card memory stays within budget, and system memory has room.** B's card peaked at 14,527 MB of a 15,033 MB budget, against 15,457 MB of 15,027 MB in A. Heap texture uploads fell from about 460 ms to about 20 ms per frame. The non-local segment peaked at 4,947 MB of 7,845 in B, against 4,285 in A. B ended with 1,219 loose windows (5,516 MB, in both memory kinds), against 1,686 (7,646 MB) in A. - **B never hit the pool breakpoints.** It stepped over 0 of them in 30 minutes, while A first stepped over at about 9 minutes. It's one run, but it fits the reading in #698 that the pools overflow because the opening cutscene runs slowly. Some reads of these windows are still not counted, because they skip `wc_read()`. Besides `Shadow::copy_back_marked` (named above), `sync_before` and `Shadow::copy` (through `Tracked::refreshed`) also read the window's bytes without it. The experiment does not catch every written window. A window first made by a read and written later, a window served by a wider one that already exists, and memory shaders write at computed addresses all stay in GPU upload memory. B still counted 79,219 write-combined reads, against 204,992 in A. It is a local hack, not a proposal for how to structure it. A thread-local flag around those lookups, read in `loose()`, is enough to try it. I can share the diff if useful. No game data, shader names or screenshots, per `docs/asset-policy.md`. AI-assisted: measured and written with Claude Code (Claude Opus 5.5), cross-checked by Gemini 4 Neon. I ran both runs on my machine.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2875/head:github-bot/gh-2875'
git switch 'github-bot/gh-2875'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2875'
git switch 'github-bot/gh-2875'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2875'
git switch 'github-bot/gh-2875'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2875'
git switch 'main'
git merge --squash 'github-bot/gh-2875'
git switch 'main'
git merge --ff-only 'github-bot/gh-2875'
git switch 'main'
git merge 'github-bot/gh-2875'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2875
No description provided.