gpu(resource): guard real VRAM budget margin in room() #144

Merged
Androtim merged 2 commits from upstream-pr/144 into main 2026-11-29 21:26:59 +00:00
Androtim commented 2026-11-29 15:28:11 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T15:28:11Z.


Guards resource::room() against fragmented-block over-commitment in crates/victory-gpu/src/resource.rs:

  • Adds real_budget_blocks, room_allowed, and VICTORY_ROOM_REAL (default on; =0 disables) with REAL_MARGIN = 256 MiB so fragmented free space inside existing texture blocks does not permit new texture allocations once process VRAM usage is within 256 MiB of budget (or over it).
  • Preserves existing weighed(budget, used) < room_line(budget) headroom checks.
  • Adds unit test real_budget_blocks_near_or_over_vram_budget.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (304 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu resource:: --locked (28 passed; 0 failed)
  • Dual cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets (--locked and --features diagnostics --locked, -D warnings)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5552186461 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/144). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T15:28:11Z. --- Guards `resource::room()` against fragmented-block over-commitment in `crates/victory-gpu/src/resource.rs`: - Adds `real_budget_blocks`, `room_allowed`, and `VICTORY_ROOM_REAL` (default on; `=0` disables) with `REAL_MARGIN = 256 MiB` so fragmented free space inside existing texture blocks does not permit new texture allocations once process VRAM usage is within 256 MiB of budget (or over it). - Preserves existing `weighed(budget, used) < room_line(budget)` headroom checks. - Adds unit test `real_budget_blocks_near_or_over_vram_budget`. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`304 files ok`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu resource:: --locked` (`28 passed; 0 failed`) - Dual `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets` (`--locked` and `--features diagnostics --locked`, `-D warnings`)
Androtim commented 2026-11-29 16:05:06 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T16:05:06Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

Logic, arithmetic safety, and unit test coverage look solid, and CI is passing. Because this changes default VRAM budget/eviction gating (VICTORY_ROOM_REAL on by default), it warrants a local real-GPU smoke test before merging.

Verified Changes (crates/victory-gpu/src/resource.rs)

  • room() / real_budget_blocks() / room_allowed(): When weighed_with(..., false) < room_line(budget) only succeeds while free = crate::pool::texture_room() > 0 and used >= budget.saturating_sub(REAL_MARGIN) (256 MiB), VICTORY_ROOM_REAL (default on; =0 disables) refuses new texture allocations and logs rate-limited telemetry (ROOM_REAL, first hit and every 20,000th). Existing VICTORY_TEXTURE_BUDGET_MB and texture_floor_bytes early returns remain intact.
  • weighed() / weighed_with() / weighed_bytes(): Applies the same REAL_MARGIN condition when VICTORY_ROOM_REAL is enabled, raising weighed pressure to used.saturating_add(kept).max(line) so let_go_idle() and room_terms() stay consistent with room() and can evict idle textures rather than stalling.
  • Safety & Tests: All boundary math uses saturating operations (saturating_sub / saturating_add), and real_budget_blocks_near_or_over_vram_budget covers normal headroom, free == 0, the inclusive 256 MiB boundary, over-budget, toggle off, credited == false, and 0 / u64::MAX extremes.

Note

  • Complementary to open PR #153 (pool hole reuse / 8 GiB room tier); if both are tested or merged, verify interaction between pool hole reuse (free > 0) and VICTORY_ROOM_REAL near budget.
  • Note that this is an automated technical review and does not constitute formal maintainer approval.

Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7258603839 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/144#issuecomment-7258603839). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T16:05:06Z. --- <!-- minivi-triage v1 head=be71a80d69403e0fb391043108513d7fadeb0139 verdict=needs-gpu-test ci=passing at=2026-11-29T19:05:03Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Logic, arithmetic safety, and unit test coverage look solid, and CI is passing. Because this changes default VRAM budget/eviction gating (`VICTORY_ROOM_REAL` on by default), it warrants a local real-GPU smoke test before merging. ### Verified Changes (`crates/victory-gpu/src/resource.rs`) - **`room()` / `real_budget_blocks()` / `room_allowed()`**: When `weighed_with(..., false) < room_line(budget)` only succeeds while `free = crate::pool::texture_room() > 0` and `used >= budget.saturating_sub(REAL_MARGIN)` (`256 MiB`), `VICTORY_ROOM_REAL` (default on; `=0` disables) refuses new texture allocations and logs rate-limited telemetry (`ROOM_REAL`, first hit and every 20,000th). Existing `VICTORY_TEXTURE_BUDGET_MB` and `texture_floor_bytes` early returns remain intact. - **`weighed()` / `weighed_with()` / `weighed_bytes()`**: Applies the same `REAL_MARGIN` condition when `VICTORY_ROOM_REAL` is enabled, raising weighed pressure to `used.saturating_add(kept).max(line)` so `let_go_idle()` and `room_terms()` stay consistent with `room()` and can evict idle textures rather than stalling. - **Safety & Tests**: All boundary math uses saturating operations (`saturating_sub` / `saturating_add`), and `real_budget_blocks_near_or_over_vram_budget` covers normal headroom, `free == 0`, the inclusive 256 MiB boundary, over-budget, toggle off, `credited == false`, and `0` / `u64::MAX` extremes. ### Note - Complementary to open PR #153 (pool hole reuse / 8 GiB room tier); if both are tested or merged, verify interaction between pool hole reuse (`free > 0`) and `VICTORY_ROOM_REAL` near budget. - Note that this is an automated technical review and does not constitute formal maintainer approval. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-29 18:08:23 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T18:08:23Z.


Rebased onto origin/main (9d8b3646, including #140 and #145/#147) and addressed all minivi-triage findings at be71a80d:

  1. Checked texture_room() > 0 before attributing credit to block headroom (crates/victory-gpu/src/resource.rs):
    • Tightened real_budget_blocks(credited, free_in_blocks, budget, used) to require free_in_blocks > 0, so budgets/lines where free_in_blocks == 0 no longer trigger the guard or log "by free space in texture blocks alone".
  2. Kept weighed() / let_go_idle() symmetrical with room():
    • Added pure weighed_bytes(budget, used, free, kept, line, room_real_on) used by weighed() (weighed_with): whenever VICTORY_ROOM_REAL blocks new allocations due to fragmented block free space near/over budget, weighed() returns used.saturating_add(kept).max(line) (>= room_line(budget)), ensuring let_go_idle() / vram_keep_below() sees the same pressure and sweeps idle textures instead of stalling room().
    • Updated real_budget_blocks_near_or_over_vram_budget unit test to cover free == 0, fragmented block credit vs normal headroom, VICTORY_ROOM_REAL=0 opt-out, weighed_bytes symmetry with let_go_idle(), and u64::MAX/0 boundaries.

Local Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: 305 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- resource::: 28 passed; 0 failed
  • Dual workspace clippy --all-targets -- -D warnings (default and --features diagnostics): 0 warnings
<!-- greyfinch-sync:Androtim/MiniVI:comment:7260242756 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/144#issuecomment-7260242756). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T18:08:23Z. --- Rebased onto `origin/main` (`9d8b3646`, including `#140` and `#145`/`#147`) and addressed all `minivi-triage` findings at `be71a80d`: 1. **Checked `texture_room() > 0` before attributing credit to block headroom (`crates/victory-gpu/src/resource.rs`):** - Tightened `real_budget_blocks(credited, free_in_blocks, budget, used)` to require `free_in_blocks > 0`, so budgets/lines where `free_in_blocks == 0` no longer trigger the guard or log `"by free space in texture blocks alone"`. 2. **Kept `weighed()` / `let_go_idle()` symmetrical with `room()`:** - Added pure `weighed_bytes(budget, used, free, kept, line, room_real_on)` used by `weighed()` (`weighed_with`): whenever `VICTORY_ROOM_REAL` blocks new allocations due to fragmented block free space near/over budget, `weighed()` returns `used.saturating_add(kept).max(line)` (`>= room_line(budget)`), ensuring `let_go_idle()` / `vram_keep_below()` sees the same pressure and sweeps idle textures instead of stalling `room()`. - Updated `real_budget_blocks_near_or_over_vram_budget` unit test to cover `free == 0`, fragmented block credit vs normal headroom, `VICTORY_ROOM_REAL=0` opt-out, `weighed_bytes` symmetry with `let_go_idle()`, and `u64::MAX`/`0` boundaries. ### Local Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: `305 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- resource::`: `28 passed; 0 failed` - Dual workspace `clippy --all-targets -- -D warnings` (default and `--features diagnostics`): 0 warnings
Androtim commented 2026-11-29 21:26:56 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T21:26:56Z.


