VRAM accounting: ~3.4 GB of free texture-pool blocks and ~1.1 GB of free staging while 17,217 texture slots wait #21

Open
opened 2026-12-01 07:41:27 +00:00 by github-bot · 6 comments
Owner

@⁠216598762 on GitHub · 2026-11-30 07:54 UTC · original

Environment

  • AMD Radeon RX 9060 XT, 16,304 MB, resizable BAR on; RADV 26.3.1 built by ./setup.sh; GE-Proton11-14.
  • Commit cd811c1b5ce8ddc9854230e293e9d9d2df73b44c, Series X profile (CONSOLE unset), 4K output.
  • Two runs on the same dump (Z:\home\null\Documents\GTA in both logs), from first frame to the window closing: 131 s and 121 s.
  • Run A: VICTORY_FSR_4K=quality, VICTORY_OUTPUT=2560x1440 (render 2560×1440 → 3840×2160).
  • Run B: VICTORY_FSR_4K=performance, VICTORY_OUTPUT=1920x1080 (render 1920×1080 → 3840×2160).

Summary

Unified memory is doing what it is for: the title's memory is resident in GTT, mapped through the RADV alias patch, and the VRAM figures below are accounted for entirely by the layer's own caches. The card, however, ends both runs at 94–99 % of the DXGI budget, and the composition at the ceiling looks wrong: 3.4 GB is free space inside 64 MiB texture blocks and 1.1 GB is free staging, while the texture queue reports 17,217 slots, 16,740 of them waiting for memory, and the layer falls back to re-uploading textures in place 154,000 times. No block is ever returned: 0 given back to the card since the start.

The two runs (last stats block before the window closed)

Run A — 4K, FSR quality (2560×1440 render) Run B — 4K, FSR performance (1920×1080 render)
duration 131 s 121 s
fps / frame_ms 25.09 / 39.86 20.42 / 48.97
vram used / budget 13,668 / 13,801 MB (99.0 %) 13,031 / 13,781 MB (94.5 %)
shared (GTT) 11,112 MB 10,831 MB
texture pool 5,952 MB in 93 blocks, 3,377 MB free 5,888 MB in 92 blocks, 3,366 MB free
staging 1,216 MB, 121 MB held → 1,095 MB free 896 MB, 79 MB held → 817 MB free
texture queue 17,217 slots, 16,740 waiting, 91 due (oldest 2,159 frames), 9 partial 17,761 slots, 16,967 waiting, 125 due (oldest 2,707 frames), 52 partial
in-place refreshes 154,000 (309 log records) 141,000 (283 log records)
blocks 93 alive, 8 emptying, 0 returned, 4 refilled "for want of room elsewhere" 92 alive, 8 emptying, 0 returned, 12 refilled

The "309 records" are the log lines: draw.rs prints the refresh message for the first one and every 500th after it (n == 1 || n.is_multiple_of(500)), so 309 records is 154,000 refreshes.

Where the 13.7 GB goes (run A, last stats block)

Consumer Bytes
texture blocks (pool) 5,952 MB reserved → 2,575 MB live, 3,377 MB free
card copies of texture levels 4,106 MB (58,984 host copies of the levels viewed alone (4,106 MB on the card, 25,081 MB of title memory whole))
staging blocks 1,216 MB reserved → 121 MB held
our own allocations 433 MB (32 MB heap + 401 MB audio)
render targets, depth and other 1,961 MB by subtraction (88 depth textures with unordered access, 88 twins; targets_room_kept() reserves up to 3,072 MB)

That accounts for the 13.7 GB without any title resource in it.

It is not the title's memory

  • XMemAllocatePhysicalPages: 710 + 185 + 6,236 = 7,131 MB physical for the title.
  • 131,437 pages in place in 149 stretches of title memory itself at 64 KiB per page ≈ 8.0 GiB, all in GTT (the shared 11,112 MB figure).
  • 36 × 3,840 MB of title ranges mapped as GPU addresses (138,240 MB of address space), e.g. the card reads and writes title memory where the title has it base=0x400000 mb=3840.
  • card_mb_for_title=4016, and write-combined title memory left in RAM never fired — the 4 GiB title reserve was not even filled.

The budget rules involved

  • um.rs: const CARD_KEPT_FOR_HOST: u64 = 12 << 30; — on this 16,304 MB heap the title gets 16,304 − 12,288 = 4,016 MB of write-combined VRAM.
  • resource.rs::room(): host copies are made unconditionally up to budget / 4 (2 GiB), then while used − texture_room + targets_room_kept < budget × ROOM_PERCENT / 100 and used < budget × 92 / 100; ROOM_PERCENT = 86, targets_room_kept() up to 3,072 MB.
  • pool.rs: 64 MiB blocks, SPARE = 2 above 80 % (SPARE_WITH_ROOM = 6 below), room() runs once a second from host::sweep() and reclaims only blocks with nothing left in them; retired blocks rest 5 s before reuse (REST).
  • pool::texture_room() = blocks × 64 MiB − live bytes.

Why the free space cannot be used (inferred from the counters)

  • 93 blocks hold 2,575 MB live → about 27 MB of each 64 MiB block in use. reclaim only drops a block whose free ranges cover all 64 MiB (free.whole(BLOCK)), so a block that still holds any piece stays; world-load fragmentation leaves all of them partly used.
  • At the end 8 blocks were in the emptying phase and none of them was free of live pieces; the remaining 85 still hold pieces too. SPARE is 2 at this pressure (used ≥ 80 % of budget), so even two empty blocks would stay — but with no empty block at all, nothing is returned (0 given back to the card since the start).
  • Yet new pieces still fail, and the layer pays for it elsewhere: 60,943 host copies were let go for room or age (5,080 MB), 309 MB of them nothing showed at the last look under pressure, and the texture queue only has 91 slots due out of 17,217.

