Reserve configurable card-buffer room for late large allocations #1168

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

@⁠BradRoland on GitHub · 2026-11-25 22:33 UTC · original
BradRoland:codex/card-buffer-large-headroom → main · +279 −26 · 3 files · 1 commits · open

When the minimum card-buffer size is set below 1 MiB, many small copies can fill the budget before large shader-written buffers appear. The RTX 4080 run in #1163 reported 17 large buffers in shared memory and 122.6 MB per frame of CPU shader-write comparisons at a 1 GiB cap.

This adds VICTORY_CARD_BUFFERS_HEADROOM_MB (default 0). With a sub-1 MiB minimum, small title buffers can consume card memory until their next 64 KiB-rounded allocation would spend that headroom. Title buffers at least 1 MiB long can use the whole cap. The reservation uses the combined live and in-progress total. A failed first allocation or a released copy returns its charge. The setting is documented beside VICTORY_CARD_BUFFERS_MIN_KB.

A D3D12 WARP replay fills an 8 MiB budget with small buffers, then dispatches a shader against a late 2 MiB buffer. At zero headroom the large buffer used shared memory. The CPU snapshotted 2,097,152 bytes and compared 2,097,152 bytes. With 2 MiB reserved the large buffer stayed on the card and both counts fell to zero. Both runs charged exactly 8 MiB, returned 42 to title memory, and released the full charge. Additional tests cover concurrent allocations, the one-byte-under-1-MiB boundary, and a synthetic sequence with large buffers allocated both early and late.

The full Windows workspace passed 606 tests with thirteen ignored, including 204 diagnostics graphics tests. Reproduce the WARP replay with cargo test --locked -p victory-gpu --features diagnostics late_large_buffer_keeps_its_headroom_and_shader_writes -- --nocapture. Gameplay FPS and the black-screen report in #1163 still need a matched title run. The change is AI-assisted and the fixtures are synthetic.

**@⁠BradRoland** on GitHub · 2026-11-25 22:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/1168) `BradRoland:codex/card-buffer-large-headroom` → `main` · +279 −26 · 3 files · 1 commits · open When the minimum card-buffer size is set below 1 MiB, many small copies can fill the budget before large shader-written buffers appear. The RTX 4080 run in #1163 reported 17 large buffers in shared memory and 122.6 MB per frame of CPU shader-write comparisons at a 1 GiB cap. This adds `VICTORY_CARD_BUFFERS_HEADROOM_MB` (default `0`). With a sub-1 MiB minimum, small title buffers can consume card memory until their next 64 KiB-rounded allocation would spend that headroom. Title buffers at least 1 MiB long can use the whole cap. The reservation uses the combined live and in-progress total. A failed first allocation or a released copy returns its charge. The setting is documented beside `VICTORY_CARD_BUFFERS_MIN_KB`. A D3D12 WARP replay fills an 8 MiB budget with small buffers, then dispatches a shader against a late 2 MiB buffer. At zero headroom the large buffer used shared memory. The CPU snapshotted 2,097,152 bytes and compared 2,097,152 bytes. With 2 MiB reserved the large buffer stayed on the card and both counts fell to zero. Both runs charged exactly 8 MiB, returned `42` to title memory, and released the full charge. Additional tests cover concurrent allocations, the one-byte-under-1-MiB boundary, and a synthetic sequence with large buffers allocated both early and late. The full Windows workspace passed 606 tests with thirteen ignored, including 204 diagnostics graphics tests. Reproduce the WARP replay with `cargo test --locked -p victory-gpu --features diagnostics late_large_buffer_keeps_its_headroom_and_shader_writes -- --nocapture`. Gameplay FPS and the black-screen report in #1163 still need a matched title run. The change is AI-assisted and the fixtures are synthetic.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:48 +00:00
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 23:25 UTC · original

