GPU: fix VRAM eviction monotonicity, texture-pool fragmentation masking, and sweep spikes #223

Open
github-bot wants to merge 2 commits from github-bot/gh-223 into a-publier AGit
Owner

@⁠zaixiakongyiji on GitHub · 2026-11-26 03:45 UTC · original
zaixiakongyiji:gpu/rx9070xt-vram-hysteresis → a-publier · +1328 −150 · 3 files · 2 commits · open

Problem

On 16 GB cards (e.g. Radeon RX 9070 XT with a 13.6-15.4 GiB DXGI local budget), long sessions (70+ minutes of streaming) hit three interacting VRAM-management failure modes:

  1. Non-monotonic >= 93% eviction target, 85..90% admit/evict overlap, and pool-fragmentation masking (host.rs, resource.rs):
    • In vram_keep, the >= 93% hard tier previously targeted used - share(84) while 85%..93% targeted used - share(80), evicting less at 93% than at 92%.
    • room_percent() defaulted to 90% while soft eviction started at 85%, so the queue kept admitting between 85% and 90% while the sweep tried to evict down to 80%.
    • effective_vram_usage subtracted all free bytes across non-empty 64 MiB texture-pool blocks without bound. After 70+ minutes, ~1.6 GiB of scattered holes across partially occupied 64 MiB blocks kept computed effective_used below the soft eviction line (idle_ms = 600_000) even while physical LOCAL.used exceeded 90%+ (12,322 / 13,579 MiB), starving buffer allocations and stalling streaming.
  2. First-fit sub-allocation preventing tail 64 MiB blocks from draining (pool.rs):
    • Sub-allocating from whichever block came first spread new textures across low-occupancy tail blocks, preventing them from draining back to whole(BLOCK) and returning physical VRAM to WDDM.
  3. Full-table let_go_idle frame-time spikes & stale host.used timestamps (resource.rs):
    • Evicting a texture's host copy left r.host.used non-zero, so every subsequent pressured let_go_idle pass re-locked made on already-evicted entries across 150k+ resources (10.87 ms avg, 30.4 ms max per sweep).

Changes

  1. crates/victory-gpu/src/host.rs:
    • Lower VRAM_TARGET_HARD_PCT to 76% (VRAM_EVICT_SOFT_PCT = 85, VRAM_EVICT_HARD_PCT = 93, VRAM_TARGET_SOFT_PCT = 80, SHORT_MS = 3_000) so eviction targets increase monotonically across 85%..=120%, and update vram_keep's doc comment.
    • Add vram_keep_with_raw + note_raw_local_vram (wired in sweep() and Host::video_memory()) with an 86% -> 82% raw LOCAL.used hysteresis guardrail so fragmented pool holes cannot suppress cold-texture eviction as physical VRAM nears exhaustion.
  2. crates/victory-gpu/src/pool.rs:
    • Track free bytes per block and rank candidates by higher occupancy and smallest sufficient free span (best_fit / pick_candidate) so low-occupancy tail 64 MiB heaps drain to whole(BLOCK).
    • Expose spare_and_fragmented_room() and has_reusable_hole(size, alignment), drop empty-block retention to 0 under raw high-VRAM hysteresis, and restrict pool::texture() to zero-WDDM non-empty hole reuse when new WDDM heaps are blocked.
  3. crates/victory-gpu/src/resource.rs:
    • Match DEFAULT_TEXTURE_ROOM_PCT directly to VRAM_EVICT_SOFT_PCT (85%) so 5 s eviction toward 80% starts at the exact boundary where room() pauses new admission (eliminating both the 85..90% admit/evict overlap and any dead band where waiting textures sit below the 5 s eviction threshold).
    • Give full credit to whole-empty 64 MiB blocks while capping non-empty fragmented + tile-pool credit at 256 MiB (0 under raw high pressure) via compute_vram_pressure / room_allows_with_pool_hole (allowing zero-WDDM hole reuse below 88% raw while deferring standalone committed textures via HostTextureOutcome::Deferred without setting refused).
    • Reset r.host.used to 0 under made's lock in want_level and let_go_idle, count SWEPT_US on cooldown-skipped looks as well, and bound pressured let_go_idle scans to a rolling 16,384-entry window, 2,048 lock checks, and a 4 MiB progress floor before a 2,000 ms cooldown (10.87 ms -> 2.04 ms avg in 154k-texture city streaming).

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
  • cargo test -p victory-gpu --locked & cargo test -p victory-gpu --features diagnostics --locked: 453 + 1 passed, 0 failed (9 unit tests covering vram_keep monotonicity/hysteresis, zero dead-band admission/eviction handoff, pool best-fit draining & non-empty hole reuse, 74-minute fragmentation pressure snapshot, eviction safety guardrails, and rolling sweep cooldown).