Automated RTX 4060 Ti 8 GB Open-World A/B hardware verification PASSED (playtest/wave5 vs origin/main b1b6dc1, VICTORY_LEVELS_ON_DEMAND=0 play-parity):

  • Hardware cargo test (RTX 4060 Ti): 645 passed, 0 failed (victory 39/39, victory-shader emit::wave64_tests 19/19 & lower 19/19, victory-gpu 568/568).
  • 45s Open-World A/B (scripts/verify-world.ps1, DLSS Quality + open-world save):
    • FPS: median 9.4 fps vs 7.5 fps (+1.90 fps / +25%), min 8.3 fps vs 0.8 fps, preparing 53.6 ms vs 60.0 ms
    • Stability: 0 crashes / 0 DRED / 0 untranslated shaders
    • VRAM / Issue #149: max 5760 MB vs 6005 MB (-245 MB, 0 MB over budget); no room for new ones halved (9,000 vs 18,000); max_waiting dropped (36,432 vs 41,431)
    • Decoration bakes / Issue #150: 0 mismatches (other_bytes=0, showed_another_view=0, failed=0 vs 5 and 2 on baseline)
    • Residency stalls: mapped_rate 1.63 ms/s vs 6.9 ms/s (-76%, max 12.9 vs 51.9 ms)
    • Visual check: Clean open-world safehouse frames (frame-5975.png, frame-5983.png), edge_energy=4.69 vs 3.88, near_black=0.02%, magenta=0.0% (and #141 2bf6800 showed zero visual artifacts).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7262883330 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/144#issuecomment-7262883330). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T21:26:56Z. --- Automated RTX 4060 Ti 8 GB **Open-World** A/B hardware verification **PASSED** (`playtest/wave5` vs `origin/main` `b1b6dc1`, `VICTORY_LEVELS_ON_DEMAND=0` play-parity): - **Hardware `cargo test` (RTX 4060 Ti):** **645 passed, 0 failed** (`victory` 39/39, `victory-shader` `emit::wave64_tests` 19/19 & `lower` 19/19, `victory-gpu` 568/568). - **45s Open-World A/B (`scripts/verify-world.ps1`, DLSS Quality + open-world save):** - **FPS:** median **`9.4 fps`** vs `7.5 fps` (**+1.90 fps / +25%**), min **`8.3 fps`** vs **`0.8 fps`**, preparing `53.6 ms` vs `60.0 ms` - **Stability:** **0** crashes / **0** DRED / **0** untranslated shaders - **VRAM / Issue #149:** max **`5760 MB`** vs `6005 MB` (**-245 MB**, `0 MB` over budget); `no room for new ones` halved (**`9,000`** vs `18,000`); `max_waiting` dropped (`36,432` vs `41,431`) - **Decoration bakes / Issue #150:** **`0` mismatches** (`other_bytes=0, showed_another_view=0, failed=0` vs `5` and `2` on baseline) - **Residency stalls:** `mapped_rate` **`1.63 ms/s`** vs `6.9 ms/s` (**-76%**, max `12.9` vs `51.9 ms`) - **Visual check:** Clean open-world safehouse frames (`frame-5975.png`, `frame-5983.png`), `edge_energy=4.69` vs `3.88`, `near_black=0.02%`, `magenta=0.0%` (and `#141` `2bf6800` showed zero visual artifacts).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Androtim/MiniVI!144
No description provided.