Series S on a 16 GB shared-memory APU (AMD BC-250): memory measurements and two fixes #451

Open
opened 2026-12-04 10:10:05 +00:00 by github-bot · 3 comments
Owner

@⁠GoldenTXS on GitHub · 2026-12-04 10:08 UTC · original

Summary

On a BC-250 (16 GB shared by the CPU and the GPU), the game reaches the world load. There, the card driver's memory climbs past what the machine has, and VICTORY_GPU_GUARD stops the run. This happens about 40–50 s after start, every time.

I measured where the memory goes, using kernel BO lists and VIctory's own counters.

I found two things worth fixing upstream:

  1. Since 8aec563, every bound title page is shown to the card, so the driver creates all of them. Hiding the untouched ones again cuts memory at the first frame from 6.8 GB to 4.3 GB.
  2. A DirectStorage read into a pool window page that does not exist yet fails with ERROR_NOACCESS.

Even with those fixes, the world load still needs more memory than a 16 GB shared machine has. The measurements below may help decide what to cut next.

Setup

  • Board: AMD BC-250 (Cyan Skillfish, GFX1013, 40 CU), 16 GB GDDR6 shared. Linux sees 15201 MiB. The card's own memory is 512 MiB. amdgpu.gttsize gives 14336 MiB of GTT.
  • System: CachyOS, kernel 7.3.7 (BC-250 build), XFCE.
  • Proton: proton-cachyos-native-bc250.
  • Mesa: 26.2.1 with DirectMesh v1.4 (mesh shaders and a compute queue on GFX1013), plus patches/mesa.patch ported to it.
  • VIctory: 0b652f8.
  • Game: Xbox build 930.048.020.
  • Settings:
    CONSOLE=series-s
    VICTORY_PRESET=low
    VICTORY_BVH_BUILDER=0
    VICTORY_GPU_GUARD=1
    KEEP_FREE=2048
    
  • warm was done: 102,666 pipelines, and 7 were missed in play.

What the memory does

Over one run (memory: card driver lines, plus mem_info_gtt_used):

Moment Card driver memory RAM available
Swap chain 4.3 GB with the fixes below (6.8 GB without)
Then, stable for 20–30 s 7–8 GB
World load: rises about 1 GB every 2–3 s until the guard stops it at 85 % (12.2 GB) 300–500 MiB
With the guard at 90 % and MemorySwapMax raised to 6G 12.9 GB 125 MiB (2.2 GB of swap used)

In the last run, the rise slows down but does not level off before RAM is used up.

Breakdown of the game process (amdgpu_gem_info, summed by BO size), during the final 20 s:

BO size Count Total What it is
64 KiB 38.7k → 77k 2.4 → 4.8 GB Pages of the title's lazy pools
64 MiB 10 → 39 +1.9 GB 14 texture blocks (896 MB), 3 staging blocks (192 MB), the by-address arenas (held twice), indirect and records blocks
Large exported BOs about 1.9 GB The memory the title committed whole (1162, 258, 194 MB…)

Pool window pages made while the world loads (a counter I added to the window fault handler):

How the page was first touched Pages
A read (the page could only hold zeros) 702
A write 6,300
DirectStorage asks before a file read 48,945 (about 3 GB)

So almost all of the rise is real streamed data. It is not reads of empty pages.

VIctory's own accounting: 2.1–2.2 GB on the card, out of a 3040 MB budget. Host copies of the textures the title fills: about 12k copies, 1.2 GB.

Fix 1: hide unseen bound pages from the card again

Commit 8aec563 dropped HIDDEN from lazy::bind, for hardware BVH64. Since then, every bound page alias is shown to the card (alias->card = true), and the driver creates every bound page. With lazy pool pages, that is about 88k pages (5.5 GB) bound at the first frame. Only about 7.9k of them are ever read by the card.

What the patch does:

  • In bind, a page the CPU has not touched and the card has not seen is bound HIDDEN, as before 8aec563.
  • This is only on when the card does not test BVH nodes itself (!host_bvh()). VICTORY_LAZY_HIDDEN=0 or 1 forces it either way.
  • A page the CPU touches gets its normal mapping in make(), which is unchanged.