**@⁠zaixiakongyiji** on GitHub · 2026-11-26 03:45 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/223) `zaixiakongyiji:gpu/rx9070xt-vram-hysteresis` → `a-publier` · +1328 −150 · 3 files · 2 commits · open ### Problem On 16 GB cards (e.g. Radeon RX 9070 XT with a 13.6-15.4 GiB DXGI local budget), long sessions (70+ minutes of streaming) hit three interacting VRAM-management failure modes: 1. **Non-monotonic `>= 93%` eviction target, `85..90%` admit/evict overlap, and pool-fragmentation masking (`host.rs`, `resource.rs`)**: - In `vram_keep`, the `>= 93%` hard tier previously targeted `used - share(84)` while `85%..93%` targeted `used - share(80)`, evicting *less* at 93% than at 92%. - `room_percent()` defaulted to `90%` while soft eviction started at `85%`, so the queue kept admitting between 85% and 90% while the sweep tried to evict down to 80%. - `effective_vram_usage` subtracted all free bytes across non-empty 64 MiB texture-pool blocks without bound. After 70+ minutes, ~1.6 GiB of scattered holes across partially occupied 64 MiB blocks kept computed `effective_used` below the soft eviction line (`idle_ms = 600_000`) even while physical `LOCAL.used` exceeded 90%+ (`12,322 / 13,579 MiB`), starving buffer allocations and stalling streaming. 2. **First-fit sub-allocation preventing tail 64 MiB blocks from draining (`pool.rs`)**: - Sub-allocating from whichever block came first spread new textures across low-occupancy tail blocks, preventing them from draining back to `whole(BLOCK)` and returning physical VRAM to WDDM. 3. **Full-table `let_go_idle` frame-time spikes & stale `host.used` timestamps (`resource.rs`)**: - Evicting a texture's host copy left `r.host.used` non-zero, so every subsequent pressured `let_go_idle` pass re-locked `made` on already-evicted entries across 150k+ resources (`10.87 ms` avg, `30.4 ms` max per sweep). ### Changes 1. **`crates/victory-gpu/src/host.rs`**: - Lower `VRAM_TARGET_HARD_PCT` to `76%` (`VRAM_EVICT_SOFT_PCT = 85`, `VRAM_EVICT_HARD_PCT = 93`, `VRAM_TARGET_SOFT_PCT = 80`, `SHORT_MS = 3_000`) so eviction targets increase monotonically across `85%..=120%`, and update `vram_keep`'s doc comment. - Add `vram_keep_with_raw` + `note_raw_local_vram` (wired in `sweep()` and `Host::video_memory()`) with an `86% -> 82%` raw `LOCAL.used` hysteresis guardrail so fragmented pool holes cannot suppress cold-texture eviction as physical VRAM nears exhaustion. 2. **`crates/victory-gpu/src/pool.rs`**: - Track free bytes per block and rank candidates by higher occupancy and smallest sufficient free span (`best_fit` / `pick_candidate`) so low-occupancy tail 64 MiB heaps drain to `whole(BLOCK)`. - Expose `spare_and_fragmented_room()` and `has_reusable_hole(size, alignment)`, drop empty-block retention to `0` under raw high-VRAM hysteresis, and restrict `pool::texture()` to zero-WDDM non-empty hole reuse when new WDDM heaps are blocked. 3. **`crates/victory-gpu/src/resource.rs`**: - Match `DEFAULT_TEXTURE_ROOM_PCT` directly to `VRAM_EVICT_SOFT_PCT` (`85%`) so 5 s eviction toward 80% starts at the exact boundary where `room()` pauses new admission (eliminating both the `85..90%` admit/evict overlap and any dead band where waiting textures sit below the 5 s eviction threshold). - Give full credit to whole-empty 64 MiB blocks while capping non-empty fragmented + tile-pool credit at `256 MiB` (`0` under raw high pressure) via `compute_vram_pressure` / `room_allows_with_pool_hole` (allowing zero-WDDM hole reuse below 88% raw while deferring standalone committed textures via `HostTextureOutcome::Deferred` without setting `refused`). - Reset `r.host.used` to `0` under `made`'s lock in `want_level` and `let_go_idle`, count `SWEPT_US` on cooldown-skipped looks as well, and bound pressured `let_go_idle` scans to a rolling `16,384`-entry window, `2,048` lock checks, and a `4 MiB` progress floor before a `2,000 ms` cooldown (`10.87 ms -> 2.04 ms` avg in 154k-texture city streaming). ### Verification - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean - `cargo test -p victory-gpu --locked` & `cargo test -p victory-gpu --features diagnostics --locked`: 453 + 1 passed, 0 failed (9 unit tests covering `vram_keep` monotonicity/hysteresis, zero dead-band admission/eviction handoff, `pool` best-fit draining & non-empty hole reuse, 74-minute fragmentation pressure snapshot, eviction safety guardrails, and rolling sweep cooldown).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:01:16 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 22:41 UTC · original

