GPU: scale texture pool spares() by remaining DXGI VRAM headroom (#94) #119

Open
github-bot wants to merge 1 commit from github-bot/gh-119 into main AGit
Owner

@⁠ESAT586 on GitHub · 2026-11-26 04:40 UTC · original
ESAT586:avatarmanz/pool-headroom-spares → main · +26 −9 · 1 files · 1 commits · open

Fixes #94.

Problem

pool::spares() used a binary threshold (used < 85% * budget -> SPARE_KEPT = 64 blocks = 4 GiB, else SPARE = 2 blocks = 128 MiB). On 8–16 GB GPUs operating below 85 % usage, retaining up to 4 GiB of empty blocks can push VRAM over the DXGI budget and trigger PCIe paging.

Change

  • Scale pool::spares() by half the remaining headroom below 85 % of budget, in BLOCK (64 MiB) units, clamped to SPARE..=SPARE_KEPT:
    • 24 GiB card (e.g. 10 GiB / 24 GiB): stays at SPARE_KEPT (64 blocks = 4 GiB) — unchanged.
    • 16 GiB-class card (e.g. 12 GiB / 15.3 GiB): ~8 blocks (~512 MiB) instead of 4 GiB.
    • 8 GiB-class card (e.g. 5.5 GiB / 7.25 GiB): 5 blocks (320 MiB) instead of 4 GiB.
    • >= 85 % / keep == false / None / zero budget: SPARE (2 blocks = 128 MiB) — unchanged.
  • Pool::rested() and Ripe::now() already read SPARES dynamically, so excess empty blocks trim automatically and ahead stays bounded.
  • Updated empty_blocks_stay_while_the_card_has_room unit test to cover 24 GiB, 16 GiB, 8 GiB, tight headroom, >= 85 %, 0 budget, keep == false, and None.

Verification

  • cargo test -p victory-gpu --locked -- pool:: --test-threads=1 on NVIDIA GeForce RTX 3060 Ti 8 GB: 6 passed, 0 failed.
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- pool:: --test-threads=1: 6 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in pool.rs.
  • cargo xtask policy --staged: asset policy: 1 files ok.
**@⁠ESAT586** on GitHub · 2026-11-26 04:40 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/119) `ESAT586:avatarmanz/pool-headroom-spares` → `main` · +26 −9 · 1 files · 1 commits · open Fixes #94. ### Problem `pool::spares()` used a binary threshold (`used < 85% * budget -> SPARE_KEPT = 64` blocks = 4 GiB, else `SPARE = 2` blocks = 128 MiB). On 8–16 GB GPUs operating below 85 % usage, retaining up to 4 GiB of empty blocks can push VRAM over the DXGI budget and trigger PCIe paging. ### Change - Scale `pool::spares()` by half the remaining headroom below 85 % of `budget`, in `BLOCK` (64 MiB) units, clamped to `SPARE..=SPARE_KEPT`: - **24 GiB card** (e.g. 10 GiB / 24 GiB): stays at **`SPARE_KEPT` (64 blocks = 4 GiB)** — unchanged. - **16 GiB-class card** (e.g. 12 GiB / 15.3 GiB): **~8 blocks (~512 MiB)** instead of 4 GiB. - **8 GiB-class card** (e.g. 5.5 GiB / 7.25 GiB): **5 blocks (320 MiB)** instead of 4 GiB. - **`>= 85 %` / `keep == false` / `None` / zero budget**: **`SPARE` (2 blocks = 128 MiB)** — unchanged. - `Pool::rested()` and `Ripe::now()` already read `SPARES` dynamically, so excess empty blocks trim automatically and `ahead` stays bounded. - Updated `empty_blocks_stay_while_the_card_has_room` unit test to cover 24 GiB, 16 GiB, 8 GiB, tight headroom, `>= 85 %`, `0` budget, `keep == false`, and `None`. ### Verification - `cargo test -p victory-gpu --locked -- pool:: --test-threads=1` on NVIDIA GeForce RTX 3060 Ti 8 GB: **6 passed, 0 failed**. - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- pool:: --test-threads=1`: **6 passed, 0 failed**. - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: **0 warnings** in `pool.rs`. - `cargo xtask policy --staged`: **`asset policy: 1 files ok`**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:24:50 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:36 UTC · original