Result: 4.3 GB of card driver memory at the swap chain, instead of 6.8 GB.

Fix 2: DirectStorage reads into lazy pool windows

dstorage::into_bound lets the kernel write the file straight into the pool window. With lazy pool pages, a window page that does not exist yet is PROT_NONE. The kernel's write does not fault into window_fault. It fails instead with ERROR_NOACCESS (998). The title then gives up (0x80000003).

This also happens with Fix 1: a hidden alias is not CPU-mapped by RADV either.

What the patch does:

  • A new lazy::window_made(window, len) makes the window's pages before the read.
  • If they cannot be made, the read falls back to the buffer path.

Other changes I tried

  • Lazy pool pages in RADV (RADV_UM_LAZY_POOLS=1): the 64 KiB page BOs of pools of 64 MiB or more are created on their first CPU alias, or on their first GPU VA map. An earlier version also created them when a hidden alias was registered, which made about 9 GB of pages. Pages that are never mapped are now never created.
  • Series S TileHeap: VICTORY_TILE_HEAP_MB below 3977 also patches the Series S size. In this build it is at title+0x24796d5, 0x19 after the Series X site. Setting 3072 or 2048 made no difference to the peak.
  • A lean mode for shared-memory hosts: the card budget is 30 % of RAM, less memory is kept for reuse, idle caches go after 10 s, and the BVH pages are capped at 2 GiB. It lowers the start, not the world-load peak.
  • VICTORY_BVH_PAGES_MB=512 or 128: no visible change to the peak.