Checked by reading the code on a-publier cd8dfc0 (head 73626bf, change 81ebb7b..73626bf); I did not build or run it.

Rebase:

  • 81ebb7b..73626bf does not apply cleanly to cd8dfc0. host.rs conflicts in vram_keep and in its test. resource.rs merges cleanly.
  • cd8dfc0 already moved the same thresholds to 85 / 93, with targets 80 / 84 and SHORT_MS 3,000 (host.rs:171-181). The PR's 82 / 90 / 78 / 74 and its test values (5,000 / 1,500 ms, 16 GiB at 90%) would need to be chosen again on top of those numbers.
  • a-publier has since moved to 4eb6cfd. None of the merges since cd8dfc0 touch vram_keep, room_percent() or resource.rs, so the numbers below are the same there, and the change conflicts in host.rs the same way.

Both problems in the description are still there on cd8dfc0:

  • Hard target: 85-93% evicts used - share(80) and 93% and up evicts used - share(84) (host.rs:178-181). At 92% that is 12% of the budget. At 93% it is 9%. The base test asserts this: (3_000, 11 GiB) at 95% (host.rs:11416), less than the 12 GiB at 92%. With a soft target of 80, any hard target above 80 makes the bytes to evict drop at 93%.
  • Overlap: room_percent() is still 90 (resource.rs:1863-1869) and soft eviction starts at 85 (host.rs:176). room() (resource.rs:1774) and let_go_idle() (resource.rs:2136-2141) use the same usage figure. So between 85% and 90% the queue keeps admitting while the sweep works down to 80%.
  • The vram_keep doc on cd8dfc0 still says 88 % / 85 % (host.rs:161-162). The rebase could update it to the new numbers.

