gpu: auto-scale card buffer limits from local VRAM budget #42

Open
github-bot wants to merge 2 commits from github-bot/gh-42 into main AGit
Owner

@⁠fever308 on GitHub · 2026-11-24 20:48 UTC · original
fever308:feat/auto-vram-card-buffers → main · +114 −12 · 1 files · 2 commits · open

Summary

 card_limits()
-  (min_mb, max_mb) = (16, 512)
+  budget = host.video_memory().local_budget
+  (min_mb, max_mb) = match budget:
+    None | <= 12 GiB => (16, 512)
+    12..20 GiB       => (4, 2048)
+    >= 20 GiB        => (1, min(budget_mb / 4, 8192))
+  apply VICTORY_CARD_BUFFERS_MIN_MB / VICTORY_CARD_BUFFERS_MB overrides (saturating)

Evidence

  • Before: Every host adapter used fixed 16 MiB min / 512 MiB max card-buffer limits regardless of local VRAM budget.
    After:
    • cargo test -p victory-gpu card_limits_scale_with_local_vram_budget: 1 passed, 0 failed.
    • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
    • Verified on host GPUs: RTX 3090 (23,040 MiB budget -> 1 MiB / 5,760 MiB) and RTX 4080 16 GB (15,280 MiB budget -> 4 MiB / 2,048 MiB).

Merge Danger

Door: two-way

Pure default-limit heuristic in crates/victory-gpu/src/shadow.rs; explicit VICTORY_CARD_BUFFERS_MIN_MB / VICTORY_CARD_BUFFERS_MB overrides remain unchanged.

Blast Radius: Buffers

Higher-VRAM hosts promote more title memory buffers into card VRAM (up to 2x with shader-written "before" twins, still bounded by card_for's 80% VRAM budget check).

**@⁠fever308** on GitHub · 2026-11-24 20:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/42) `fever308:feat/auto-vram-card-buffers` → `main` · +114 −12 · 1 files · 2 commits · open ## Summary ```diff card_limits() - (min_mb, max_mb) = (16, 512) + budget = host.video_memory().local_budget + (min_mb, max_mb) = match budget: + None | <= 12 GiB => (16, 512) + 12..20 GiB => (4, 2048) + >= 20 GiB => (1, min(budget_mb / 4, 8192)) + apply VICTORY_CARD_BUFFERS_MIN_MB / VICTORY_CARD_BUFFERS_MB overrides (saturating) ``` ## Evidence - **Before:** Every host adapter used fixed `16 MiB` min / `512 MiB` max card-buffer limits regardless of local VRAM budget. **After:** - `cargo test -p victory-gpu card_limits_scale_with_local_vram_budget`: 1 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. - Verified on host GPUs: RTX 3090 (`23,040 MiB` budget -> `1 MiB / 5,760 MiB`) and RTX 4080 16 GB (`15,280 MiB` budget -> `4 MiB / 2,048 MiB`). ## Merge Danger **Door:** two-way Pure default-limit heuristic in `crates/victory-gpu/src/shadow.rs`; explicit `VICTORY_CARD_BUFFERS_MIN_MB` / `VICTORY_CARD_BUFFERS_MB` overrides remain unchanged. **Blast Radius:** Buffers Higher-VRAM hosts promote more title memory buffers into card VRAM (up to 2x with shader-written "before" twins, still bounded by `card_for`'s 80% VRAM budget check).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:05 +00:00
Author
Owner

@⁠viktoschi on GitHub · 2026-11-24 21:05 UTC · original

Tested this branch on the tier the new thresholds are written for: RTX 3090 (24 GB, driver 591.86), Windows 11, Rust 1.98.1 (the pinned toolchain), fffafee.

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
  • cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored (victory-gpu: 111 passed, 1 ignored; the GPU tests ran on the card)

What the formula picks here: the adapter reports a local budget of 24,159,346,688 B (23,040 MiB, ~22.5 GiB), so default_card_limits_mb takes the >= 20 GiB tier and returns 1 MiB / 5,760 MiB instead of 16 / 512.

One question on the thresholds: 22.5 GiB is what DXGI reports for a 24 GB card here, not 24 GiB, and Budget is dynamic — a 24 GB card with another title holding memory can drop below 20 GiB and land in the 16 GB tier. Is that intended, or should the tier be read from dedicated video memory rather than the budget?

