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
Zayfway wants to merge 1 commit from upstream-pr/281 into main
Zayfway commented 2026-11-26 14:16:11 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Zayfway on 2026-11-26T14:16:11Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6628558712 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/281). Originally posted by [Zayfway](https://github.com/Zayfway) on 2026-11-26T14:16:11Z. --- 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)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/281:upstream-pr/281'
git switch 'upstream-pr/281'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/281'
git switch 'upstream-pr/281'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/281'
git switch 'upstream-pr/281'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/281'
git switch 'main'
git merge --squash 'upstream-pr/281'
git switch 'main'
git merge --ff-only 'upstream-pr/281'
git switch 'main'
git merge 'upstream-pr/281'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!281
No description provided.