Concern with DEFAULT_TEXTURE_ROOM_PCT = VRAM_EVICT_SOFT_PCT - 2 (from reading):

  • The PR as written leaves a 2% band (80 vs 82) where admission has stopped and the 5 s eviction has not started. After a rebase it gives 83 against a soft start of 85. On a 19,653 MB budget, admission stops at about 16,312 MB (today about 17,688 MB) and eviction starts at about 16,705 MB.
  • Below the soft start, vram_keep returns (600_000, u64::MAX), so the sweep only lets go of copies idle 10 minutes or more.
  • When room() is false, new heap textures are refused (draw.rs:2297, 2533-2537). Held levels are not asked for again (texture.rs:782). keep_shown stops (descriptor/host.rs:2363, 3343, 3373).
  • So if the texture queue is what fills the card, usage can sit in that band with textures waiting while the sweep frees only copies that reach 10 minutes idle.
  • The comment the PR removes (resource.rs:1855-1861 on cd8dfc0) says that at 90 about a tenth of the budget stayed unused while thousands of textures waited (runs 170-174), and suggests 94. Going below 90 moves the other way.
  • One option: keep admission at or above the eviction start, or start the 5 s eviction where room() stops admitting.

Small things:

  • assert!(DEFAULT_TEXTURE_ROOM_PCT < crate::host::VRAM_EVICT_SOFT_PCT) (resource.rs:4589 on the PR head) compares two constants. From reading, I expect clippy's assertions_on_constants to flag it. I did not run clippy. CI runs clippy with --all-targets -- -D warnings on Windows (ci.yml:29, 31), so if it is flagged the Clippy job fails. const { assert!(..) } avoids it, as descriptor/host.rs:61 already does.
  • EMPTY_PRESSURE_SWEEP_COOLDOWN_MS (resource.rs:2018 on the PR head) sits between let_go_idle's doc comment (from 1996) and the function (2042). Rustdoc attaches most of that comment to the const.
  • A skipped sweep returns (resource.rs:2075 on the PR head) before SWEPT_US is counted (2172). So the sweep counters no longer include those calls.

Not checked: build, unit tests and clippy on a rebased branch; in-world behaviour at 12-18 GB VRAM.