Impact

  • texture_late kind="after_memory": n = 75,092, mean 6,964 ms, p50 < 4 s, p90 < 32 s, p99 > 32 s (written_to_shown mean is 59 ms, so the wait is memory, not the copy).
  • 169,790 texture slots uploaded over the run (15,713 MB); 16,740 still waiting at the end.
  • fps plateaus at 20–25 (25.09 in run A, 20.42 in run B) with busy_percent 99–100 and gpu_wait_ms 15.9 (A) / 29.8 (B).

Questions

  1. Is the 12 GiB CARD_KEPT_FOR_HOST reserve meant to cover this much fragmentation slack, or should the pool be sized against live bytes (or trimmed when used ≥ 92 % of budget)?
  2. Should pool::room() be allowed to retire a partly used block under pressure, moving its live pieces to other blocks, instead of only completely empty ones? With 2.6 GB live in 93 blocks this would recover most of the 3.4 GB.
  3. Should staging be trimmed by STAGED rather than by block count? It ends at 1,095 MB free (run A) and 817 MB free (run B) while the pool is at its ceiling.
  4. Is the steady state meant to be "card at 99 %, queue stopped" (91 of 17,217 slots due), or should resource::room()'s 92 % stop leave more room for the queue?

Reproduction

  1. ./run.sh play with VICTORY_FSR_4K=quality and VICTORY_OUTPUT=2560x1440 (or performance / 1920x1080), Series X profile.
  2. Play for about two minutes, then close the window.
  3. The 5-second stats block prints texture blocks free (pool …, staging …, vram used/budget, shared …), texture blocks: … alive … given back to the card …, textures picked by index, the queue: … waiting for their memory …, and the no room for new ones so_far= lines used above.

The two play logs are available if they would help.

