GPU: the per-frame eviction pass is counted, and its census reads a flag instead of GetDesc per texture #3254

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

@⁠borosf on GitHub · 2026-11-26 14:41 UTC · original
borosf:vibe/evictable-counted-842ca5 → main · +43 −8 · 2 files · 1 commits · open

The per-frame eviction census now costs nothing when nothing is evictable, and reads a flag instead of a COM call per texture when it does run.

What it cost

evict_unused runs once per presented frame and calls candidates(), which locks TEXTURES_AT and walks every title texture there is (~20,000–50,000 in the world), taking each resource's host mutex, cloning the Arc, and calling GetDesc per texture to answer "may this be given up?" — all under the same TEXTURES_AT lock that alias_source needs per texture view per draw, so title threads queue behind it once a frame.

What changes

HostTexture carries an evictable: AtomicBool — fed from title memory (has a MemoryKey, not a render/depth/unordered target) and not written by the host — maintained exactly where its inputs change:

  • set where the key is assigned at creation (and counted in a new EVICTABLE counter),
  • cleared by HostTexture::note_host_written() (the existing deferred host_written store in texture.rs now calls it),
  • cleared in Drop, alongside the existing TEXTURES/TEXTURE_BYTES counter maintenance.

candidates() reads the flag instead of GetDesc, and evict_unused returns immediately when EVICTABLE == 0 — the steady state between shots, and any frame where the host has written everything fed from title memory.

The old evictable(t) helper (the GetDesc-per-texture predicate) is gone; the flag is its memo.

Verification

  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings — clean; --all-features too.
  • cargo test -p victory-gpu --lib --locked --no-fail-fast — 229 passed, 2 failed, both the known Intel baseline failures pristine main also fails (#1744/#1829). I checked the counts against a main worktree run twice, identical; one earlier run showed a third, shadow::tests::marked_pages_go_back_by_the_bytes_the_gpu_changed, which passes 3/3 in isolation and did not recur in three further full runs — a parallel-run flake, not this change.
  • The eviction tests (evict_among, idle/budget/evict_among-driven cases in resource::tests) pass.
  • rustfmt --edition 2024 --check hunk counts against main: resource.rs 64→63, texture.rs 25→24 (both one fewer).

Synthetic tests only; no game data.

Part of the fifteen gaps claimed for this sweep on #1633. AI-assisted.

**@⁠borosf** on GitHub · 2026-11-26 14:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/3254) `borosf:vibe/evictable-counted-842ca5` → `main` · +43 −8 · 2 files · 1 commits · open The per-frame eviction census now costs nothing when nothing is evictable, and reads a flag instead of a COM call per texture when it does run. ## What it cost `evict_unused` runs once per presented frame and calls `candidates()`, which locks `TEXTURES_AT` and walks every title texture there is (~20,000–50,000 in the world), taking each resource's `host` mutex, cloning the `Arc`, and calling `GetDesc` per texture to answer "may this be given up?" — all under the same `TEXTURES_AT` lock that `alias_source` needs per texture view per draw, so title threads queue behind it once a frame. ## What changes `HostTexture` carries an `evictable: AtomicBool` — fed from title memory (has a `MemoryKey`, not a render/depth/unordered target) and not written by the host — maintained exactly where its inputs change: - set where the key is assigned at creation (and counted in a new `EVICTABLE` counter), - cleared by `HostTexture::note_host_written()` (the existing deferred `host_written` store in `texture.rs` now calls it), - cleared in `Drop`, alongside the existing `TEXTURES`/`TEXTURE_BYTES` counter maintenance. `candidates()` reads the flag instead of `GetDesc`, and `evict_unused` returns immediately when `EVICTABLE == 0` — the steady state between shots, and any frame where the host has written everything fed from title memory. The old `evictable(t)` helper (the `GetDesc`-per-texture predicate) is gone; the flag is its memo. ## Verification - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` — clean; `--all-features` too. - `cargo test -p victory-gpu --lib --locked --no-fail-fast` — 229 passed, 2 failed, both the known Intel baseline failures pristine `main` also fails (#1744/#1829). I checked the counts against a `main` worktree run twice, identical; one earlier run showed a third, `shadow::tests::marked_pages_go_back_by_the_bytes_the_gpu_changed`, which passes 3/3 in isolation and did not recur in three further full runs — a parallel-run flake, not this change. - The eviction tests (`evict_among`, idle/budget/`evict_among`-driven cases in `resource::tests`) pass. - `rustfmt --edition 2024 --check` hunk counts against `main`: `resource.rs` 64→63, `texture.rs` 25→24 (both one *fewer*). Synthetic tests only; no game data. Part of the fifteen gaps claimed for this sweep on #1633. AI-assisted.
`evict_unused` runs once per presented frame and calls `candidates()`, which
locks TEXTURES_AT and walks every title texture there is (~20,000-50,000),
taking each resource's `host` mutex, cloning the Arc and calling `GetDesc`
per texture to ask whether it may be given up — the whole census held under
the same TEXTURES_AT lock that alias_source needs per draw.