**@⁠adrianmjim** on GitHub · 2026-11-26 22:41 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/223#issuecomment-7204908865) Checked by reading the code on a-publier cd8dfc0 (head 73626bf, change 81ebb7b..73626bf); I did not build or run it. Rebase: - 81ebb7b..73626bf does not apply cleanly to cd8dfc0. `host.rs` conflicts in `vram_keep` and in its test. `resource.rs` merges cleanly. - cd8dfc0 already moved the same thresholds to 85 / 93, with targets 80 / 84 and `SHORT_MS` 3,000 (host.rs:171-181). The PR's 82 / 90 / 78 / 74 and its test values (5,000 / 1,500 ms, 16 GiB at 90%) would need to be chosen again on top of those numbers. - a-publier has since moved to 4eb6cfd. None of the merges since cd8dfc0 touch `vram_keep`, `room_percent()` or `resource.rs`, so the numbers below are the same there, and the change conflicts in `host.rs` the same way. Both problems in the description are still there on cd8dfc0: - Hard target: 85-93% evicts `used - share(80)` and 93% and up evicts `used - share(84)` (host.rs:178-181). At 92% that is 12% of the budget. At 93% it is 9%. The base test asserts this: `(3_000, 11 GiB)` at 95% (host.rs:11416), less than the 12 GiB at 92%. With a soft target of 80, any hard target above 80 makes the bytes to evict drop at 93%. - Overlap: `room_percent()` is still 90 (resource.rs:1863-1869) and soft eviction starts at 85 (host.rs:176). `room()` (resource.rs:1774) and `let_go_idle()` (resource.rs:2136-2141) use the same usage figure. So between 85% and 90% the queue keeps admitting while the sweep works down to 80%. - The `vram_keep` doc on cd8dfc0 still says 88 % / 85 % (host.rs:161-162). The rebase could update it to the new numbers. Concern with `DEFAULT_TEXTURE_ROOM_PCT = VRAM_EVICT_SOFT_PCT - 2` (from reading): - The PR as written leaves a 2% band (80 vs 82) where admission has stopped and the 5 s eviction has not started. After a rebase it gives 83 against a soft start of 85. On a 19,653 MB budget, admission stops at about 16,312 MB (today about 17,688 MB) and eviction starts at about 16,705 MB. - Below the soft start, `vram_keep` returns `(600_000, u64::MAX)`, so the sweep only lets go of copies idle 10 minutes or more. - When `room()` is false, new heap textures are refused (draw.rs:2297, 2533-2537). Held levels are not asked for again (texture.rs:782). `keep_shown` stops (descriptor/host.rs:2363, 3343, 3373). - So if the texture queue is what fills the card, usage can sit in that band with textures waiting while the sweep frees only copies that reach 10 minutes idle. - The comment the PR removes (resource.rs:1855-1861 on cd8dfc0) says that at 90 about a tenth of the budget stayed unused while thousands of textures waited (runs 170-174), and suggests 94. Going below 90 moves the other way. - One option: keep admission at or above the eviction start, or start the 5 s eviction where `room()` stops admitting. Small things: - `assert!(DEFAULT_TEXTURE_ROOM_PCT < crate::host::VRAM_EVICT_SOFT_PCT)` (resource.rs:4589 on the PR head) compares two constants. From reading, I expect clippy's `assertions_on_constants` to flag it. I did not run clippy. CI runs clippy with `--all-targets -- -D warnings` on Windows (ci.yml:29, 31), so if it is flagged the Clippy job fails. `const { assert!(..) }` avoids it, as descriptor/host.rs:61 already does. - `EMPTY_PRESSURE_SWEEP_COOLDOWN_MS` (resource.rs:2018 on the PR head) sits between `let_go_idle`'s doc comment (from 1996) and the function (2042). Rustdoc attaches most of that comment to the const. - A skipped sweep returns (resource.rs:2075 on the PR head) before `SWEPT_US` is counted (2172). So the sweep counters no longer include those calls. Not checked: build, unit tests and clippy on a rebased branch; in-world behaviour at 12-18 GB VRAM.
github-bot changed title from GPU: align texture room_percent below vram_keep and fix >=90% eviction target to GPU: fix VRAM eviction monotonicity, texture-pool fragmentation masking, and sweep spikes 2026-11-27 15:14:21 +00:00
github-bot changed target branch from rx9070xt to a-publier 2026-11-27 15:14:21 +00:00
github-bot force-pushed github-bot/gh-223 from 73626bfcfd to 6be0fe3c72 2026-11-27 15:14:22 +00:00 Compare
Author
Owner

@⁠zaixiakongyiji on GitHub · 2026-11-27 15:13 UTC · original

Rebased onto a-publier (4eb6cfd), retargeted the base branch from rx9070xt to a-publier, and addressed every item from @⁠adrianmjim's review (thank you for the detailed catch!):

  • Thresholds on a-publier: Kept 85 / 93 and SHORT_MS = 3_000, lowered the hard eviction target from 84% to 76% (VRAM_TARGET_SOFT_PCT = 80, VRAM_TARGET_HARD_PCT = 76) so eviction bytes increase monotonically across the 92% -> 93% boundary, and updated vram_keep's doc comment.
  • No dead band between room() and 5 s eviction: Changed DEFAULT_TEXTURE_ROOM_PCT to match VRAM_EVICT_SOFT_PCT (85%) directly instead of VRAM_EVICT_SOFT_PCT - 2, so 5 s eviction toward 80% starts at the exact byte boundary where room() pauses admission (and kept the runs 170-174 note on room_percent()).
  • Clippy / rustdoc / SWEPT_US nits: Used const { assert!(..) }, kept let_go_idle's doc comment attached directly to let_go_idle rather than EMPTY_PRESSURE_SWEEP_COOLDOWN_MS, and recorded SWEPT_US on cooldown-skipped let_go_idle calls too.
  • Follow-up fixes from 70+ min RX 9070 XT runs: Added bounded fragmentation credit + raw LOCAL.used 86% -> 82% hysteresis (pool.rs best-fit block clustering + spare_and_fragmented_room()) and bounded rolling 16,384-entry sweeps + r.host.used = 0 eviction reset (10.87 ms -> 2.04 ms avg over 154k textures).