**@⁠216598762** on GitHub · 2026-11-30 07:54 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21) **Environment** - AMD Radeon RX 9060 XT, 16,304 MB, resizable BAR on; RADV 26.3.1 built by `./setup.sh`; GE-Proton11-14. - Commit `cd811c1b5ce8ddc9854230e293e9d9d2df73b44c`, Series X profile (`CONSOLE` unset), 4K output. - Two runs on the same dump (`Z:\home\null\Documents\GTA` in both logs), from first frame to the window closing: 131 s and 121 s. - Run A: `VICTORY_FSR_4K=quality`, `VICTORY_OUTPUT=2560x1440` (render 2560×1440 → 3840×2160). - Run B: `VICTORY_FSR_4K=performance`, `VICTORY_OUTPUT=1920x1080` (render 1920×1080 → 3840×2160). ## Summary Unified memory is doing what it is for: the title's memory is resident in GTT, mapped through the RADV alias patch, and the VRAM figures below are accounted for entirely by the layer's own caches. The card, however, ends both runs at 94–99 % of the DXGI budget, and the composition at the ceiling looks wrong: **3.4 GB is free space inside 64 MiB texture blocks and 1.1 GB is free staging**, while the texture queue reports **17,217 slots, 16,740 of them waiting for memory**, and the layer falls back to re-uploading textures in place **154,000 times**. No block is ever returned: `0 given back to the card since the start`. ## The two runs (last stats block before the window closed) | | Run A — 4K, FSR quality (2560×1440 render) | Run B — 4K, FSR performance (1920×1080 render) | |---|---|---| | duration | 131 s | 121 s | | fps / frame_ms | 25.09 / 39.86 | 20.42 / 48.97 | | vram used / budget | 13,668 / 13,801 MB (99.0 %) | 13,031 / 13,781 MB (94.5 %) | | shared (GTT) | 11,112 MB | 10,831 MB | | texture pool | 5,952 MB in 93 blocks, **3,377 MB free** | 5,888 MB in 92 blocks, **3,366 MB free** | | staging | 1,216 MB, **121 MB held → 1,095 MB free** | 896 MB, **79 MB held → 817 MB free** | | texture queue | 17,217 slots, **16,740 waiting**, 91 due (oldest 2,159 frames), 9 partial | 17,761 slots, **16,967 waiting**, 125 due (oldest 2,707 frames), 52 partial | | in-place refreshes | **154,000** (309 log records) | **141,000** (283 log records) | | blocks | 93 alive, 8 emptying, **0 returned**, 4 refilled "for want of room elsewhere" | 92 alive, 8 emptying, **0 returned**, 12 refilled | The "309 records" are the log lines: `draw.rs` prints the refresh message for the first one and every 500th after it (`n == 1 || n.is_multiple_of(500)`), so 309 records is 154,000 refreshes. ## Where the 13.7 GB goes (run A, last stats block) | Consumer | Bytes | |---|---| | texture blocks (pool) | 5,952 MB reserved → 2,575 MB live, 3,377 MB free | | card copies of texture levels | 4,106 MB (`58,984 host copies of the levels viewed alone (4,106 MB on the card, 25,081 MB of title memory whole)`) | | staging blocks | 1,216 MB reserved → 121 MB held | | our own allocations | 433 MB (32 MB heap + 401 MB audio) | | render targets, depth and other | 1,961 MB by subtraction (88 depth textures with unordered access, 88 twins; `targets_room_kept()` reserves up to 3,072 MB) | That accounts for the 13.7 GB without any title resource in it. ## It is not the title's memory - `XMemAllocatePhysicalPages`: 710 + 185 + 6,236 = **7,131 MB** physical for the title. - `131,437 pages in place in 149 stretches of title memory itself` at 64 KiB per page ≈ **8.0 GiB**, all in GTT (the `shared 11,112 MB` figure). - 36 × 3,840 MB of title ranges mapped as GPU addresses (138,240 MB of address space), e.g. `the card reads and writes title memory where the title has it base=0x400000 mb=3840`. - `card_mb_for_title=4016`, and `write-combined title memory left in RAM` never fired — the 4 GiB title reserve was not even filled. ## The budget rules involved - `um.rs`: `const CARD_KEPT_FOR_HOST: u64 = 12 << 30;` — on this 16,304 MB heap the title gets `16,304 − 12,288 = 4,016 MB` of write-combined VRAM. - `resource.rs::room()`: host copies are made unconditionally up to `budget / 4` (2 GiB), then while `used − texture_room + targets_room_kept < budget × ROOM_PERCENT / 100` and `used < budget × 92 / 100`; `ROOM_PERCENT = 86`, `targets_room_kept()` up to 3,072 MB. - `pool.rs`: 64 MiB blocks, `SPARE = 2` above 80 % (`SPARE_WITH_ROOM = 6` below), `room()` runs once a second from `host::sweep()` and reclaims only blocks with nothing left in them; retired blocks rest 5 s before reuse (`REST`). - `pool::texture_room()` = `blocks × 64 MiB − live bytes`. ## Why the free space cannot be used (inferred from the counters) - 93 blocks hold 2,575 MB live → about 27 MB of each 64 MiB block in use. `reclaim` only drops a block whose free ranges cover all 64 MiB (`free.whole(BLOCK)`), so a block that still holds any piece stays; world-load fragmentation leaves all of them partly used. - At the end 8 blocks were in the emptying phase and none of them was free of live pieces; the remaining 85 still hold pieces too. `SPARE` is 2 at this pressure (used ≥ 80 % of budget), so even two empty blocks would stay — but with no empty block at all, nothing is returned (`0 given back to the card since the start`). - Yet new pieces still fail, and the layer pays for it elsewhere: 60,943 host copies were let go for room or age (5,080 MB), 309 MB of them `nothing showed at the last look under pressure`, and the texture queue only has 91 slots due out of 17,217. ## Impact - `texture_late kind="after_memory"`: n = 75,092, mean 6,964 ms, p50 < 4 s, p90 < 32 s, p99 > 32 s (`written_to_shown` mean is 59 ms, so the wait is memory, not the copy). - 169,790 texture slots uploaded over the run (15,713 MB); 16,740 still waiting at the end. - fps plateaus at 20–25 (25.09 in run A, 20.42 in run B) with `busy_percent` 99–100 and `gpu_wait_ms` 15.9 (A) / 29.8 (B). ## Questions 1. Is the 12 GiB `CARD_KEPT_FOR_HOST` reserve meant to cover this much fragmentation slack, or should the pool be sized against live bytes (or trimmed when `used ≥ 92 %` of budget)? 2. Should `pool::room()` be allowed to retire a partly used block under pressure, moving its live pieces to other blocks, instead of only completely empty ones? With 2.6 GB live in 93 blocks this would recover most of the 3.4 GB. 3. Should staging be trimmed by `STAGED` rather than by block count? It ends at 1,095 MB free (run A) and 817 MB free (run B) while the pool is at its ceiling. 4. Is the steady state meant to be "card at 99 %, queue stopped" (91 of 17,217 slots due), or should `resource::room()`'s 92 % stop leave more room for the queue? ## Reproduction 1. `./run.sh play` with `VICTORY_FSR_4K=quality` and `VICTORY_OUTPUT=2560x1440` (or `performance` / `1920x1080`), Series X profile. 2. Play for about two minutes, then close the window. 3. The 5-second stats block prints `texture blocks free (pool …, staging …, vram used/budget, shared …)`, `texture blocks: … alive … given back to the card …`, `textures picked by index, the queue: … waiting for their memory …`, and the `no room for new ones so_far=` lines used above. The two play logs are available if they would help.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:41:27 +00:00
Author
Owner

@⁠LOCKhart07 on GitHub · 2026-11-30 13:53 UTC · original

Same picture here on a 9070 XT (16 GB), cd811c1, 2560x1440, ray tracing on. While driving: VRAM 13.6 / 15.3 GB, 173 texture slots due, ~19 MB/frame uploaded, GPU 47 ms. Textures flicker and pop in, and there are no dropped draws or missing pipelines.

I looked for prior work on this across the VIctory forks: the 30 forks of this repo, plus 97 copies of crates/victory-gpu/src/pool.rs found through GitHub code search. None of this repo's forks change the reclaim rule. Two other VIctory forks implement actual compaction:

  • crbns/victory-tapin (r25–r35, see the r35 commit):
    • Switches: VICTORY_POOL_DRAIN and VICTORY_POOL_COMPACT=1, both off by default.
    • How it picks blocks: once a second, the emptiest blocks are chosen (compact_choice), as many as the other blocks can absorb while keeping a headroom free (VICTORY_POOL_HEADROOM_MB, default 256).
    • The mover: their textures are moved out (resource::drain_moves), at a rate bounded per second that rises with how far the card is over budget.
    • When it holds off: nothing is chosen for 10 s after the pool last grew (a world loading), or for a block whose largest texture fits no free range elsewhere.
    • Tests: unit tests for the choice and headroom.
    • Their numbers (8 GB card): over budget in 1,260 of 1,304 s without the drain, 191 of 1,916 s with the drain, 0 of 262 s with compaction. The last run is short; their README says long sessions with compaction aren't measured yet.
  • zivyn/codec-d--cool_fox: a similar compaction (resource::compact_pool) plus VICTORY_POOL_FIT=best placement.

