Windows on the card with their CPU side in plain memory (VICTORY_WINDOW_PLAIN=1): 7.7 -> 6.1 GB of memory shared with the card on a 16 GB PC #281

Open
github-bot wants to merge 1 commit from github-bot/gh-281 into main AGit
Owner

@⁠Zayfway on GitHub · 2026-11-26 14:16 UTC · original
Zayfway:window-plain → main · +85 −12 · 2 files · 1 commits · open

With VICTORY_CARD_WINDOWS_MB, a window of title memory outside buffers gets a card side in the card's memory. Its CPU side still stayed a buffer as big as the window in the PC's memory shared with the card (shared_buffer). The card never reads that buffer: shaders read the card side, and since VICTORY_SEND_OWN (on by default) the sends go out of memory of their own.

On a 16 GB PC that shared budget is 7,488 MiB, and windows were about 4.7 GB of it in the first mission. There, NVIDIA refused upload buffers by the thousand and the device hung (0x887A0005). #255 makes the refusals survivable; this PR removes their cause in that scene.

Change

With VICTORY_WINDOW_PLAIN=1 (off by default), a window that gets a card side has its CPU side in plain committed memory (VirtualAlloc). It holds the same bytes, refreshed the same way, but no longer counts against the shared budget.

The switch only acts while send::own() is on, because the sends must come from memory of their own.

Card.staging becomes Option<ID3D12Resource>:

  • card_sides() gives None for such a window.
  • Every caller already skips a copy without sides.
  • Windows have no shader writes, so no "before" twin.

The plain memory is freed with the copy.

Measurements

PC: RTX 3060 12 GB, Ryzen 7 5700X, 16 GB RAM, Windows 11, Series S profile.

Build: codec-d/cool_fox f4b48ad with the same change. It is built on this repository; shadow.rs and send.rs match here, and this branch applies to 0dec5dc with one trivial mod conflict.

Settings: CARD_BUFFERS_MIN_KB=64, CARD_BUFFERS_MB=1536 (#225), and CARD_WINDOWS_MB=2048 in the runs that have it.

Run Shared memory in use (peak) fps Refused upload buffers Outcome
Whole intro to the prison, without 7,690 MiB 9.7 cutscenes / 11.7 prison — no crash
Whole intro to the prison, WINDOW_PLAIN=1 6,122 MiB 9.4 / 11.5 0 no crash; picture checked against the run without
First mission (check cashing), without (with #255) 7,520–7,744 MiB ~6 at the counter 61 to 48,544 device hung while aiming, or about 6 fps with constant retries
First mission, WINDOW_PLAIN=1 5,728 MiB at the counter, 6,573 peak 9.7 at the counter 0 about 5 minutes of aiming, no hang

Tests

  • cargo test -p victory-gpu --lib shadow: 35 passed, 1 ignored. The test-only Shadow::unbacked is updated for the optional staging.
  • cargo clippy -p victory-gpu --lib -- -D warnings: clean.

Not done

  • It is off by default.
  • Not measured on AMD or with more RAM.
  • When the CPU side is plain memory, the "upcheck" diagnostics skip windows, because they read the CPU side buffer.

🤖 Generated with Claude Code

**@⁠Zayfway** on GitHub · 2026-11-26 14:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/281) `Zayfway:window-plain` → `main` · +85 −12 · 2 files · 1 commits · open With `VICTORY_CARD_WINDOWS_MB`, a window of title memory outside buffers gets a card side in the card's memory. Its CPU side still stayed a buffer as big as the window in the PC's memory shared with the card (`shared_buffer`). The card never reads that buffer: shaders read the card side, and since `VICTORY_SEND_OWN` (on by default) the sends go out of memory of their own. On a 16 GB PC that shared budget is 7,488 MiB, and windows were about 4.7 GB of it in the first mission. There, NVIDIA refused upload buffers by the thousand and the device hung (0x887A0005). #255 makes the refusals survivable; this PR removes their cause in that scene. ### Change With `VICTORY_WINDOW_PLAIN=1` (off by default), a window that gets a card side has its CPU side in plain committed memory (`VirtualAlloc`). It holds the same bytes, refreshed the same way, but no longer counts against the shared budget. The switch only acts while `send::own()` is on, because the sends must come from memory of their own. `Card.staging` becomes `Option<ID3D12Resource>`: - `card_sides()` gives `None` for such a window. - Every caller already skips a copy without sides. - Windows have no shader writes, so no "before" twin. The plain memory is freed with the copy. ### Measurements **PC:** RTX 3060 12 GB, Ryzen 7 5700X, 16 GB RAM, Windows 11, Series S profile. **Build:** codec-d/cool_fox f4b48ad with the same change. It is built on this repository; `shadow.rs` and `send.rs` match here, and this branch applies to 0dec5dc with one trivial `mod` conflict. **Settings:** `CARD_BUFFERS_MIN_KB=64`, `CARD_BUFFERS_MB=1536` (#225), and `CARD_WINDOWS_MB=2048` in the runs that have it. | Run | Shared memory in use (peak) | fps | Refused upload buffers | Outcome | |---|---|---|---|---| | Whole intro to the prison, without | 7,690 MiB | 9.7 cutscenes / 11.7 prison | — | no crash | | Whole intro to the prison, `WINDOW_PLAIN=1` | **6,122 MiB** | 9.4 / 11.5 | 0 | no crash; picture checked against the run without | | First mission (check cashing), without (with #255) | 7,520–7,744 MiB | ~6 at the counter | 61 to 48,544 | device hung while aiming, or about 6 fps with constant retries | | First mission, `WINDOW_PLAIN=1` | 5,728 MiB at the counter, 6,573 peak | 9.7 at the counter | **0** | about 5 minutes of aiming, no hang | ### Tests - `cargo test -p victory-gpu --lib shadow`: 35 passed, 1 ignored. The test-only `Shadow::unbacked` is updated for the optional staging. - `cargo clippy -p victory-gpu --lib -- -D warnings`: clean. ### Not done - It is off by default. - Not measured on AMD or with more RAM. - When the CPU side is plain memory, the "upcheck" diagnostics skip windows, because they read the CPU side buffer. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With VICTORY_CARD_WINDOWS_MB a window's card side is in the card's memory, and
its CPU side stayed a buffer in the PC's memory shared with the card, though
the sends come out of memory of their own (VICTORY_SEND_OWN). That side is now
plain committed memory: the same bytes, outside the budget of memory shared
with the card. Full intro on an RTX 3060 12 GB / 16 GB PC with
CARD_WINDOWS_MB=2048: peak shared use 6,122 MiB (7,690 without), 9.4 / 11.5 fps
(9.7 / 11.7 without), no refused upload buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:22:23 +00:00
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/281/head:github-bot/gh-281'
git switch 'github-bot/gh-281'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-281'
git switch 'github-bot/gh-281'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-281'
git switch 'github-bot/gh-281'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-281'
git switch 'main'
git merge --squash 'github-bot/gh-281'
git switch 'main'
git merge --ff-only 'github-bot/gh-281'
git switch 'main'
git merge 'github-bot/gh-281'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.