Notes that may save others time

  • VICTORY_BVH_IN_PLACE changes host_bvh() (the card's node test). That value is part of the shader translation key. So changing VICTORY_BVH_IN_PLACE re-translates about 25.8k shaders and rebuilds about 104k pipelines: roughly 1 hour on this board. Also, run.sh exports VICTORY_BVH_IN_PLACE=1 even when VICTORY_BVH_BUILDER=0.
  • MemorySwapMax=2G is hard-coded in run.sh. A setting for it would help on hosts with a large swap.
  • run.sh shaders, warm or play started from a text console with no display waits forever: Proton's prefix update and the window need one.

Questions

  1. On a shared-memory host, could the host copies of title textures be avoided?
    • This would mean sampling the console-tiled memory in place.
    • The two chips are of the same family, but the 64 KB swizzle address bits depend on each chip's pipe and bank configuration.
    • It would save about 2 GB here (host copies, texture blocks and staging), but likely not enough on its own.
  2. Are the by-address arenas (held for both the CPU and the card) needed when ray tracing is off?
  3. Does the world load ever level off on Series S? Has anyone seen a number for its peak on a 16 GB Steam Deck?

The patches are attached:

  • victory-lazy-hidden.patch: Fix 1, Fix 2, and the window-page counters.
  • The RADV lazy-pool change.
  • The Series S TileHeap and lean-mode patch.

mesa-radv-lazy-pools-only.patch
victory-lazy-hidden.patch
victory-lazy-pools.patch
victory-optim-latest.patch

**@⁠GoldenTXS** on GitHub · 2026-12-04 10:08 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/451) ## Summary On a BC-250 (16 GB shared by the CPU and the GPU), the game reaches the world load. There, the card driver's memory climbs past what the machine has, and `VICTORY_GPU_GUARD` stops the run. This happens about 40–50 s after start, every time. I measured where the memory goes, using kernel BO lists and VIctory's own counters. I found two things worth fixing upstream: 1. Since 8aec563, every bound title page is shown to the card, so the driver creates all of them. Hiding the untouched ones again cuts memory at the first frame from 6.8 GB to 4.3 GB. 2. A DirectStorage read into a pool window page that does not exist yet fails with `ERROR_NOACCESS`. Even with those fixes, the world load still needs more memory than a 16 GB shared machine has. The measurements below may help decide what to cut next. ## Setup - **Board**: AMD BC-250 (Cyan Skillfish, GFX1013, 40 CU), 16 GB GDDR6 shared. Linux sees 15201 MiB. The card's own memory is 512 MiB. `amdgpu.gttsize` gives 14336 MiB of GTT. - **System**: CachyOS, kernel 7.3.7 (BC-250 build), XFCE. - **Proton**: `proton-cachyos-native-bc250`. - **Mesa**: 26.2.1 with DirectMesh v1.4 (mesh shaders and a compute queue on GFX1013), plus `patches/mesa.patch` ported to it. - **VIctory**: 0b652f8. - **Game**: Xbox build 930.048.020. - **Settings**: ``` CONSOLE=series-s VICTORY_PRESET=low VICTORY_BVH_BUILDER=0 VICTORY_GPU_GUARD=1 KEEP_FREE=2048 ``` - `warm` was done: 102,666 pipelines, and 7 were missed in play. ## What the memory does **Over one run** (`memory: card driver` lines, plus `mem_info_gtt_used`): | Moment | Card driver memory | RAM available | |---|---|---| | Swap chain | 4.3 GB with the fixes below (6.8 GB without) | | | Then, stable for 20–30 s | 7–8 GB | | | World load: rises about 1 GB every 2–3 s | until the guard stops it at 85 % (12.2 GB) | 300–500 MiB | | With the guard at 90 % and `MemorySwapMax` raised to 6G | 12.9 GB | 125 MiB (2.2 GB of swap used) | In the last run, the rise slows down but does not level off before RAM is used up. **Breakdown of the game process** (`amdgpu_gem_info`, summed by BO size), during the final 20 s: | BO size | Count | Total | What it is | |---|---|---|---| | 64 KiB | 38.7k → 77k | 2.4 → 4.8 GB | Pages of the title's lazy pools | | 64 MiB | 10 → 39 | +1.9 GB | 14 texture blocks (896 MB), 3 staging blocks (192 MB), the by-address arenas (held twice), indirect and records blocks | | Large exported BOs | | about 1.9 GB | The memory the title committed whole (1162, 258, 194 MB…) | **Pool window pages** made while the world loads (a counter I added to the window fault handler): | How the page was first touched | Pages | |---|---| | A read (the page could only hold zeros) | 702 | | A write | 6,300 | | DirectStorage asks before a file read | 48,945 (about 3 GB) | So almost all of the rise is real streamed data. It is not reads of empty pages. **VIctory's own accounting**: 2.1–2.2 GB on the card, out of a 3040 MB budget. Host copies of the textures the title fills: about 12k copies, 1.2 GB. ## Fix 1: hide unseen bound pages from the card again Commit 8aec563 dropped `HIDDEN` from `lazy::bind`, for hardware BVH64. Since then, every bound page alias is shown to the card (`alias->card = true`), and the driver creates every bound page. With lazy pool pages, that is about 88k pages (5.5 GB) bound at the first frame. Only about 7.9k of them are ever read by the card. What the patch does: - In `bind`, a page the CPU has not touched and the card has not seen is bound `HIDDEN`, as before 8aec563. - This is only on when the card does not test BVH nodes itself (`!host_bvh()`). `VICTORY_LAZY_HIDDEN=0` or `1` forces it either way. - A page the CPU touches gets its normal mapping in `make()`, which is unchanged. Result: 4.3 GB of card driver memory at the swap chain, instead of 6.8 GB. ## Fix 2: DirectStorage reads into lazy pool windows `dstorage::into_bound` lets the kernel write the file straight into the pool window. With lazy pool pages, a window page that does not exist yet is `PROT_NONE`. The kernel's write does not fault into `window_fault`. It fails instead with `ERROR_NOACCESS` (998). The title then gives up (`0x80000003`). This also happens with Fix 1: a hidden alias is not CPU-mapped by RADV either. What the patch does: - A new `lazy::window_made(window, len)` makes the window's pages before the read. - If they cannot be made, the read falls back to the buffer path. ## Other changes I tried - **Lazy pool pages in RADV** (`RADV_UM_LAZY_POOLS=1`): the 64 KiB page BOs of pools of 64 MiB or more are created on their first CPU alias, or on their first GPU VA map. An earlier version also created them when a hidden alias was registered, which made about 9 GB of pages. Pages that are never mapped are now never created. - **Series S TileHeap**: `VICTORY_TILE_HEAP_MB` below 3977 also patches the Series S size. In this build it is at title+0x24796d5, 0x19 after the Series X site. Setting 3072 or 2048 made no difference to the peak. - **A lean mode for shared-memory hosts**: the card budget is 30 % of RAM, less memory is kept for reuse, idle caches go after 10 s, and the BVH pages are capped at 2 GiB. It lowers the start, not the world-load peak. - **`VICTORY_BVH_PAGES_MB=512` or `128`**: no visible change to the peak. ## Notes that may save others time - `VICTORY_BVH_IN_PLACE` changes `host_bvh()` (the card's node test). That value is part of the shader translation key. So changing `VICTORY_BVH_IN_PLACE` re-translates about 25.8k shaders and rebuilds about 104k pipelines: roughly 1 hour on this board. Also, `run.sh` exports `VICTORY_BVH_IN_PLACE=1` even when `VICTORY_BVH_BUILDER=0`. - `MemorySwapMax=2G` is hard-coded in `run.sh`. A setting for it would help on hosts with a large swap. - `run.sh shaders`, `warm` or `play` started from a text console with no display waits forever: Proton's prefix update and the window need one. ## Questions 1. On a shared-memory host, could the host copies of title textures be avoided? - This would mean sampling the console-tiled memory in place. - The two chips are of the same family, but the 64 KB swizzle address bits depend on each chip's pipe and bank configuration. - It would save about 2 GB here (host copies, texture blocks and staging), but likely not enough on its own. 2. Are the by-address arenas (held for both the CPU and the card) needed when ray tracing is off? 3. Does the world load ever level off on Series S? Has anyone seen a number for its peak on a 16 GB Steam Deck? The patches are attached: - `victory-lazy-hidden.patch`: Fix 1, Fix 2, and the window-page counters. - The RADV lazy-pool change. - The Series S TileHeap and lean-mode patch. [mesa-radv-lazy-pools-only.patch](https://github.com/user-attachments/files/35863970/mesa-radv-lazy-pools-only.patch) [victory-lazy-hidden.patch](https://github.com/user-attachments/files/35863968/victory-lazy-hidden.patch) [victory-lazy-pools.patch](https://github.com/user-attachments/files/35863969/victory-lazy-pools.patch) [victory-optim-latest.patch](https://github.com/user-attachments/files/35863971/victory-optim-latest.patch)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 10:10:05 +00:00
Author
Owner