Partial measures seen elsewhere: best-fit placement only (a few forks), and 32 MiB or 16 MiB blocks (three forks).

This repo already has half of it: pool::drain(only) marks blocks so they take no new pieces. Those are the "8 emptying" blocks in the counters above. Nothing moves the live textures out, though, so an emptying block only frees once the title releases every texture in it, which during streaming it doesn't. The piece that's missing compared with tapin is the mover, plus the choice of which blocks to empty.

I'm planning to port that piece to xmem: read their design and reimplement it here, behind a switch. I'll report back with before/after numbers from a driving run. Their README also lists texture flicker that remains with compaction on and has no known cause, so compaction likely fixes the wasted VRAM and memory waits, but not necessarily all the flicker.

**@⁠LOCKhart07** on GitHub · 2026-11-30 13:53 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21#issuecomment-7280531495) Same picture here on a 9070 XT (16 GB), `cd811c1`, 2560x1440, ray tracing on. While driving: VRAM 13.6 / 15.3 GB, 173 texture slots due, ~19 MB/frame uploaded, GPU 47 ms. Textures flicker and pop in, and there are no dropped draws or missing pipelines. I looked for prior work on this across the VIctory forks: the 30 forks of this repo, plus 97 copies of `crates/victory-gpu/src/pool.rs` found through GitHub code search. None of this repo's forks change the reclaim rule. Two other VIctory forks implement actual compaction: - **[crbns/victory-tapin](https://github.com/crbns/victory-tapin)** (r25–r35, see the [r35 commit](https://github.com/crbns/victory-tapin/commit/3dba942c)): - **Switches:** `VICTORY_POOL_DRAIN` and `VICTORY_POOL_COMPACT=1`, both off by default. - **How it picks blocks:** once a second, the emptiest blocks are chosen (`compact_choice`), as many as the other blocks can absorb while keeping a headroom free (`VICTORY_POOL_HEADROOM_MB`, default 256). - **The mover:** their textures are moved out (`resource::drain_moves`), at a rate bounded per second that rises with how far the card is over budget. - **When it holds off:** nothing is chosen for 10 s after the pool last grew (a world loading), or for a block whose largest texture fits no free range elsewhere. - **Tests:** unit tests for the choice and headroom. - **Their numbers (8 GB card):** over budget in 1,260 of 1,304 s without the drain, 191 of 1,916 s with the drain, 0 of 262 s with compaction. The last run is short; their README says long sessions with compaction aren't measured yet. - **[zivyn/codec-d--cool_fox](https://github.com/zivyn/codec-d--cool_fox)**: a similar compaction (`resource::compact_pool`) plus `VICTORY_POOL_FIT=best` placement. Partial measures seen elsewhere: best-fit placement only (a few forks), and 32 MiB or 16 MiB blocks (three forks). This repo already has half of it: `pool::drain(only)` marks blocks so they take no new pieces. Those are the "8 emptying" blocks in the counters above. Nothing moves the live textures out, though, so an emptying block only frees once the title releases every texture in it, which during streaming it doesn't. The piece that's missing compared with tapin is the mover, plus the choice of which blocks to empty. I'm planning to port that piece to xmem: read their design and reimplement it here, behind a switch. I'll report back with before/after numbers from a driving run. Their README also lists texture flicker that remains with compaction on and has no known cause, so compaction likely fixes the wasted VRAM and memory waits, but not necessarily all the flicker.
Author
Owner

@⁠grykom on GitHub · 2026-12-01 14:02 UTC · original

@⁠LOCKhart07 before you start the port: we have a give-back branch that already does the missing piece (the mover plus
the choice of blocks), measured today. Sharing so we don't both write it.

What it does, behind VICTORY_VRAM_GIVE_BACK=1 (off = unchanged code):

  • texture and staging blocks of 16 MiB instead of 64 MiB, best-fit placement into the fullest ripe blocks, 1-2 spare
    blocks instead of 2-6;
  • compaction, once a second from host::sweep() when nothing is in flight: picks up to 16 of the sparsest blocks whose
    textures can all move (largest texture fits a free range elsewhere, at least 128 MiB of headroom kept), copies them
    GPU->GPU (one list, grouped barriers, own fence), swaps the HostTexture and the descriptors, keeps the old copy for
    ~1 s + 4 frames before retiring it. Skips textures touched in the last 500 ms, host-written, staged, aliased or held by
    a list. 32 MiB/s, 64 MiB/s above 85 % VRAM; holds off for 5 s after the pool grew;
  • let_go_idle() also lets idle, unpinned textures go from WaitedOut blocks;
  • idle staging blocks returned after 5-15 s instead of 5 min.

Numbers (RX 9070 16 GB, prison cell, 2560x1440, diag build on cd811c1, A B B A with a second variant in between, 4 min
runs; VRAM reading includes ~1.2 GB for a remote-desktop screen, the same in every arm):

VRAM peak texture blocks reserved / live cell fps
off 15,079 / 15,037 MB 96-97 blocks of 64 MiB, ~6.1 GB (1-2 ever given back) 35.8 / 32.8
give-back 13,806 / 13,912 MB 2,720 / 2,555 MB (165-197 MB free) 36.8 / 37.5

