Take texture upload memory from the list's scratch pool #30

Manually merged
github merged 1 commit from gh-pr/30/head into gh-pr/30/base 2026-11-26 03:33:51 +00:00
Owner

@⁠romainhedouin on GitHub · 2026-11-25 12:32 UTC · original
romainhedouin:perf/upload-pool → main · +30 −20 · 2 files · 1 commits · merged 2026-11-25 17:09 UTC

Each title copy from a buffer into a texture created a brand new D3D12 upload buffer, mapped it, and destroyed it at list reset (the code marked this as a shortcut to pool later). Now the bytes go into the list's scratch memory: pooled 512 KiB chunks that stay mapped and are reused once the GPU is done with them, at a 512-byte offset as D3D12 requires for texture copies. Copies over 512 KiB still get their own buffer, as before.

Per buffer-to-texture copy (up to 512 KiB) Before After
CreateCommittedResource 1 0 (steady state)
Map 1 0
Buffer destroyed at list reset 1 0

Counts from the code, not timings. Type-checked for Windows (cargo clippy --target x86_64-pc-windows-msvc, with and without --all-features, no new warnings); not run.

🤖 Generated with Claude Code

**@⁠romainhedouin** on GitHub · 2026-11-25 12:32 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/30) `romainhedouin:perf/upload-pool` → `main` · +30 −20 · 2 files · 1 commits · merged 2026-11-25 17:09 UTC Each title copy from a buffer into a texture created a brand new D3D12 upload buffer, mapped it, and destroyed it at list reset (the code marked this as a shortcut to pool later). Now the bytes go into the list's scratch memory: pooled 512 KiB chunks that stay mapped and are reused once the GPU is done with them, at a 512-byte offset as D3D12 requires for texture copies. Copies over 512 KiB still get their own buffer, as before. | Per buffer-to-texture copy (up to 512 KiB) | Before | After | |---|---|---| | `CreateCommittedResource` | 1 | 0 (steady state) | | `Map` | 1 | 0 | | Buffer destroyed at list reset | 1 | 0 | Counts from the code, not timings. Type-checked for Windows (`cargo clippy --target x86_64-pc-windows-msvc`, with and without `--all-features`, no new warnings); not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:33:50 +00:00
github manually merged commit 5e08eee09f into gh-pr/30/base 2026-11-26 03:33:51 +00:00
@ -2415,2 +2422,2 @@
s.used += len;
Some((gpu + at, (data + at as usize) as *mut u8))
let (buffer, data, gpu) = &s.chunks[s.current];
let at = s.used.next_multiple_of(align);
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 15:13 UTC · original

Could we add a Windows regression test that first allocates a 256-byte scratch span, then requests an upload span with 512-byte alignment and checks that the returned GPU offset is 512-byte aligned? This is the contract that makes the new pooled upload safe for placed footprints, and the mixed-alignment rollover path is currently untested. AI-assisted review.

**@⁠gut0to** on GitHub · 2026-11-25 15:13 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/30#discussion_r4696953139) Could we add a Windows regression test that first allocates a 256-byte scratch span, then requests an upload span with 512-byte alignment and checks that the returned GPU offset is 512-byte aligned? This is the contract that makes the new pooled upload safe for placed footprints, and the mixed-alignment rollover path is currently untested. AI-assisted review.
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 15:13 UTC · original · reviewed

AI-assisted review: I traced the scratch allocation alignment contract and the current test coverage.

**@⁠gut0to** on GitHub · 2026-11-25 15:13 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/30#pullrequestreview-6060252887) · **reviewed** AI-assisted review: I traced the scratch allocation alignment contract and the current test coverage.
This discussion has been locked. Commenting is limited to contributors.
No description provided.