GPU: reuse retired staging buffers for oversized uploads #1391

Open
NotADonky43 wants to merge 4 commits from upstream-pr/1391 into main
NotADonky43 commented 2026-11-28 18:44:26 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by NotADonky43 on 2026-11-28T18:44:26Z.


Supersedes #1383. Oversized uploads currently require one contiguous buffer, even when retired upload buffers are available. Right-size allocations larger than the retention budget. With VICTORY_STAGE_SEGMENTS=1, keep each destination's bulk copies and scatter pairs together, reuse fenced spare blocks first, and allocate only the remainder. All source blocks remain owned until the original submission retires.

On an RTX 5070 Ti, the instrumented same-executable opening A/B reused 264 MiB twice. Repeat live staging capacity at fill: 1.54 GB single-buffer vs 1.32 GB segmented, despite staging more bytes. This is upload memory at one point, not whole-process savings or a sustained FPS claim. Both sides used identical precompiled shader and pipeline seeds. Visual comparison: no observed rendering difference and less perceived hitching.

The source-only extraction builds in release and passes the included offset regression. Mixed bulk/scatter byte-exact readback passed in an isolated RTX 5070 Ti test with D3D12 diagnostics: 4 independent destinations per run, both empty pool and retired + fresh blocks, including unchanged sentinel bytes. The native 513 MiB retention/reuse test also passed. Longer-session validation remains outstanding; segmentation is opt-in. No game data or caches included.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5543443970 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1391). Originally posted by [NotADonky43](https://github.com/NotADonky43) on 2026-11-28T18:44:26Z. --- Supersedes #1383. Oversized uploads currently require one contiguous buffer, even when retired upload buffers are available. Right-size allocations larger than the retention budget. With `VICTORY_STAGE_SEGMENTS=1`, keep each destination's bulk copies and scatter pairs together, reuse fenced spare blocks first, and allocate only the remainder. All source blocks remain owned until the original submission retires. On an RTX 5070 Ti, the instrumented same-executable opening A/B reused 264 MiB twice. Repeat live staging capacity at fill: 1.54 GB single-buffer vs 1.32 GB segmented, despite staging more bytes. This is upload memory at one point, not whole-process savings or a sustained FPS claim. Both sides used identical precompiled shader and pipeline seeds. Visual comparison: no observed rendering difference and less perceived hitching. The source-only extraction builds in release and passes the included offset regression. Mixed bulk/scatter byte-exact readback passed in an isolated RTX 5070 Ti test with D3D12 diagnostics: 4 independent destinations per run, both empty pool and retired + fresh blocks, including unchanged sentinel bytes. The native 513 MiB retention/reuse test also passed. Longer-session validation remains outstanding; segmentation is opt-in. No game data or caches included.
ANDREANIADS commented 2026-11-28 18:49:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ANDREANIADS on 2026-11-28T18:49:37Z.


CPU-only byte check at b1f44ad: I exercised take and Own::record with a CPU stand-in for the command list. Three 128-byte destinations used distinct source patterns, each with both a bulk copy and a scatter update. With a 64-byte test retention limit and one retired 64-byte block, destination ranges [1,4), [16,20) / [3,52), [64,72) / [8,16), [25,30) produced block IDs 1 → 0 → 1 and three scatter source bindings. The single-buffer control used 0 → 0 → 0 and one binding. All 384 destination bytes matched the independently expected bytes in each run, including untouched bytes initialized to 0xcd. This covers switching back to a previously used block. D3D12 execution, barriers, fence lifetime and GPU readback remain untested here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244082932 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1391#issuecomment-7244082932). Originally posted by [ANDREANIADS](https://github.com/ANDREANIADS) on 2026-11-28T18:49:37Z. --- CPU-only byte check at `b1f44ad`: I exercised `take` and `Own::record` with a CPU stand-in for the command list. Three 128-byte destinations used distinct source patterns, each with both a bulk copy and a scatter update. With a 64-byte test retention limit and one retired 64-byte block, destination ranges `[1,4), [16,20)` / `[3,52), [64,72)` / `[8,16), [25,30)` produced block IDs `1 → 0 → 1` and three scatter source bindings. The single-buffer control used `0 → 0 → 0` and one binding. All 384 destination bytes matched the independently expected bytes in each run, including untouched bytes initialized to `0xcd`. This covers switching back to a previously used block. D3D12 execution, barriers, fence lifetime and GPU readback remain untested here.
Lancito01 commented 2026-11-28 19:44:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lancito01 on 2026-11-28T19:44:39Z.


Data point, RTX 3080 10 GB / 32 GB RAM, Series S mode, main 9ce3cf9e + #938 face fix, prison prologue scenes (~4.1k draws/frame):

  • without this PR: median 65.4 ms/frame (63-76), peak process working set 17.8 GB
  • with this PR + VICTORY_STAGE_SEGMENTS=1: median 64.7 ms/frame (60-77), peak working set 18.1 GB

No regressions or visual issues seen in ~10 min, but also no measurable RAM or frame-time change on this setup; the staging buffer doesn't seem to be where memory goes here. One run each, so treat as a rough sample.

AI-assisted (Claude).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244772571 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1391#issuecomment-7244772571). Originally posted by [Lancito01](https://github.com/Lancito01) on 2026-11-28T19:44:39Z. --- Data point, RTX 3080 10 GB / 32 GB RAM, Series S mode, main 9ce3cf9e + #938 face fix, prison prologue scenes (~4.1k draws/frame): - without this PR: median 65.4 ms/frame (63-76), peak process working set 17.8 GB - with this PR + `VICTORY_STAGE_SEGMENTS=1`: median 64.7 ms/frame (60-77), peak working set 18.1 GB No regressions or visual issues seen in ~10 min, but also no measurable RAM or frame-time change on this setup; the staging buffer doesn't seem to be where memory goes here. One run each, so treat as a rough sample. *AI-assisted (Claude).*
NotADonky43 commented 2026-11-28 22:59:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by NotADonky43 on 2026-11-28T22:59:27Z.


Integration note for NVIDIA main d4b5d517: in send::take retain both total_pair_words += words as u64 and block: 0; in Own::record rebind the source SRV on block change and retain main’s shadow.buffer_gpu() destination. Keep both the pack_copy_tasks test and the PR’s native tests. In upload_test_target, cache unsafe { buffer.GetGPUVirtualAddress() } in Shadow::new instead of passing zero: the stock fixture otherwise binds a null root UAV on the new code. This is a test fixture change, not a game fault. Combined on RTX 5070 Ti with the copy-queue sizing and pressure-drain changes: mixed bulk/scatter byte-exact GPU test passed with debug layer and GBV; the 513 MiB retention/reuse test passed. No new FPS claim. I have the conflict resolution locally; the fork branch push was rejected because syncing main also imports workflow files outside the account token’s scope. No CI/workflow edits requested.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247121525 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1391#issuecomment-7247121525). Originally posted by [NotADonky43](https://github.com/NotADonky43) on 2026-11-28T22:59:27Z. --- Integration note for NVIDIA main `d4b5d517`: in `send::take` retain both `total_pair_words += words as u64` and `block: 0`; in `Own::record` rebind the source SRV on block change and retain main’s `shadow.buffer_gpu()` destination. Keep both the `pack_copy_tasks` test and the PR’s native tests. In `upload_test_target`, cache `unsafe { buffer.GetGPUVirtualAddress() }` in `Shadow::new` instead of passing zero: the stock fixture otherwise binds a null root UAV on the new code. This is a **test fixture change**, not a game fault. Combined on RTX 5070 Ti with the copy-queue sizing and pressure-drain changes: mixed bulk/scatter byte-exact GPU test passed with debug layer and GBV; the 513 MiB retention/reuse test passed. No new FPS claim. I have the conflict resolution locally; the fork branch push was rejected because syncing main also imports workflow files outside the account token’s scope. No CI/workflow edits requested.
pickles976 commented 2026-11-29 08:06:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by pickles976 on 2026-11-29T08:06:16Z.


Verified the segmented submission-upload mechanism in a disclosed adaptation onto our older synchronous send path (local commit6463c32537872478d2c4bbd651236383f05b2f5a overfb92449bd3), not an exact-head/full-PR certification. Physical RTX4060 Laptop8GiB, Wine11/NVIDIA590.48.1, stock assertion-enabled app-local vkd3d2576c0b4adfae4a; loader paths/hashes verified, vendor0x10de/softwareflags0 required, raw-access chains disabled.

Fresh17.91s intended-tree build; three focused checks pass3/3,0ignored,1.01s. The actual GPU fixture runs two legs with STAGE_SEGMENTS=1/SEND_SPARE_MB=1: empty pool gives one exact allocation; a retired512KiB block then gives mixed source sequence[1,0,1,0]. Every CPU source is mutated after packing and before recording. All5242880 destination bytes match original bulk/scatter snapshots or untouched sentinels. The retired block identity is reused, no upload returns to the spare pool before explicit retirement after native completion, and idle capacity stays<=1MiB. Two pure rebasing/rounding checks pass too. Native buffer fixture stays below8MiB; peakGPU361MiB/minavailableRAM11781MiB.

This does not exercise forced allocation failure, an artificially pending queue, original title shaders, or establish a frame-time/telemetry fix. Complete destination groups and the fresh remainder can still be large; with no retired blocks the full request remains necessary. Our prior loading run stalled a native telemetry query while a379362704-byte upload allocation was outstanding, with submit-thread allocation/I/O waits sampled; correlation, not proven driver-lock causality. Changed title observations are recorded below. External2s telemetry/9GiB+512MiB scope/6000MiB GPU/2048MiB availableRAM/10GiB disk guards remain unchanged.

Evidence: verify-nvidia-segmented-upload-build-fixed-20261129T080229Z/ and verify-nvidia-segmented-upload-stock-20261129T080247Z/. Adaptation retains the original CardPlan completion point and has no copy-queue port.

Guarded title follow-through, 29 Nov

Same committed adaptation6463c325, fresh86s release SHA2564e5ca0dc4a7ff6565b71650a401f5137df9141b7f57cc621e15808bac7650bbd. Four streaming workers,512ahead buffers,128MiB completed-send cap, private CPU mirrors,80% texture line,64MiB separate small/ordinary texture pools, scoped file-backed XMem with native imports disabled. Existing fork rendering defaults/omitted programs retained; no added shader skips.

Run081925 reached actual rendered cutscenes (characters/city at180s, car interior240s), not demonstrated controllable gameplay. A543939088-byte send used50331648 retired bytes and493607440 fresh bytes; the fresh native allocation returned in747.9309ms. The cold164168032-byte one-group send still required one full fresh block (31.1504ms). Thus reuse really executes, but the remainder is not a small-allocation cap and this is not a matched performance comparison.

The unchanged6000MiB global-GPU guard stopped at276.08s/6061MiB, exit137. RAM minimum3184.8MiB, scope peak9GiB/max1155/oom0, disk minimum12.206GiB. All274 native guard queries completed (max582.65ms); independent observer max244.51ms. No kernel entries or observed title exception. The supervisor now uses a pre-launch journal cursor;256 kernel queries completed, max0.863s, with its original3s deadline. The preceding080855 observation stopped on that journal monitor deadline, not a GPU query failure; it is not counted as a full run.

Performance remains far below target:69 disjoint late host-present-attempt windows/302 intervals,298over50ms,250over100ms, max3200.8ms. These are not scanout or global percentile/FPS measurements. Final pool census28×64MiB blocks,1463MiB held,322MiB free,6MiB resting,0empty; other GPU owners remain. No sustained safety, frame-time gain or15-minute gameplay claim. All stopped backing files were removed only after exact inode/scope/no-holder checks.

Evidence: nvidia-fork-trial-20261129T081925Z/{verified-summary,late-present-attempts,vram-admission-evidence,backing-cleanup}.json. Captures remain local/unpublished. The next action is offscreen small-card address-arena/shared-memory coherence verification, not a higher guard or an eight-worker run.

Later hardware safety hold: a subsequent changed registered-copy-budget experiment hit an Intel i915/Xwayland GPU hang/reset. All GPU/title work is parked; no attribution to segmented uploads or that quota is established. Details: https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1226#issuecomment-7254875954 . Earlier offscreen and scoped observations above remain their exact, limited results.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7252888505 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1391#issuecomment-7252888505). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-29T08:06:16Z. --- Verified the segmented submission-upload mechanism in a disclosed adaptation onto our older synchronous send path (local commit6463c32537872478d2c4bbd651236383f05b2f5a overfb92449bd3), not an exact-head/full-PR certification. Physical RTX4060 Laptop8GiB, Wine11/NVIDIA590.48.1, stock assertion-enabled app-local vkd3d2576c0b4adfae4a; loader paths/hashes verified, vendor0x10de/softwareflags0 required, raw-access chains disabled. Fresh17.91s intended-tree build; three focused checks pass3/3,0ignored,1.01s. The actual GPU fixture runs two legs with STAGE_SEGMENTS=1/SEND_SPARE_MB=1: empty pool gives one exact allocation; a retired512KiB block then gives mixed source sequence[1,0,1,0]. Every CPU source is mutated after packing and before recording. All5242880 destination bytes match original bulk/scatter snapshots or untouched sentinels. The retired block identity is reused, no upload returns to the spare pool before explicit retirement after native completion, and idle capacity stays<=1MiB. Two pure rebasing/rounding checks pass too. Native buffer fixture stays below8MiB; peakGPU361MiB/minavailableRAM11781MiB. This does not exercise forced allocation failure, an artificially pending queue, original title shaders, or establish a frame-time/telemetry fix. Complete destination groups and the fresh remainder can still be large; with no retired blocks the full request remains necessary. Our prior loading run stalled a native telemetry query while a379362704-byte upload allocation was outstanding, with submit-thread allocation/I/O waits sampled; correlation, not proven driver-lock causality. Changed title observations are recorded below. External2s telemetry/9GiB+512MiB scope/6000MiB GPU/2048MiB availableRAM/10GiB disk guards remain unchanged. Evidence: verify-nvidia-segmented-upload-build-fixed-20261129T080229Z/ and verify-nvidia-segmented-upload-stock-20261129T080247Z/. Adaptation retains the original CardPlan completion point and has no copy-queue port. ### Guarded title follow-through, 29 Nov Same committed adaptation6463c325, fresh86s release SHA2564e5ca0dc4a7ff6565b71650a401f5137df9141b7f57cc621e15808bac7650bbd. Four streaming workers,512ahead buffers,128MiB completed-send cap, private CPU mirrors,80% texture line,64MiB separate small/ordinary texture pools, scoped file-backed XMem with native imports disabled. Existing fork rendering defaults/omitted programs retained; no added shader skips. Run081925 reached actual rendered cutscenes (characters/city at180s, car interior240s), not demonstrated controllable gameplay. A543939088-byte send used50331648 retired bytes and493607440 fresh bytes; the fresh native allocation returned in747.9309ms. The cold164168032-byte one-group send still required one full fresh block (31.1504ms). Thus reuse really executes, but the remainder is not a small-allocation cap and this is not a matched performance comparison. The unchanged6000MiB global-GPU guard stopped at276.08s/6061MiB, exit137. RAM minimum3184.8MiB, scope peak9GiB/max1155/oom0, disk minimum12.206GiB. All274 native guard queries completed (max582.65ms); independent observer max244.51ms. No kernel entries or observed title exception. The supervisor now uses a pre-launch journal cursor;256 kernel queries completed, max0.863s, with its original3s deadline. The preceding080855 observation stopped on that journal monitor deadline, not a GPU query failure; it is not counted as a full run. Performance remains far below target:69 disjoint late host-present-attempt windows/302 intervals,298over50ms,250over100ms, max3200.8ms. These are not scanout or global percentile/FPS measurements. Final pool census28×64MiB blocks,1463MiB held,322MiB free,6MiB resting,0empty; other GPU owners remain. No sustained safety, frame-time gain or15-minute gameplay claim. All stopped backing files were removed only after exact inode/scope/no-holder checks. Evidence: nvidia-fork-trial-20261129T081925Z/{verified-summary,late-present-attempts,vram-admission-evidence,backing-cleanup}.json. Captures remain local/unpublished. The next action is offscreen small-card address-arena/shared-memory coherence verification, not a higher guard or an eight-worker run. **Later hardware safety hold:** a subsequent changed registered-copy-budget experiment hit an Intel i915/Xwayland GPU hang/reset. All GPU/title work is parked; no attribution to segmented uploads or that quota is established. Details: https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1226#issuecomment-7254875954 . Earlier offscreen and scoped observations above remain their exact, limited results.
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/1391:upstream-pr/1391'
git switch 'upstream-pr/1391'

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/1391'
git switch 'upstream-pr/1391'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1391'
git switch 'upstream-pr/1391'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1391'
git switch 'main'
git merge --squash 'upstream-pr/1391'
git switch 'main'
git merge --ff-only 'upstream-pr/1391'
git switch 'main'
git merge 'upstream-pr/1391'
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
trustno1-coder/VIctory-NVIDIA!1391
No description provided.