**@⁠zaixiakongyiji** on GitHub · 2026-11-27 15:13 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/223#issuecomment-7221792415) Rebased onto `a-publier` (`4eb6cfd`), retargeted the base branch from `rx9070xt` to `a-publier`, and addressed every item from @⁠adrianmjim's review (thank you for the detailed catch!): - **Thresholds on `a-publier`**: Kept `85 / 93` and `SHORT_MS = 3_000`, lowered the hard eviction target from `84%` to `76%` (`VRAM_TARGET_SOFT_PCT = 80`, `VRAM_TARGET_HARD_PCT = 76`) so eviction bytes increase monotonically across the `92% -> 93%` boundary, and updated `vram_keep`'s doc comment. - **No dead band between `room()` and 5 s eviction**: Changed `DEFAULT_TEXTURE_ROOM_PCT` to match `VRAM_EVICT_SOFT_PCT` (`85%`) directly instead of `VRAM_EVICT_SOFT_PCT - 2`, so 5 s eviction toward 80% starts at the exact byte boundary where `room()` pauses admission (and kept the `runs 170-174` note on `room_percent()`). - **Clippy / rustdoc / `SWEPT_US` nits**: Used `const { assert!(..) }`, kept `let_go_idle`'s doc comment attached directly to `let_go_idle` rather than `EMPTY_PRESSURE_SWEEP_COOLDOWN_MS`, and recorded `SWEPT_US` on cooldown-skipped `let_go_idle` calls too. - **Follow-up fixes from 70+ min RX 9070 XT runs**: Added bounded fragmentation credit + raw `LOCAL.used` `86% -> 82%` hysteresis (`pool.rs` best-fit block clustering + `spare_and_fragmented_room()`) and bounded rolling `16,384`-entry sweeps + `r.host.used = 0` eviction reset (`10.87 ms -> 2.04 ms` avg over 154k textures).
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 15:25 UTC · original

Thanks @⁠zaixiakongyiji. I checked 6be0fe3 on a-publier 4eb6cfd.

What I ran

  • cargo build -p victory-gpu: OK.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without diagnostics: clean.
  • The 9 new unit tests: pass.

I did not run GPU tests or the game.

Earlier points: all addressed.

  • At 13,579 MiB, eviction at 92% → 93% now goes 1,630 → 2,308 MiB. Stepping by 0.01% from 85% to 120%, it never decreases.
  • room() and the 5 s eviction now start at the same 85% line, from the same usage figure.
  • The doc fix, const { assert!(..) }, the rustdoc placement and the SWEPT_US counting are all in.