Left open: under load the 7900 XTX keeps fewer empty blocks than now (16 instead of 64 at 18 GB used); needs an in-game check first.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:36 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/119#issuecomment-7185636664) Left open: under load the 7900 XTX keeps fewer empty blocks than now (16 instead of 64 at 18 GB used); needs an in-game check first.
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-26 09:19 UTC · original

Tested on an 8 GB card under Wine/RADV: the VRAM cap is real, and the tail of the frame time improves.

Setup: Radeon RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, CachyOS kernel 7.3.5, your main 0ce46d5 + this branch, x86_64-pc-windows-gnu, --features diagnostics, retail 1.0.2.1, Series S, the launcher's profile (VICTORY_RELAY=2, TEXTURE_NO_WAIT=1, JOIN_COPIES=1, CARD_STEPS=2, AMBIENT=0.8, PORT_DESCRIPTORS=1), VICTORY_TEXTURE_BUDGET_MB=4608, VICTORY_CARD_BUFFERS_MB=1024. A dxcompiler.dll fallback for D3DCompile is the only local patch (Wine's compiler refuses the clamp/composer shaders).

without this PR with it
VRAM used (steady) 6.64-6.83 GB 6.0-6.53 GB
RSS 8.1 GB 5.8-9.1 GB
world frames sampled 18 25
median frame 288 ms 288 ms
90th percentile 712 ms 571 ms
best frames 132-146 ms 120-126 ms

So on 8 GB the spare pool no longer holds VRAM it cannot afford, and the worst frames get shorter; the median is unchanged in these two samples (different scenes, so treat that as indicative).

Context that may matter for #94: with the texture budget at 4608 MB the title still has ~43,000 textures (16.4 GB) waiting for a host copy, and the card plateaus around 6.5 GB either way. The freed half gigabyte is what let me keep the budget that high without running out; at 85 % it was already tight.

No game files or dumps; numbers only.

**@⁠YaBulochka** on GitHub · 2026-11-26 09:19 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/119#issuecomment-7187783156) Tested on an 8 GB card under Wine/RADV: the VRAM cap is real, and the tail of the frame time improves. **Setup:** Radeon RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, CachyOS kernel 7.3.5, your `main` `0ce46d5` + this branch, `x86_64-pc-windows-gnu`, `--features diagnostics`, retail 1.0.2.1, Series S, the launcher's profile (`VICTORY_RELAY=2`, `TEXTURE_NO_WAIT=1`, `JOIN_COPIES=1`, `CARD_STEPS=2`, `AMBIENT=0.8`, `PORT_DESCRIPTORS=1`), `VICTORY_TEXTURE_BUDGET_MB=4608`, `VICTORY_CARD_BUFFERS_MB=1024`. A `dxcompiler.dll` fallback for `D3DCompile` is the only local patch (Wine's compiler refuses the clamp/composer shaders). | | without this PR | with it | |---|---:|---:| | VRAM used (steady) | 6.64-6.83 GB | **6.0-6.53 GB** | | RSS | 8.1 GB | 5.8-9.1 GB | | world frames sampled | 18 | 25 | | median frame | 288 ms | 288 ms | | 90th percentile | 712 ms | **571 ms** | | best frames | 132-146 ms | **120-126 ms** | So on 8 GB the spare pool no longer holds VRAM it cannot afford, and the worst frames get shorter; the median is unchanged in these two samples (different scenes, so treat that as indicative). Context that may matter for #94: with the texture budget at 4608 MB the title still has ~43,000 textures (16.4 GB) waiting for a host copy, and the card plateaus around 6.5 GB either way. The freed half gigabyte is what let me keep the budget that high without running out; at 85 % it was already tight. No game files or dumps; numbers only.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/119/head:github-bot/gh-119'
git switch 'github-bot/gh-119'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-119'
git switch 'github-bot/gh-119'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-119'
git switch 'github-bot/gh-119'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-119'
git switch 'main'
git merge --squash 'github-bot/gh-119'
git switch 'main'
git merge --ff-only 'github-bot/gh-119'
git switch 'main'
git merge 'github-bot/gh-119'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.