@⁠GoldenTXS on GitHub · 2026-12-04 10:40 UTC · original

Follow-up with per-second numbers (amdgpu_gem_info every 1 s, same setup as above).

The title levels off; VIctory's blocks do not.

Time in the world load 64 KiB title pages 64 MiB blocks (VIctory)
start 2.4 GB (38.7k) 10 (640 MB)
+9 s 4.6 GB (73k) 30 (1.9 GB)
+20 s 4.8 GB (77k), flat from here 50 (3.2 GB)
  • The texture pool goes from 10 to 30–35 blocks in about 6 s, then stays there. 8–11 of those blocks are "being emptied" for the whole run, and none is ever given back ("0 given back to the card since the start"). VICTORY_POOL_MOVE=1 moved 1,810 textures (276 MB) but still gave back 0 blocks within the load.
  • VIctory's card accounting keeps rising after the texture pool is flat: 2,877 → 4,110 MB in 12 s, while host copies of textures only go from 1,315 to 1,429 MB.
  • The by-address arenas are not the cause here: 1 arena, 72 MB.

Things that made no difference to the peak: VICTORY_PRESET=potato with VICTORY_WORLD_DIST_SCALE=0.15 (patches confirmed in the log), VICTORY_LEAN_VRAM_PERCENT=10 (budget 2,048 MB, 3,259 MB used anyway).

