Texture store: switches for the most its queue and memory hold (unset as before) #404

Open
Esteban-V wants to merge 1 commit from upstream-pr/404 into a-publier
Esteban-V commented 2026-11-27 00:03:44 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Esteban-V on 2026-11-27T00:03:44Z.


The texture store (VICTORY_TEXTURE_STORE, off by default) has two memory limits that cannot be changed, in crates/victory-gpu/src/texstore.rs. kept holds up to KEPT = 4 GiB of levels (texstore.rs:36) and nothing in it is ever let go. Jobs go through an unbounded mpsc::channel, and each new texture is copied whole (tiled.to_vec() in keep(), texstore.rs:182) on the thread that read it, where it waits until the store's thread detiles and writes it. At world load many textures arrive at once (an audit estimate is about 24,000), so the bytes waiting have no limit. This adds two switches for those limits.

  • VICTORY_TEXTURE_STORE_QUEUE_MB: the most bytes of copies waiting. A new QUEUED counter is checked with fetch_update after the seen insert and before the copy. A texture over the limit is not copied, its digest is taken out of seen so a later read offers it again, and a "not kept with the queue full" count goes up. A texture is always taken when the queue is empty, so one larger than the limit can still be stored.
  • The store's thread subtracts a job's bytes as soon as it receives it, before any continue; keep() subtracts them too if send fails.
  • VICTORY_TEXTURE_STORE_KEPT_MB: replaces KEPT in kept() and find(). With 0 nothing is held, and every texture found is read from the folder on the recording thread that asks; the doc comment says so.
  • The memory line also shows how many textures were not kept and how many MB are waiting.
  • The limit check (admit) and the MB parser are pure functions, each with a test.
  • Default unchanged: unset means no queue limit and 4096 MB kept, as today.

Testing

  • Windows CI (windows-latest): Clippy, default tests and diagnostics tests pass (run).
  • Type-checked and clippy-clean for x86_64-pc-windows-msvc on a macOS host (cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, default and --all-features).
  • Unit tests queue_limit and mb_read added.
<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5518884987 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/404). Originally posted by [Esteban-V](https://github.com/Esteban-V) on 2026-11-27T00:03:44Z. --- The texture store (`VICTORY_TEXTURE_STORE`, off by default) has two memory limits that cannot be changed, in `crates/victory-gpu/src/texstore.rs`. `kept` holds up to `KEPT` = 4 GiB of levels (`texstore.rs:36`) and nothing in it is ever let go. Jobs go through an unbounded `mpsc::channel`, and each new texture is copied whole (`tiled.to_vec()` in `keep()`, `texstore.rs:182`) on the thread that read it, where it waits until the store's thread detiles and writes it. At world load many textures arrive at once (an audit estimate is about 24,000), so the bytes waiting have no limit. This adds two switches for those limits. - `VICTORY_TEXTURE_STORE_QUEUE_MB`: the most bytes of copies waiting. A new `QUEUED` counter is checked with `fetch_update` after the `seen` insert and before the copy. A texture over the limit is not copied, its digest is taken out of `seen` so a later read offers it again, and a "not kept with the queue full" count goes up. A texture is always taken when the queue is empty, so one larger than the limit can still be stored. - The store's thread subtracts a job's bytes as soon as it receives it, before any `continue`; `keep()` subtracts them too if `send` fails. - `VICTORY_TEXTURE_STORE_KEPT_MB`: replaces `KEPT` in `kept()` and `find()`. With `0` nothing is held, and every texture found is read from the folder on the recording thread that asks; the doc comment says so. - The memory line also shows how many textures were not kept and how many MB are waiting. - The limit check (`admit`) and the MB parser are pure functions, each with a test. - Default unchanged: unset means no queue limit and 4096 MB kept, as today. ## Testing - Windows CI (`windows-latest`): Clippy, default tests and diagnostics tests pass ([run](https://github.com/Esteban-V/VIctory-Belobug-AMD/actions/runs/45916891287)). - Type-checked and clippy-clean for `x86_64-pc-windows-msvc` on a macOS host (`cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`, default and `--all-features`). - Unit tests `queue_limit` and `mb_read` added.
MamaLeVrai commented 2026-11-27 01:23:05 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by MamaLeVrai on 2026-11-27T01:23:05Z.


Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 54a696e: cargo test --release -p victory-gpu --lib 398 passed, 0 failed, 34 ignored.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7207243301 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/404#issuecomment-7207243301). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-27T01:23:05Z. --- Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `54a696e`: `cargo test --release -p victory-gpu --lib` 398 passed, 0 failed, 34 ignored. AI-assisted (Claude Code); no game data.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/404:upstream-pr/404'
git switch 'upstream-pr/404'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'a-publier'
git merge --no-ff 'upstream-pr/404'
git switch 'upstream-pr/404'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/404'
git switch 'upstream-pr/404'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/404'
git switch 'a-publier'
git merge --squash 'upstream-pr/404'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/404'
git switch 'a-publier'
git merge 'upstream-pr/404'
git push origin 'a-publier'
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
Belobug/VIctory-Belobug-AMD!404
No description provided.