victory-gpu: small device-local buffers placed together #110

Manually merged
github merged 1 commit from github-bot/gh-110 into main 2026-12-02 01:45:47 +00:00 AGit
Owner

@⁠Bushyon on GitHub · 2026-12-01 20:38 UTC · original
Bushyon:small-buffers-placed-together → main · +290 −3 · 3 files · 1 commits · merged 2026-12-02 01:43 UTC

What was wrong

Every buffer Host::uav_buffer makes is a committed resource, and the AMD driver gives each one in local video memory 256 KiB of the card, however small it is. Indirect batch buffers (64 KiB), indirect budgets (256 bytes) and indirect arguments buffers are made by the thousands.

What this changes

New card_pool.rs: buffers of 256 KiB or less are placed in shared 4 MiB ALLOW_ONLY_BUFFERS heaps at 64 KiB multiples. take_batch_buffer, make_card_budget and the indirect arguments buffer ask the pool first and fall back to uav_buffer. A slot is reused only once the pool's own reference is the last one (host::references). VICTORY_CARD_POOL=0 turns it off.

Measured

run.sh play, VICTORY_BVH_BUILDER=1, 330 s, pool off vs on: no panics or device removal, average FPS 28.7 vs 30.0 (noise). With the pool on: 2,986 small buffers in 81 heaps (324 MB, 98% used), against about 750 MB if committed at 256 KiB each (arithmetic, not an RMV trace).

Not checked

  • The pool's unit tests did not run (the test exe under wine printed nothing here).
  • I did not verify that every owner holds a real reference for as long as the GPU may read a buffer, notably the batch buffers recycled through SPARE_BATCH.

AI-assisted.

**@⁠Bushyon** on GitHub · 2026-12-01 20:38 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/110) `Bushyon:small-buffers-placed-together` → `main` · +290 −3 · 3 files · 1 commits · merged 2026-12-02 01:43 UTC ## What was wrong Every buffer `Host::uav_buffer` makes is a committed resource, and the AMD driver gives each one in local video memory 256 KiB of the card, however small it is. Indirect batch buffers (64 KiB), indirect budgets (256 bytes) and indirect arguments buffers are made by the thousands. ## What this changes New `card_pool.rs`: buffers of 256 KiB or less are placed in shared 4 MiB `ALLOW_ONLY_BUFFERS` heaps at 64 KiB multiples. `take_batch_buffer`, `make_card_budget` and the indirect arguments buffer ask the pool first and fall back to `uav_buffer`. A slot is reused only once the pool's own reference is the last one (`host::references`). `VICTORY_CARD_POOL=0` turns it off. ## Measured `run.sh play`, `VICTORY_BVH_BUILDER=1`, 330 s, pool off vs on: no panics or device removal, average FPS 28.7 vs 30.0 (noise). With the pool on: 2,986 small buffers in 81 heaps (324 MB, 98% used), against about 750 MB if committed at 256 KiB each (arithmetic, not an RMV trace). ## Not checked - The pool's unit tests did not run (the test exe under wine printed nothing here). - I did not verify that every owner holds a real reference for as long as the GPU may read a buffer, notably the batch buffers recycled through `SPARE_BATCH`. AI-assisted.
Every buffer Host::uav_buffer makes is a committed resource, and the AMD
driver gives each one in local video memory 256 KiB of the card however
small it is. Buffers of 256 KiB or less (indirect batches, indirect
budgets, indirect arguments) are now placed in shared 4 MiB
ALLOW_ONLY_BUFFERS heaps at 64 KiB multiples (card_pool.rs), falling back
to uav_buffer if the pool can't place one.

A slot is reused only once the pool's own reference is the last one
(host::references). VICTORY_CARD_POOL=0 turns it off.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:42:29 +00:00
Author
Owner

@⁠Frtuchinno on GitHub · 2026-12-01 20:52 UTC · original

Ran the pool's unit tests you couldn't run, on an RX 7800 XT (RDNA3), CachyOS, proton-cachyos-slr, this PR merged on 37bb30f:

test card_pool::tests::a_slot_is_taken_again_only_when_nothing_holds_its_buffer ... ok
test card_pool::tests::masks_cover_the_slots_asked ... ok
test card_pool::tests::room_finds_runs_of_free_slots ... ok
test result: ok. 3 passed; 0 failed

This only covers the unit tests, not the open point about owners holding a real reference while the GPU may still read a batch buffer.

Why the test exe printed nothing: it imports d3d12.dll, and without the DLL overrides run.sh sets, Wine/Proton loads its builtin d3d12 → wined3d, which isn't there, so the process exits during import (status c0000135, exit code 53) before the harness prints anything. With the same overrides as run.sh it runs:

export WINEDLLOVERRIDES='d3d12,d3d12core,dxgi=n;d3dcompiler_47=n,b'
PKG=victory-gpu ./build.sh test --lib --no-run       # build only
source env.sh
"$WINE_BIN" target/x86_64-pc-windows-msvc/release/deps/victory_gpu-*.exe <filter>

(Running the whole victory-gpu suite in one go still dies part-way with exit status 5 on unmodified main here, so a filter is the way to check one module. build.sh appends its own flags after its arguments, so a test filter can't go through it; hence running the exe directly.)

**@⁠Frtuchinno** on GitHub · 2026-12-01 20:52 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/110#issuecomment-7325398484) Ran the pool's unit tests you couldn't run, on an RX 7800 XT (RDNA3), CachyOS, `proton-cachyos-slr`, this PR merged on `37bb30f`: ``` test card_pool::tests::a_slot_is_taken_again_only_when_nothing_holds_its_buffer ... ok test card_pool::tests::masks_cover_the_slots_asked ... ok test card_pool::tests::room_finds_runs_of_free_slots ... ok test result: ok. 3 passed; 0 failed ``` This only covers the unit tests, not the open point about owners holding a real reference while the GPU may still read a batch buffer. **Why the test exe printed nothing:** it imports `d3d12.dll`, and without the DLL overrides `run.sh` sets, Wine/Proton loads its builtin `d3d12` → `wined3d`, which isn't there, so the process exits during import (status `c0000135`, exit code 53) before the harness prints anything. With the same overrides as `run.sh` it runs: ```sh export WINEDLLOVERRIDES='d3d12,d3d12core,dxgi=n;d3dcompiler_47=n,b' PKG=victory-gpu ./build.sh test --lib --no-run # build only source env.sh "$WINE_BIN" target/x86_64-pc-windows-msvc/release/deps/victory_gpu-*.exe <filter> ``` (Running the whole `victory-gpu` suite in one go still dies part-way with exit status 5 on unmodified `main` here, so a filter is the way to check one module. `build.sh` appends its own flags after its arguments, so a test filter can't go through it; hence running the exe directly.)
github-bot referenced this pull request from a commit 2026-12-02 01:45:44 +00:00
github manually merged commit cc23f4ea48 into main 2026-12-02 01:45:47 +00:00
github-bot referenced this pull request from a commit 2026-12-04 19:05:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.