GPU: reuse retired upload buffers for oversized submissions #1390

Closed
AkshatPal2007 wants to merge 1 commit from upstream-pr/1390 into main
AkshatPal2007 commented 2026-11-28 18:43:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by AkshatPal2007 on 2026-11-28T18:43:50Z.


Addresses #1383. The segmented staging patch and the original gameplay measurements come from @NotADonky43. This PR adapts the posted patch and adds the requested byte-exact GPU readback, failure recovery coverage, and a reproducible device-local memory measurement.

Uploads now request their exact size when rounding up would exceed the pool retention limit. With VICTORY_STAGE_SEGMENTS=1, oversized submissions reuse retired buffers for complete destination groups and allocate only the remainder. All source buffers stay alive until the submission retires. Segmented reuse is opt-in pending longer gameplay testing.

Device-local memory measurement

RTX 4070 Laptop GPU, Windows, VICTORY_SEND_BAR=1. Each run started with 26 MiB and 38 MiB retired buffers and requested the same four destination groups totaling 105 MiB. DXGI local usage was sampled before creating the retired buffers and again with the submission buffers alive.

Measurement Single buffer Segmented
New upload allocation 105 MiB 41 MiB
Increase in process-local VRAM, first pair 169 MiB 105 MiB
Increase in process-local VRAM, reverse-order pair 169 MiB 105 MiB

The default upload path uses host memory. The table specifically measures device-local upload heaps. Gameplay FPS and long-session behavior remain unmeasured here.

Verification

Four destinations received distinct bulk copies and scatter writes. The readback checked every byte, including untouched sentinel regions, as the scatter source switched between retired blocks and the new remainder. Tests also cover rollback after a failed allocation and size rounding at the retention limit. All four focused checks passed. The default host-memory path passed its three applicable checks separately.

To reproduce on a GPU supporting device-local upload heaps, run in PowerShell:

$env:VICTORY_SEND_BAR = '1'
cargo test --locked -p victory-gpu --lib host::send::tests -- --include-ignored --test-threads=1 --nocapture

Strict Clippy reports a pre-existing manual_is_multiple_of lint in shadow.rs at line 1708 on the base revision.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5543439165 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1390). Originally posted by [AkshatPal2007](https://github.com/AkshatPal2007) on 2026-11-28T18:43:50Z. --- Addresses #1383. The segmented staging patch and the original gameplay measurements come from @NotADonky43. This PR adapts the [posted patch](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1383#issuecomment-7243899837) and adds the requested byte-exact GPU readback, failure recovery coverage, and a reproducible device-local memory measurement. Uploads now request their exact size when rounding up would exceed the pool retention limit. With `VICTORY_STAGE_SEGMENTS=1`, oversized submissions reuse retired buffers for complete destination groups and allocate only the remainder. All source buffers stay alive until the submission retires. Segmented reuse is opt-in pending longer gameplay testing. ### Device-local memory measurement RTX 4070 Laptop GPU, Windows, `VICTORY_SEND_BAR=1`. Each run started with 26 MiB and 38 MiB retired buffers and requested the same four destination groups totaling 105 MiB. DXGI local usage was sampled before creating the retired buffers and again with the submission buffers alive. | Measurement | Single buffer | Segmented | | --- | ---: | ---: | | New upload allocation | 105 MiB | 41 MiB | | Increase in process-local VRAM, first pair | 169 MiB | 105 MiB | | Increase in process-local VRAM, reverse-order pair | 169 MiB | 105 MiB | The default upload path uses host memory. The table specifically measures device-local upload heaps. Gameplay FPS and long-session behavior remain unmeasured here. ### Verification Four destinations received distinct bulk copies and scatter writes. The readback checked every byte, including untouched sentinel regions, as the scatter source switched between retired blocks and the new remainder. Tests also cover rollback after a failed allocation and size rounding at the retention limit. All four focused checks passed. The default host-memory path passed its three applicable checks separately. To reproduce on a GPU supporting device-local upload heaps, run in PowerShell: ```powershell $env:VICTORY_SEND_BAR = '1' cargo test --locked -p victory-gpu --lib host::send::tests -- --include-ignored --test-threads=1 --nocapture ``` Strict Clippy reports a pre-existing `manual_is_multiple_of` lint in `shadow.rs` at line 1708 on the base revision.

Pull request closed

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!1390
No description provided.