GPU: grow per-list upload scratch on demand #1246

Merged
LaunchDoesntCode merged 1 commit from upstream-pr/1246 into main 2026-11-25 00:17:31 +00:00
LaunchDoesntCode commented 2026-11-24 16:46:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LaunchDoesntCode on 2026-11-24T16:46:17Z.


The first scratch allocation on each host command list currently reserves 4 MiB, even for a 256-byte request. This starts per-list chunks at 64 KiB, grows them to fit up to 4 MiB, and reuses them after a fenced reset. Larger requests still get a dedicated upload. The optional victory_gpu::scratch=debug trace reports each new chunk's requested and allocated sizes.

On an integrated Windows WARP playtest build, 158 distinct command lists allocated 261 scratch chunks totaling 30.4 MiB during loading. At the old fixed size, the first chunk of each of those lists alone would account for 632 MiB. These figures describe cumulative chunk allocations. They do not measure peak process memory or frame time.

The regression test uses a D3D12 list to check 256-byte alignment, small and large requests, overflow, and reuse of the same upload addresses after submission and reset. On this branch based on ffe310e, the Windows diagnostics GPU suite passed 54 tests with one ignored. Workspace Clippy with all targets and features, the default workspace check with all targets, and the asset-policy check also passed.

Related to #982, which pools transient uploads across lists. This change sizes the scratch chunks retained by each list.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586844327 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1246). Originally posted by [LaunchDoesntCode](https://github.com/LaunchDoesntCode) on 2026-11-24T16:46:17Z. --- The first scratch allocation on each host command list currently reserves 4 MiB, even for a 256-byte request. This starts per-list chunks at 64 KiB, grows them to fit up to 4 MiB, and reuses them after a fenced reset. Larger requests still get a dedicated upload. The optional `victory_gpu::scratch=debug` trace reports each new chunk's requested and allocated sizes. On an integrated Windows WARP playtest build, 158 distinct command lists allocated 261 scratch chunks totaling **30.4 MiB** during loading. At the old fixed size, the first chunk of each of those lists alone would account for **632 MiB**. These figures describe cumulative chunk allocations. They do not measure peak process memory or frame time. The regression test uses a D3D12 list to check 256-byte alignment, small and large requests, overflow, and reuse of the same upload addresses after submission and reset. On this branch based on `ffe310e`, the Windows diagnostics GPU suite passed 54 tests with one ignored. Workspace Clippy with all targets and features, the default workspace check with all targets, and the asset-policy check also passed. Related to #982, which pools transient uploads across lists. This change sizes the scratch chunks retained by each list.
DenRakEiw commented 2026-11-24 17:04:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T16:56:50Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):

  • cargo test -p victory-gpu (RTX 5090): 51 passed, 0 failed, 1 ignored
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu (WARP): 51 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean on-demand growth for per-list upload scratch buffers, verified on Blackwell hardware and WARP. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6043697901 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1246#pullrequestreview-6043697901). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T16:56:50Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP** (`VICTORY_D3D12_WARP=1`): - `cargo test -p victory-gpu` (RTX 5090): **51 passed, 0 failed, 1 ignored** - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu` (WARP): **51 passed, 0 failed, 1 ignored** - `cargo clippy -p victory-gpu --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean on-demand growth for per-list upload scratch buffers, verified on Blackwell hardware and WARP. Approving. AI-assisted (Gemini 4 Neon).
mercuryVM commented 2026-11-24 18:04:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T17:40:09Z.

Review: APPROVED


Tested 59035de9 on Windows 11, RTX 5070, MSVC:

  • cargo test -p victory-gpu passes on the head (51 passed, 1 ignored), including the new scratch test.
  • Merged into our fork: workspace tests, shader tests and clippy -D warnings (default and all features) are all clean.

The change is right:

  • len <= SCRATCH_CHUNK holds on the chunk path, so a new chunk is always big enough: at least len rounded up to 64 KiB, at most 4 MiB.
  • The while let walks past reused chunks that are too small, and chunk.capacity - s.used can't underflow, because used never passes the capacity.
  • checked_next_multiple_of turns a u64::MAX request into None, where it used to overflow.

One trade-off worth a comment: after a reset, a request bigger than the current chunk skips that chunk for the rest of the list, even if later small requests would have fit in it. That's fine for a scratch arena.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6044353362 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1246#pullrequestreview-6044353362). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T17:40:09Z. **Review:** APPROVED --- Tested 59035de9 on Windows 11, RTX 5070, MSVC: - `cargo test -p victory-gpu` passes on the head (51 passed, 1 ignored), including the new scratch test. - Merged into our fork: workspace tests, shader tests and `clippy -D warnings` (default and all features) are all clean. The change is right: - `len <= SCRATCH_CHUNK` holds on the chunk path, so a new chunk is always big enough: at least `len` rounded up to 64 KiB, at most 4 MiB. - The `while let` walks past reused chunks that are too small, and `chunk.capacity - s.used` can't underflow, because `used` never passes the capacity. - `checked_next_multiple_of` turns a `u64::MAX` request into `None`, where it used to overflow. One trade-off worth a comment: after a reset, a request bigger than the current chunk skips that chunk for the rest of the list, even if later small requests would have fit in it. That's fine for a scratch arena. AI-assisted (Claude Code).
Zipettte commented 2026-11-24 18:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T17:59:28Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 59035de: cargo test -p victory-gpu passes, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139997504 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1246#issuecomment-7139997504). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T17:59:28Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 59035de: `cargo test -p victory-gpu` passes, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
fladit123 commented 2026-11-24 18:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fladit123 on 2026-11-24T18:02:10Z.


Independent focused validation of 59035de94c4a7c42361994ea861641a7ac78c2e9 on NVIDIA Ada Lovelace.

Environment

  • RTX 4060 8 GB, driver 610.88
  • Intel Core i5-12400F, 32 GB RAM
  • Windows 11, Rust 1.98.1 MSVC

The regression test list_scratch_grows_to_fit_and_reuses_fenced_chunks passed on both the physical RTX 4060 and WARP. Separate instrumentation confirmed that the test reached both GPU submissions rather than returning early.

The existing alignment, allocation growth and fenced reuse assertions passed.

Limitations: The build used a zero-byte BCPack placeholder with the original table excluded. This is focused validation, not a clean full-workspace result. Peak memory reduction and scratch payload integrity were not independently measured.

No game data or proprietary console SDK material was used.

AI use: OpenAI Codex assisted with test execution and instrumentation; ChatGPT (GPT-6.2) assisted with reporting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140063016 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1246#issuecomment-7140063016). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-24T18:02:10Z. --- Independent focused validation of `59035de94c4a7c42361994ea861641a7ac78c2e9` on NVIDIA Ada Lovelace. **Environment** - RTX 4060 8 GB, driver 610.88 - Intel Core i5-12400F, 32 GB RAM - Windows 11, Rust 1.98.1 MSVC The regression test `list_scratch_grows_to_fit_and_reuses_fenced_chunks` passed on both the physical RTX 4060 and WARP. Separate instrumentation confirmed that the test reached both GPU submissions rather than returning early. The existing alignment, allocation growth and fenced reuse assertions passed. **Limitations:** The build used a zero-byte BCPack placeholder with the original table excluded. This is focused validation, not a clean full-workspace result. Peak memory reduction and scratch payload integrity were not independently measured. No game data or proprietary console SDK material was used. **AI use:** OpenAI Codex assisted with test execution and instrumentation; ChatGPT (GPT-6.2) assisted with reporting.
upstream-sync closed this pull request 2026-11-25 01:06:01 +00:00
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
Marvisak/VIctory!1246
No description provided.