**@⁠viktoschi** on GitHub · 2026-11-24 21:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/42#issuecomment-7144451872) Tested this branch on the tier the new thresholds are written for: RTX 3090 (24 GB, driver 591.86), Windows 11, Rust 1.98.1 (the pinned toolchain), `fffafee`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo test --workspace --locked`: 497 passed, 0 failed, 7 ignored (`victory-gpu`: 111 passed, 1 ignored; the GPU tests ran on the card) What the formula picks here: the adapter reports a local budget of 24,159,346,688 B (23,040 MiB, ~22.5 GiB), so `default_card_limits_mb` takes the `>= 20 GiB` tier and returns **1 MiB / 5,760 MiB** instead of 16 / 512. One question on the thresholds: 22.5 GiB is what DXGI reports for a 24 GB card here, not 24 GiB, and `Budget` is dynamic — a 24 GB card with another title holding memory can drop below 20 GiB and land in the 16 GB tier. Is that intended, or should the tier be read from dedicated video memory rather than the budget?
Author
Owner

@⁠fever308 on GitHub · 2026-11-24 21:10 UTC · original

@⁠viktoschi Thank you for testing this on an RTX 3090 and reporting the exact numbers!

Using DXGI_QUERY_VIDEO_MEMORY_INFO.Budget rather than raw DedicatedVideoMemory is intentional: Budget reflects what WDDM is actually making available to this process, so if another GPU-heavy app is occupying VRAM and pushes a 24 GB card's available budget below 20 GiB, stepping down to the 16 GB tier (4 MiB / 2,048 MiB) avoids overcommitting past the OS budget (especially since shader-written card buffers can take up to 2× with their "before" twins) and forcing paging to system RAM.

For the exact same WDDM-headroom reason you noted (~22.5 GiB reported on a 24 GB card), I just pushed de4ae61 lowering the 12 GB -> 16 GB boundary from 14 GiB to 12 GiB so 16 GB cards (~13.5–15 GiB WDDM budget) don't fall back into the 12 GB tier under light desktop usage. Explicit VICTORY_CARD_BUFFERS_MIN_MB / VICTORY_CARD_BUFFERS_MB overrides remain available if someone wants a fixed cap independent of dynamic budget.

**@⁠fever308** on GitHub · 2026-11-24 21:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/42#issuecomment-7144586130) @⁠viktoschi Thank you for testing this on an RTX 3090 and reporting the exact numbers! Using `DXGI_QUERY_VIDEO_MEMORY_INFO.Budget` rather than raw `DedicatedVideoMemory` is intentional: `Budget` reflects what WDDM is actually making available to this process, so if another GPU-heavy app is occupying VRAM and pushes a 24 GB card's available budget below 20 GiB, stepping down to the 16 GB tier (`4 MiB` / `2,048 MiB`) avoids overcommitting past the OS budget (especially since shader-written card buffers can take up to 2× with their "before" twins) and forcing paging to system RAM. For the exact same WDDM-headroom reason you noted (~22.5 GiB reported on a 24 GB card), I just pushed `de4ae61` lowering the 12 GB -> 16 GB boundary from `14 GiB` to `12 GiB` so 16 GB cards (~13.5–15 GiB WDDM budget) don't fall back into the 12 GB tier under light desktop usage. Explicit `VICTORY_CARD_BUFFERS_MIN_MB` / `VICTORY_CARD_BUFFERS_MB` overrides remain available if someone wants a fixed cap independent of dynamic budget.
Author
Owner

@⁠arminkhaleghirod on GitHub · 2026-11-24 21:18 UTC · original

Tested fffafee on an RTX 4080 16 GB, Windows 11, Series X profile, no env overrides. It logs vram_budget_mb=15280 card_buffers_min_mb=4 card_buffers_max_mb=2048, the 16 GB tier as intended. 5.5 min from boot into the opening cutscene. City renders, no device loss, 0.7–2.4 fps in the cutscene.

**@⁠arminkhaleghirod** on GitHub · 2026-11-24 21:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/42#issuecomment-7144751573) Tested fffafee on an RTX 4080 16 GB, Windows 11, Series X profile, no env overrides. It logs `vram_budget_mb=15280 card_buffers_min_mb=4 card_buffers_max_mb=2048`, the 16 GB tier as intended. 5.5 min from boot into the opening cutscene. City renders, no device loss, 0.7–2.4 fps in the cutscene.
Author
Owner

@⁠fever308 on GitHub · 2026-11-24 21:22 UTC · original

@⁠arminkhaleghirod Thank you for testing on an RTX 4080 16 GB and sharing the live run log! Great to see vram_budget_mb=15280 hitting the 4 MiB / 2048 MiB tier cleanly with no device loss into the cutscene.

**@⁠fever308** on GitHub · 2026-11-24 21:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/42#issuecomment-7144835764) @⁠arminkhaleghirod Thank you for testing on an RTX 4080 16 GB and sharing the live run log! Great to see `vram_budget_mb=15280` hitting the `4 MiB / 2048 MiB` tier cleanly with no device loss into the cutscene.
github-bot force-pushed github-bot/gh-42 from 20481d2a36 to 4d30f983ad 2026-11-26 07:27:01 +00:00 Compare
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/42/head:github-bot/gh-42'
git switch 'github-bot/gh-42'

Merge

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