New code. These come from reading the code, not from runs.

  1. While RAW_VRAM_HIGH is set, some textures are drawn black, and they can stay black after it clears.

    • Where: resource.rs:3029-3031. A title-filled texture that pool::texture can't place returns Deferred. That means XOR-swizzled, over 64 MiB, or no ripe non-empty block with a hole that fits. hosted() then returns None without setting refused.
    • What a draw gets: the draw isn't skipped and nothing falls back to making the texture. mirror writes a typed null SRV into the slot (descriptor/host.rs:3399-3406), so the shader samples zeros.
    • Why it stays black: mirror records the slot as made under that key even though the texture wasn't (3398, 3412). When the texture is made later, the quick path doesn't remake the slot. It stays null until the title rewrites that descriptor.
    • At 4eb6cfd these textures always went on to CreateCommittedResource.
    • Possible fixes: only defer on the indexed-heap queue path, or don't record a slot as made when its texture was Deferred.
  2. Under the latch, eviction doesn't see most of what it frees.

    • Before: at 4eb6cfd the sweep subtracted every unheld pool byte, so each released copy lowered used.
    • Now: under the latch the hole credit is 0 and effective is held at raw - whole_free or more (resource.rs:1856-1866, 1888-1893). A copy whose release only leaves a hole in a partly used block doesn't move it.
    • Example: 13,579 MiB budget, raw 11,800 MiB, 238 MiB kept. Effective is 12,038 MiB, so most is about 1,175 MiB. Each 1 s sweep can let go of that much again, up to 2,048 lock checks per sweep. A productive sweep resets the cooldown streak (resource.rs:2383), so cooldown never stops it.
    • When it stops: when enough blocks empty completely, are reclaimed (spares are 0 under the latch) and bring raw down to about 82%, or when no copy idle 5 s is left. With idle-first order spreading frees across blocks, that can be most of the 5 s-idle set. Each copy let go is then uploaded again into those holes.
    • One option: subtract the bytes already let go since the last raw sample.
  3. The two raw latches use different lines.

    • raw_vram_high_for uses the margin. For budgets of 8-16 GiB the margin is exactly budget/32, so it turns on at 84.875% and off at 81.875%.
    • vram_keep_with_raw uses a plain 86 / 82.
    • Rising band, 84.875% to 86% (about 150 MiB at 13,579 MiB): the resource latch is on, so there are no new heaps and no hole credit, and point 1 applies. The host guardrail is off, so only the 10 min idle eviction runs as long as effective stays under 85%.
    • Falling band: 81.875% to 82%, about 17 MiB. It's small, and reclaiming one empty block clears it.
    • No test covers either band. Reading RAW_VRAM_HIGH in vram_keep, or giving the host the same margin, would make them one latch.
  4. The 2,048 lock-check cap can starve a window.

    • How: by_age runs oldest first (resource.rs:2521). A texture held by a descriptor slot that the CPU hasn't asked for passes the lock-free checks, then fails com_refs == 1. Its used is never refreshed or cleared, so it takes a check again on every pass.
    • When the younger evictable textures in a window are never reached:
      • the table has 16,384 entries or fewer and holds 2,048 such textures;
      • the table length is an exact multiple of 16,384;
      • such textures are dense enough to fill 2,048 checks in every window.
    • Otherwise the shifting window edges spread them out over laps. 4eb6cfd had no cap.
    • One option: a resume index into by_age, or not counting checks for textures already known to be held.

Smaller:

  • While the latch is set, room() admits whenever raw is under 88% and a hole exists. It ignores the effective figure and VICTORY_TEXTURE_ROOM_PERCENT, so admission and eviction overlap again in that range.
  • host.rs:159 says "below this line" where it means "at".
  • The else if at resource.rs:1894 can't run: whole == 0 is caught by the branch before it.