(The "off" log doesn't print the free space inside blocks; a third variant in the same series, with the same 64 MiB
blocks and no compaction, logged 3.2-3.4 GB free inside 97-99 blocks.)

  • ~11.5k textures (~1.25 GB) compacted per run, 240-259 blocks of 16 MiB returned. No visible artefacts.
  • These runs also had our experimental page split on, which keeps never-CPU-touched pages in VRAM with a free-VRAM
    budget. With give-back it kept 2.1-2.3 GB of title pages on the card instead of 0.8-0.9 GB, and the peak was still
    1.2 GB lower. So about 2.6 GB of VRAM came back in total.
  • fps: +8 % on average, but the "off" arm drifted 3 fps over the series, so I would not quote it yet.
  • Open: more frames over 80 ms in the cutscene where compaction starts (21-31 vs 2-16). The copy runs on the main
    queue and waits for its fence, so it may be the cost, but that is not confirmed. One run also had a 2.2 s stall at
    world load, before compaction had started; the second run didn't.
    Not yet measured: open world / driving, upstream main.

The branch is on cd811c1 with our older experiment under it, so it is not a PR as is. If it's useful I can push it
to my fork for you to read, or port it to current main myself; your call, so we don't both do it.

**@⁠grykom** on GitHub · 2026-12-01 14:02 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21#issuecomment-7313586231) @⁠LOCKhart07 before you start the port: we have a give-back branch that already does the missing piece (the mover plus the choice of blocks), measured today. Sharing so we don't both write it. What it does, behind `VICTORY_VRAM_GIVE_BACK=1` (off = unchanged code): - texture and staging blocks of 16 MiB instead of 64 MiB, best-fit placement into the fullest ripe blocks, 1-2 spare blocks instead of 2-6; - compaction, once a second from `host::sweep()` when nothing is in flight: picks up to 16 of the sparsest blocks whose textures can all move (largest texture fits a free range elsewhere, at least 128 MiB of headroom kept), copies them GPU->GPU (one list, grouped barriers, own fence), swaps the `HostTexture` and the descriptors, keeps the old copy for ~1 s + 4 frames before retiring it. Skips textures touched in the last 500 ms, host-written, staged, aliased or held by a list. 32 MiB/s, 64 MiB/s above 85 % VRAM; holds off for 5 s after the pool grew; - `let_go_idle()` also lets idle, unpinned textures go from `WaitedOut` blocks; - idle staging blocks returned after 5-15 s instead of 5 min. Numbers (RX 9070 16 GB, prison cell, 2560x1440, diag build on `cd811c1`, A B B A with a second variant in between, 4 min runs; VRAM reading includes ~1.2 GB for a remote-desktop screen, the same in every arm): | | VRAM peak | texture blocks reserved / live | cell fps | |---|---|---|---| | off | 15,079 / 15,037 MB | 96-97 blocks of 64 MiB, ~6.1 GB (1-2 ever given back) | 35.8 / 32.8 | | give-back | 13,806 / 13,912 MB | 2,720 / 2,555 MB (165-197 MB free) | 36.8 / 37.5 | (The "off" log doesn't print the free space inside blocks; a third variant in the same series, with the same 64 MiB blocks and no compaction, logged 3.2-3.4 GB free inside 97-99 blocks.) - ~11.5k textures (~1.25 GB) compacted per run, 240-259 blocks of 16 MiB returned. No visible artefacts. - These runs also had our experimental page split on, which keeps never-CPU-touched pages in VRAM with a free-VRAM budget. With give-back it kept 2.1-2.3 GB of title pages on the card instead of 0.8-0.9 GB, and the peak was still 1.2 GB lower. So about 2.6 GB of VRAM came back in total. - fps: +8 % on average, but the "off" arm drifted 3 fps over the series, so I would not quote it yet. - Open: more frames over 80 ms in the cutscene where compaction starts (21-31 vs 2-16). The copy runs on the main queue and waits for its fence, so it may be the cost, but that is not confirmed. One run also had a 2.2 s stall at world load, before compaction had started; the second run didn't. Not yet measured: open world / driving, upstream `main`. The branch is on `cd811c1` with our older experiment under it, so it is not a PR as is. If it's useful I can push it to my fork for you to read, or port it to current `main` myself; your call, so we don't both do it.
Author
Owner

@⁠Aruku448 on GitHub · 2026-12-01 14:17 UTC · original

Same shape on RDNA3 (RX 7800 XT, 37bb30f, wine-staging 11.22, Series X profile at 1080p, RT off), one ~20 minute session:

textures picked by index: 5780537 uploaded so far (493941 MB), 24315 waiting,
  4751746 passed over unmapped, 22212 uploaded from memory that read all zeros
picked_textures: written_under=36.22 written_uploaded_again=36.14 looks_same=126.42
  looks_changed=0.0 looks_told=0.0 looks_copy_differs=0.0

Two things there that are new to me, and both look like the visible defect:

  • 22,212 textures uploaded from memory that read all zeros. Those are presumably the props that stay black or arrive late, and it would explain "different objects stay black from run to run" in #69 as well.
  • written_uploaded_again (36.14 MB/frame) is essentially equal to written_under (36.22 MB/frame) while looks_same is 126 MB/frame: almost all of the upload traffic is textures written and then uploaded again inside the same frame, and the comparison layer already proved the bytes match. That is most of the 4.4 ms/frame copy_ms here, before any pumping.

24,315 waiting at the end of the session, VRAM at 15,469 of 16,368 MB (94 %), GPU 89 %.