`HostTexture` now carries an `evictable` flag (fed from title memory, not
written by the host) set where its key is assigned, cleared by
`note_host_written`, and counted in `EVICTABLE`, maintained like the
existing TEXTURES/TEXTURE_BYTES counters (set at creation, cleared in
Drop). `candidates()` reads the flag instead of `GetDesc`, and
`evict_unused` returns at zero, so a frame with nothing evictable pays
nothing for the pass.

Verification: `cargo clippy -p victory-gpu --all-targets --locked -- -D
warnings` and `--all-features` both clean; `cargo test -p victory-gpu --lib
--locked --no-fail-fast` 229 passed, 2 failed — both the known Intel
baseline failures pristine main also fails (#1744/#1829), same counts as
main run twice. `rustfmt --edition 2024 --check` hunks against main:
resource.rs 64->63, texture.rs 25->24.

Synthetic tests only; no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:47:57 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 14:48 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):

  • Tracking HostTexture::evictable and the global EVICTABLE counter (incremented in shared_texture, decremented once via swap(false) in
    ote_host_written or Drop) avoids per-texture GetDesc calls during candidates() and skips the per-frame census when EVICTABLE == 0. Confirmed exture::host_writes is the sole mutator of host_written.
  • cargo test -p victory-gpu --lib resource:: -- --test-threads=1 (RTX 5090): 18 passed, 0 failed (including only_textures_fed_from_title_memory_are_given_up and idle_textures_go_and_past_the_budget_the_least_recently_used).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 14:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3254#pullrequestreview-6076146163) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090): - Tracking HostTexture::evictable and the global EVICTABLE counter (incremented in shared_texture, decremented once via swap(false) in ote_host_written or Drop) avoids per-texture GetDesc calls during candidates() and skips the per-frame census when EVICTABLE == 0. Confirmed exture::host_writes is the sole mutator of host_written. - cargo test -p victory-gpu --lib resource:: -- --test-threads=1 (RTX 5090): 18 passed, 0 failed (including only_textures_fed_from_title_memory_are_given_up and idle_textures_go_and_past_the_budget_the_least_recently_used). - cargo clippy -p victory-gpu --all-targets -- -D warnings: clean. - cargo xtask policy: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠borosf on GitHub · 2026-11-26 14:59 UTC · original

Thanks — no change needed, head stays 14b3ff6710a9086a33a1e3e0a413a573fccfc480. Your check that texture::host_writes is the sole mutator of host_written matches mine (single store(true) site, now routed through note_host_written). Synthetic tests only; no game data.

**@⁠borosf** on GitHub · 2026-11-26 14:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/3254#issuecomment-7195616849) Thanks — no change needed, head stays `14b3ff6710a9086a33a1e3e0a413a573fccfc480`. Your check that `texture::host_writes` is the sole mutator of `host_written` matches mine (single `store(true)` site, now routed through `note_host_written`). Synthetic tests only; no game data.
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/3254/head:github-bot/gh-3254'
git switch 'github-bot/gh-3254'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3254'
git switch 'github-bot/gh-3254'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3254'
git switch 'github-bot/gh-3254'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3254'
git switch 'main'
git merge --squash 'github-bot/gh-3254'
git switch 'main'
git merge --ff-only 'github-bot/gh-3254'
git switch 'main'
git merge 'github-bot/gh-3254'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!3254
No description provided.