With the guard at 95 % and MemorySwapMax=12G: stopped at 13.6 GB of GTT, 137 MiB of RAM free, 2.8 GB in swap, still rising. So the world load wants about 18 GB here.

Questions:

  1. Is there a reason emptied texture blocks cannot be returned during a load (issue #21 in the resource.rs comment)?
  2. What else in VIctory's card share grows by ~1.2 GB after the texture pool is flat? VICTORY_MEMORY_CATEGORIES needs a diagnostics build; is there a way to get that breakdown in a normal build?
  3. Would a host-copy cap (for example dropping the top mip level of large title textures on low-memory hosts) be acceptable upstream?
**@⁠GoldenTXS** on GitHub · 2026-12-04 10:40 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/451#issuecomment-7409050417) Follow-up with per-second numbers (`amdgpu_gem_info` every 1 s, same setup as above). **The title levels off; VIctory's blocks do not.** | Time in the world load | 64 KiB title pages | 64 MiB blocks (VIctory) | |---|---|---| | start | 2.4 GB (38.7k) | 10 (640 MB) | | +9 s | 4.6 GB (73k) | 30 (1.9 GB) | | +20 s | 4.8 GB (77k), flat from here | 50 (3.2 GB) | - The texture pool goes from 10 to 30–35 blocks in about 6 s, then stays there. 8–11 of those blocks are "being emptied" for the whole run, and none is ever given back ("0 given back to the card since the start"). `VICTORY_POOL_MOVE=1` moved 1,810 textures (276 MB) but still gave back 0 blocks within the load. - VIctory's card accounting keeps rising after the texture pool is flat: 2,877 → 4,110 MB in 12 s, while host copies of textures only go from 1,315 to 1,429 MB. - The by-address arenas are not the cause here: 1 arena, 72 MB. **Things that made no difference to the peak:** `VICTORY_PRESET=potato` with `VICTORY_WORLD_DIST_SCALE=0.15` (patches confirmed in the log), `VICTORY_LEAN_VRAM_PERCENT=10` (budget 2,048 MB, 3,259 MB used anyway). **With the guard at 95 % and `MemorySwapMax=12G`:** stopped at 13.6 GB of GTT, 137 MiB of RAM free, 2.8 GB in swap, still rising. So the world load wants about 18 GB here. Questions: 1. Is there a reason emptied texture blocks cannot be returned during a load (issue #21 in the `resource.rs` comment)? 2. What else in VIctory's card share grows by ~1.2 GB after the texture pool is flat? `VICTORY_MEMORY_CATEGORIES` needs a diagnostics build; is there a way to get that breakdown in a normal build? 3. Would a host-copy cap (for example dropping the top mip level of large title textures on low-memory hosts) be acceptable upstream?
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-05 17:43 UTC · original

#393 and #501 are worth following for the texture blocks that never get returned. #501 is still a draft and neither has been merged. They may help memory pressure, but we don't yet know if that's enough to load the world on 16 GB shared memory.

**@⁠tommiehansen** on GitHub · 2026-12-05 17:43 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/451#issuecomment-7442445056) #393 and #501 are worth following for the texture blocks that never get returned. #501 is still a draft and neither has been merged. They may help memory pressure, but we don't yet know if that's enough to load the world on 16 GB shared memory.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-05 20:08 UTC · original

I've added the configurable swap limit you mentioned in #620. CI passed, and the default stays at 2 GiB. You can try SWAP_MAX_MB=6144 once it's merged (or on the PR branch). This doesn't solve the underlying GPU memory pressure, though.

**@⁠tommiehansen** on GitHub · 2026-12-05 20:08 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/451#issuecomment-7444560258) I've added the configurable swap limit you mentioned in #620. CI passed, and the default stays at 2 GiB. You can try `SWAP_MAX_MB=6144` once it's merged (or on the PR branch). This doesn't solve the underlying GPU memory pressure, though.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/lobomfz--VIctory-xmem#451
No description provided.