**@⁠Aruku448** on GitHub · 2026-12-01 14:17 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21#issuecomment-7314009332) Same shape on RDNA3 (RX 7800 XT, `37bb30f`, wine-staging 11.22, Series X profile at 1080p, RT off), one ~20 minute session: ``` textures picked by index: 5780537 uploaded so far (493941 MB), 24315 waiting, 4751746 passed over unmapped, 22212 uploaded from memory that read all zeros picked_textures: written_under=36.22 written_uploaded_again=36.14 looks_same=126.42 looks_changed=0.0 looks_told=0.0 looks_copy_differs=0.0 ``` Two things there that are new to me, and both look like the visible defect: - **22,212 textures uploaded from memory that read all zeros.** Those are presumably the props that stay black or arrive late, and it would explain "different objects stay black from run to run" in #69 as well. - `written_uploaded_again` (36.14 MB/frame) is essentially equal to `written_under` (36.22 MB/frame) while `looks_same` is 126 MB/frame: almost all of the upload traffic is textures written and then uploaded again inside the same frame, and the comparison layer already proved the bytes match. That is most of the 4.4 ms/frame `copy_ms` here, before any pumping. 24,315 waiting at the end of the session, VRAM at 15,469 of 16,368 MB (94 %), GPU 89 %.
Author
Owner

@⁠grykom on GitHub · 2026-12-01 19:47 UTC · original

VRAM give-back on current main: measurements and a branch to try

Follow-up to my earlier note here. The give-back branch is now ported onto main (37bb30f) and measured there,
on a physical monitor this time. Branch: https://github.com/grykom/VIctory-xmem/tree/give-back-main (commits on top of 37bb30f, all behind switches; unset = main).

What it does (behind VICTORY_VRAM_GIVE_BACK=1): 16 MiB texture/staging blocks instead of 64 MiB, best-fit into the
fullest blocks, compaction of the sparsest texture blocks once a second (GPU->GPU copy, descriptor swap, old copy kept
~1 s + 4 frames), idle staging returned after 5-15 s. Details in my previous comment.

Setup: RX 9070 16 GB, prison cell, 2560x1440, diag build, RT off, 7 min runs, order A B C C B A, physical monitor
(desktop uses ~0.4 GB). Run-to-run spread in this series ~0.4 fps.

arm VRAM peak free VRAM at end title pages on the card fps 360-420 s 1 % low 360-420 s
A main (residency room 4 GB) 14,455 / 14,495 MB 1.78 / 1.74 GB 3.87 GB 41.7 / 41.4 18.4 / 18.7
B + give-back 13,271 / 13,243 MB 3.09 / 3.18 GB 3.87 GB 41.5 / 41.4 21.1 / 19.8
C + give-back + room 7 GB (VICTORY_CARD_KEPT_MB=9216) 14,015 / 14,091 MB 2.52 / 2.34 GB 5.37 / 5.40 GB 43.9 / 44.2 21.4 / 19.7
  • Give-back alone: peak -1.2 GB, +1.4 GB free, fps unchanged, because residency's room is fixed at VRAM - 12 GiB and
    doesn't use the space. Texture pool slack goes from ~3.3 GB (measured earlier with 64 MiB blocks) to ~100 MB;
    ~7-8k textures (0.8-0.9 GB) compacted per run.
  • With a larger room residency puts 1.5 GB more title pages on the card: +6 % fps at the end of the run, and the peak is
    still 0.4 GB below main. The room was not full (5.4 of 7.1 GB) and 2.3-2.5 GB stayed free: 43k pages in 7 min is
    exactly the 128 pages/s pace, so pace is the next limit.
  • Steady-state 1 % lows are better with give-back; over the whole run they are a bit worse because of extra frames
    over 80 ms when compaction starts during the cutscene (9-19 vs 7-12). Copy waits on its fence and the texture scan
    takes up to ~13 ms; both are known and not fixed yet.

Open world (Mandy save, walk then drive, ~6 min, one run per arm, played by hand on a similar route) is a different
story:

arm avg fps 1 % low frames > 80 ms worst
main, PAGES=0 28.7 11.1 84 115 ms
main, PAGES=1 29.2 9.5 121 678 ms
+ give-back + room 7 GB 28.8 8.7 194 675 ms
  • No fps gain and more stutter. Residency filled only 4.4 of its 7.1 GB room: of 44.8k pages moved up, 21.2k (47 %)
    went back down because the CPU touched them, most after 30 s to a few minutes (return times in vktory6/VKtory#17).
    A bigger room in a streaming scene mostly means more churn, not more pages staying on the card.
  • Texture slack while driving was 1.3 GB (vs ~0.1 GB in the cell): textures stream in faster than compaction moves
    them (32-64 MiB/s).
  • So: in a static scene free VRAM is the limit and give-back turns it into fps; in the open world the limit is page
    churn, and more room doesn't help until pages that will be touched again are told apart from those that won't.

How to measure it on your card (no extra tooling, all in the normal log):

  • A/B: unset vs VICTORY_VRAM_GIVE_BACK=1, and optionally VICTORY_CARD_KEPT_MB=<VRAM - room you want, in MB> to
    let residency use what comes back (we used 9216 on 16 GB; on 8-12 GB cards try a smaller room first).
  • vram give-back ... line: pool_reserved_mb vs pool_live_mb (slack), returned_blocks, compacted_mb.
  • page residency: ... line: MB on the card, room, MB of the card free.
  • page returns (...) line (from the counter commit): how long pages stayed on the card before the CPU pulled them back.
  • compaction pass timing (diag, passes over 5 ms): where the compaction time goes.
  • Compare fps and 1 % low over a fixed window late in the run (we use 360-420 s); the first minutes are dominated by
    residency filling up.
    Most useful to us: small cards (8-12 GB) and open world, which we can't test.

Not for merging as is: the pace/room switches are local experiments, and the give-back stutter at compaction start is
open. If you'd rather take only parts of it (block size + best-fit, staging return, compaction), say which.

**@⁠grykom** on GitHub · 2026-12-01 19:47 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21#issuecomment-7323449404) VRAM give-back on current `main`: measurements and a branch to try Follow-up to my earlier note here. The give-back branch is now ported onto `main` (`37bb30f`) and measured there, on a physical monitor this time. Branch: https://github.com/grykom/VIctory-xmem/tree/give-back-main (commits on top of `37bb30f`, all behind switches; unset = `main`). What it does (behind `VICTORY_VRAM_GIVE_BACK=1`): 16 MiB texture/staging blocks instead of 64 MiB, best-fit into the fullest blocks, compaction of the sparsest texture blocks once a second (GPU->GPU copy, descriptor swap, old copy kept ~1 s + 4 frames), idle staging returned after 5-15 s. Details in my previous comment. Setup: RX 9070 16 GB, prison cell, 2560x1440, diag build, RT off, 7 min runs, order A B C C B A, physical monitor (desktop uses ~0.4 GB). Run-to-run spread in this series ~0.4 fps. | arm | VRAM peak | free VRAM at end | title pages on the card | fps 360-420 s | 1 % low 360-420 s | |---|---|---|---|---|---| | A `main` (residency room 4 GB) | 14,455 / 14,495 MB | 1.78 / 1.74 GB | 3.87 GB | 41.7 / 41.4 | 18.4 / 18.7 | | B + give-back | 13,271 / 13,243 MB | 3.09 / 3.18 GB | 3.87 GB | 41.5 / 41.4 | 21.1 / 19.8 | | C + give-back + room 7 GB (`VICTORY_CARD_KEPT_MB=9216`) | 14,015 / 14,091 MB | 2.52 / 2.34 GB | 5.37 / 5.40 GB | 43.9 / 44.2 | 21.4 / 19.7 | - Give-back alone: peak -1.2 GB, +1.4 GB free, fps unchanged, because residency's room is fixed at VRAM - 12 GiB and doesn't use the space. Texture pool slack goes from ~3.3 GB (measured earlier with 64 MiB blocks) to ~100 MB; ~7-8k textures (0.8-0.9 GB) compacted per run. - With a larger room residency puts 1.5 GB more title pages on the card: +6 % fps at the end of the run, and the peak is still 0.4 GB below `main`. The room was not full (5.4 of 7.1 GB) and 2.3-2.5 GB stayed free: 43k pages in 7 min is exactly the 128 pages/s pace, so pace is the next limit. - Steady-state 1 % lows are better with give-back; over the whole run they are a bit worse because of extra frames over 80 ms when compaction starts during the cutscene (9-19 vs 7-12). Copy waits on its fence and the texture scan takes up to ~13 ms; both are known and not fixed yet. Open world (Mandy save, walk then drive, ~6 min, one run per arm, played by hand on a similar route) is a different story: | arm | avg fps | 1 % low | frames > 80 ms | worst | |---|---|---|---|---| | `main`, PAGES=0 | 28.7 | 11.1 | 84 | 115 ms | | `main`, PAGES=1 | 29.2 | 9.5 | 121 | 678 ms | | + give-back + room 7 GB | 28.8 | 8.7 | 194 | 675 ms | - No fps gain and more stutter. Residency filled only 4.4 of its 7.1 GB room: of 44.8k pages moved up, 21.2k (47 %) went back down because the CPU touched them, most after 30 s to a few minutes (return times in vktory6/VKtory#17). A bigger room in a streaming scene mostly means more churn, not more pages staying on the card. - Texture slack while driving was 1.3 GB (vs ~0.1 GB in the cell): textures stream in faster than compaction moves them (32-64 MiB/s). - So: in a static scene free VRAM is the limit and give-back turns it into fps; in the open world the limit is page churn, and more room doesn't help until pages that will be touched again are told apart from those that won't. How to measure it on your card (no extra tooling, all in the normal log): - A/B: unset vs `VICTORY_VRAM_GIVE_BACK=1`, and optionally `VICTORY_CARD_KEPT_MB=<VRAM - room you want, in MB>` to let residency use what comes back (we used 9216 on 16 GB; on 8-12 GB cards try a smaller room first). - `vram give-back ...` line: `pool_reserved_mb` vs `pool_live_mb` (slack), `returned_blocks`, `compacted_mb`. - `page residency: ...` line: MB on the card, room, MB of the card free. - `page returns (...)` line (from the counter commit): how long pages stayed on the card before the CPU pulled them back. - `compaction pass timing` (diag, passes over 5 ms): where the compaction time goes. - Compare fps and 1 % low over a fixed window late in the run (we use 360-420 s); the first minutes are dominated by residency filling up. Most useful to us: small cards (8-12 GB) and open world, which we can't test. Not for merging as is: the pace/room switches are local experiments, and the give-back stutter at compaction start is open. If you'd rather take only parts of it (block size + best-fit, staging return, compaction), say which.
Author
Owner

@⁠TheRifai on GitHub · 2026-12-02 11:26 UTC · original

A comparison point from vkback's arena on the same GPU class (RX 9070 XT, main d59b4f8, GE-Proton11-16, Series X, 3840x2160, house save rt3, 80 s warm-store run, UMEM_MEMREPORT=1):

  • Arena: 26,945 images / ~5,966 MB, of which GPU-written 1,192 / ~4,030 MB and texture copies 25,753 / ~1,936 MB.
  • Free inside arena blocks: 716 MB of 5,966 MB (~12%), of which 315 MB in GTT blocks; 1 empty block; largest free range 256 MB.
  • umem: vram 17 blocks / 2,294 MB, gtt 17 blocks / 2,429 MB.

So our free-inside-block fraction is much smaller than the ~50% you saw on VIctory-NVIDIA, but it is fragmented (256 MB largest range, 27 blocks), so compaction alone would not free a whole 64 MB-equivalent block easily. Your point that slack only becomes fps when a consumer uses the freed room still holds; on our side the consumer would be in-place render targets, not page residency. Evidence: /home/shlong/Documents/VKtory-capture/arena-slack/20261202-122424/. No code change from me.

**@⁠TheRifai** on GitHub · 2026-12-02 11:26 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21#issuecomment-7343926439) A comparison point from vkback's arena on the same GPU class (RX 9070 XT, main `d59b4f8`, GE-Proton11-16, Series X, 3840x2160, house save `rt3`, 80 s warm-store run, `UMEM_MEMREPORT=1`): - Arena: 26,945 images / ~5,966 MB, of which GPU-written 1,192 / ~4,030 MB and texture copies 25,753 / ~1,936 MB. - Free inside arena blocks: **716 MB of 5,966 MB (~12%)**, of which 315 MB in GTT blocks; 1 empty block; **largest free range 256 MB**. - umem: vram 17 blocks / 2,294 MB, gtt 17 blocks / 2,429 MB. So our free-inside-block fraction is much smaller than the ~50% you saw on VIctory-NVIDIA, but it is fragmented (256 MB largest range, 27 blocks), so compaction alone would not free a whole 64 MB-equivalent block easily. Your point that slack only becomes fps when a consumer uses the freed room still holds; on our side the consumer would be in-place render targets, not page residency. Evidence: `/home/shlong/Documents/VKtory-capture/arena-slack/20261202-122424/`. No code change from me.
Author
Owner

@⁠grykom on GitHub · 2026-12-02 16:18 UTC · original

A data point for current main on RX 9070 16 GB, open world (Mandy save, walking then driving, played by hand on the
same route, ~5 min each, 1440p output, release build, RT off, physical monitor). One run per build, so take it as a
hint, not a verdict.

  • A: our branch on 37bb30f (give-back-main 4c6d3c6, switches off = 37bb30f + a page-return counter):
    the old page pace, 1 s passes of 8 MiB, "seen" source on.
  • B off: main d044248, defaults ("seen" source off since f68c5c9).
  • B seen: main d044248 with VICTORY_PAGES_SEEN=1.
avg fps median 1 % low frames > 50 ms frames > 80 ms worst pages moved up / down on CPU touch
A 29.8 31.3 ms 9.9 530 99 689 ms (one) 32.4k / 16.6k (51 %)
B off 27.0 34.7 ms 9.8 1106 127 165 ms 15.6k / 11.2k (72 %)
B seen 25.2 36.5 ms 9.2 1609 208 207 ms 61.8k / 45.9k (74 %)
  • Both B runs lose in the same two stretches (driving), 22-24 fps where A held 29-30; in the calmer parts B off is
    level with A. B leaves ~0.8-1 GB more VRAM free (1.7-1.9 GB vs 0.9 GB), which this card doesn't turn into frames.
  • The share of moved pages that the CPU pulls back went from about half to about three quarters. B seen also
    logged 8.6k of them "within two seconds of promotion".
  • Main has many other changes since 37bb30f (reads through a card copy instead of BAR, the Mesa budget patch, ...),
    so this does not isolate the page pace. It's only where the counters point.

If someone wants to check this on their card: the page residency: line in the log gives "pages moved up" and
"down when the processor touched them"; VICTORY_PAGE_PASS_MS=1000 VICTORY_PAGE_MOVE_MB=8 puts back the old pace
from 518bc1b (the guard release stays). Comparing that against defaults on the same route would show whether the
faster pace is what costs frames in the open world. We may run that ourselves later; numbers from other cards would
help more.

**@⁠grykom** on GitHub · 2026-12-02 16:18 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/21#issuecomment-7351758128) A data point for current main on RX 9070 16 GB, open world (Mandy save, walking then driving, played by hand on the same route, ~5 min each, 1440p output, release build, RT off, physical monitor). One run per build, so take it as a hint, not a verdict. - A: our branch on `37bb30f` (`give-back-main` `4c6d3c6`, switches off = `37bb30f` + a page-return counter): the old page pace, 1 s passes of 8 MiB, "seen" source on. - B off: main `d044248`, defaults ("seen" source off since f68c5c9). - B seen: main `d044248` with `VICTORY_PAGES_SEEN=1`. | | avg fps | median | 1 % low | frames > 50 ms | frames > 80 ms | worst | pages moved up / down on CPU touch | |---|---|---|---|---|---|---|---| | A | 29.8 | 31.3 ms | 9.9 | 530 | 99 | 689 ms (one) | 32.4k / 16.6k (51 %) | | B off | 27.0 | 34.7 ms | 9.8 | 1106 | 127 | 165 ms | 15.6k / 11.2k (72 %) | | B seen | 25.2 | 36.5 ms | 9.2 | 1609 | 208 | 207 ms | 61.8k / 45.9k (74 %) | - Both B runs lose in the same two stretches (driving), 22-24 fps where A held 29-30; in the calmer parts B off is level with A. B leaves ~0.8-1 GB more VRAM free (1.7-1.9 GB vs 0.9 GB), which this card doesn't turn into frames. - The share of moved pages that the CPU pulls back went from about half to about three quarters. B seen also logged 8.6k of them "within two seconds of promotion". - Main has many other changes since `37bb30f` (reads through a card copy instead of BAR, the Mesa budget patch, ...), so this does not isolate the page pace. It's only where the counters point. If someone wants to check this on their card: the `page residency:` line in the log gives "pages moved up" and "down when the processor touched them"; `VICTORY_PAGE_PASS_MS=1000 VICTORY_PAGE_MOVE_MB=8` puts back the old pace from 518bc1b (the guard release stays). Comparing that against defaults on the same route would show whether the faster pace is what costs frames in the open world. We may run that ourselves later; numbers from other cards would help more.
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#21
No description provided.