First Radeon run of ccc06ed: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 (#402). Base: 3151ccf (main d827419 + #402).

  • victory-gpu: 186 passed, 1 failed. concurrent_reservations_charge_only_admitted_bytes and headroom_protects_late_large_copies_after_an_early_large_allocation pass on the card.
  • The failure is warp_budget_saturates_without_wraparound_and_preserves_draw_fields, the WARP test that #849 fixes, unrelated to this PR.
  • Your command with --features diagnostics: late_large_buffer_keeps_its_headroom_and_shader_writes passes on the card too.
**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/1168#issuecomment-7177549721) First Radeon run of `ccc06ed`: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 (#402). Base: `3151ccf` (main `d827419` + #402). - `victory-gpu`: 186 passed, 1 failed. `concurrent_reservations_charge_only_admitted_bytes` and `headroom_protects_late_large_copies_after_an_early_large_allocation` pass on the card. - The failure is `warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, the WARP test that #849 fixes, unrelated to this PR. - Your command with `--features diagnostics`: `late_large_buffer_keeps_its_headroom_and_shader_writes` passes on the card too.
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-25 23:17 UTC · original · edited 2026-11-25 23:26 UTC

AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.

Setup: RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B:

  • A fxceless stack, f32 path
  • B = A + a local port of Marvisak/VIctory#2825 native f16
  • C = B + #1168 + #1147 + #1164 (VICTORY_CARD_PIECE_KB=16) + #1171 + #1172 + a local commit (skip clean card_dirty copies; chunk wide compare dispatches to ≤ 65,535 groups)
In-world, from the logs A B C
FPS, 2nd-half median (max) 8.8 (9.3) 8.8 (9.7) 8.9 (9.4)
Usual frame, median 112 ms 111 ms 113 ms
GPU title lists (all other lists), 2nd-half median 40.0 ms 38.1 ms 31.8 ms
cardmeter, 256-frame mean, steady 40.8 ms 40.9 ms 31.6–33.7 ms
Copy-back (last usual-frame summary) 23.2 ms / 62.5 MB 22.4 ms / 60.9 MB 28.4 ms / 49.4 MB
Pieces fetched on the copy queue / frame ~1,370 ~1,388 ~4,138
Writes back in place / frame 1,386 1,390 4,150
Card idle per frame 62.5 ms 68.7 ms 68.8 ms
  • GPU: title-list time fell by ~8 ms between B and C. Native f16 alone (A→B) changed it by ~2 ms at most (cardmeter unchanged). Which of C's additions gave the 8 ms is not isolated.
  • No FPS change: the frame is CPU-bound on the submit thread (copies ~63 ms + copy-back 22–28 ms of a ~110 ms frame), so the GPU saving does not reach the screen.
  • Artifacts in C: a frame grabbed at 330 s shows blocky corrupted tiles along the bottom of the screen and a stair-stepped edge on the character's shoulder. Which change causes it is not isolated. B's earlier frame looked clean.
  • Stability: no panic, device-removed or ERROR lines in C's log, no crash in 360 s.

For this PR: built and ran cleanly in C with VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1536: 10,322 card buffers (1,681 MB) made over the run, no crash. Nothing here isolates this PR's headroom. An earlier note gave "3,513 MB free"; that was PC RAM, not video memory.

**@⁠Proudnoob4** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/1168#issuecomment-7177369151) · edited 2026-11-25 23:26 UTC *AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. **This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.*** **Setup:** RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B: - **A** fxceless stack, f32 path - **B** = A + a local port of `Marvisak/VIctory#2825` native f16 - **C** = B + `#1168` + `#1147` + `#1164` (`VICTORY_CARD_PIECE_KB=16`) + `#1171` + `#1172` + a local commit (skip clean `card_dirty` copies; chunk wide compare dispatches to ≤ 65,535 groups) | In-world, from the logs | A | B | C | |---|---:|---:|---:| | FPS, 2nd-half median (max) | 8.8 (9.3) | 8.8 (9.7) | 8.9 (9.4) | | Usual frame, median | 112 ms | 111 ms | 113 ms | | GPU title lists (`all other lists`), 2nd-half median | 40.0 ms | 38.1 ms | **31.8 ms** | | `cardmeter`, 256-frame mean, steady | 40.8 ms | 40.9 ms | **31.6–33.7 ms** | | Copy-back (last usual-frame summary) | 23.2 ms / 62.5 MB | 22.4 ms / 60.9 MB | **28.4 ms** / 49.4 MB | | Pieces fetched on the copy queue / frame | ~1,370 | ~1,388 | **~4,138** | | Writes back in place / frame | 1,386 | 1,390 | 4,150 | | Card idle per frame | 62.5 ms | 68.7 ms | 68.8 ms | - **GPU:** title-list time fell by ~8 ms between B and C. Native f16 alone (A→B) changed it by ~2 ms at most (`cardmeter` unchanged). Which of C's additions gave the 8 ms is **not isolated**. - **No FPS change:** the frame is CPU-bound on the submit thread (copies ~63 ms + copy-back 22–28 ms of a ~110 ms frame), so the GPU saving does not reach the screen. - **Artifacts in C:** a frame grabbed at 330 s shows blocky corrupted tiles along the bottom of the screen and a stair-stepped edge on the character's shoulder. Which change causes it is **not isolated**. B's earlier frame looked clean. - **Stability:** no panic, device-removed or ERROR lines in C's log, no crash in 360 s. **For this PR:** built and ran cleanly in C with `VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1536`: 10,322 card buffers (1,681 MB) made over the run, no crash. Nothing here isolates this PR's headroom. An earlier note gave "3,513 MB free"; that was PC RAM, not video memory.
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/1168/head:github-bot/gh-1168'
git switch 'github-bot/gh-1168'

Merge

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