**@⁠adrianmjim** on GitHub · 2026-11-27 15:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/223#issuecomment-7222047464) Thanks @⁠zaixiakongyiji. I checked 6be0fe3 on `a-publier` `4eb6cfd`. **What I ran** - `cargo build -p victory-gpu`: OK. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `diagnostics`: clean. - The 9 new unit tests: pass. I did not run GPU tests or the game. **Earlier points:** all addressed. - At 13,579 MiB, eviction at 92% → 93% now goes 1,630 → 2,308 MiB. Stepping by 0.01% from 85% to 120%, it never decreases. - `room()` and the 5 s eviction now start at the same 85% line, from the same usage figure. - The doc fix, `const { assert!(..) }`, the rustdoc placement and the `SWEPT_US` counting are all in. **New code.** These come from reading the code, not from runs. 1. **While `RAW_VRAM_HIGH` is set, some textures are drawn black, and they can stay black after it clears.** - Where: `resource.rs:3029-3031`. A title-filled texture that `pool::texture` can't place returns `Deferred`. That means XOR-swizzled, over 64 MiB, or no ripe non-empty block with a hole that fits. `hosted()` then returns `None` without setting `refused`. - What a draw gets: the draw isn't skipped and nothing falls back to making the texture. `mirror` writes a typed null SRV into the slot (`descriptor/host.rs:3399-3406`), so the shader samples zeros. - Why it stays black: `mirror` records the slot as made under that key even though the texture wasn't (`3398`, `3412`). When the texture is made later, the quick path doesn't remake the slot. It stays null until the title rewrites that descriptor. - At `4eb6cfd` these textures always went on to `CreateCommittedResource`. - Possible fixes: only defer on the indexed-heap queue path, or don't record a slot as made when its texture was `Deferred`. 2. **Under the latch, eviction doesn't see most of what it frees.** - Before: at `4eb6cfd` the sweep subtracted every unheld pool byte, so each released copy lowered `used`. - Now: under the latch the hole credit is 0 and effective is held at `raw - whole_free` or more (`resource.rs:1856-1866`, `1888-1893`). A copy whose release only leaves a hole in a partly used block doesn't move it. - Example: 13,579 MiB budget, raw 11,800 MiB, 238 MiB kept. Effective is 12,038 MiB, so `most` is about 1,175 MiB. Each 1 s sweep can let go of that much again, up to 2,048 lock checks per sweep. A productive sweep resets the cooldown streak (`resource.rs:2383`), so cooldown never stops it. - When it stops: when enough blocks empty completely, are reclaimed (spares are 0 under the latch) and bring raw down to about 82%, or when no copy idle 5 s is left. With idle-first order spreading frees across blocks, that can be most of the 5 s-idle set. Each copy let go is then uploaded again into those holes. - One option: subtract the bytes already let go since the last raw sample. 3. **The two raw latches use different lines.** - `raw_vram_high_for` uses the margin. For budgets of 8-16 GiB the margin is exactly budget/32, so it turns on at 84.875% and off at 81.875%. - `vram_keep_with_raw` uses a plain 86 / 82. - Rising band, 84.875% to 86% (about 150 MiB at 13,579 MiB): the resource latch is on, so there are no new heaps and no hole credit, and point 1 applies. The host guardrail is off, so only the 10 min idle eviction runs as long as effective stays under 85%. - Falling band: 81.875% to 82%, about 17 MiB. It's small, and reclaiming one empty block clears it. - No test covers either band. Reading `RAW_VRAM_HIGH` in `vram_keep`, or giving the host the same margin, would make them one latch. 4. **The 2,048 lock-check cap can starve a window.** - How: `by_age` runs oldest first (`resource.rs:2521`). A texture held by a descriptor slot that the CPU hasn't asked for passes the lock-free checks, then fails `com_refs == 1`. Its `used` is never refreshed or cleared, so it takes a check again on every pass. - When the younger evictable textures in a window are never reached: - the table has 16,384 entries or fewer and holds 2,048 such textures; - the table length is an exact multiple of 16,384; - such textures are dense enough to fill 2,048 checks in every window. - Otherwise the shifting window edges spread them out over laps. `4eb6cfd` had no cap. - One option: a resume index into `by_age`, or not counting checks for textures already known to be held. **Smaller:** - While the latch is set, `room()` admits whenever raw is under 88% and a hole exists. It ignores the effective figure and `VICTORY_TEXTURE_ROOM_PERCENT`, so admission and eviction overlap again in that range. - `host.rs:159` says "below this line" where it means "at". - The `else if` at `resource.rs:1894` can't run: `whole == 0` is caught by the branch before it.
This pull request can be merged automatically.
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/223/head:github-bot/gh-223'
git switch 'github-bot/gh-223'

Merge

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