Texture store: at most 8 textures wait for its thread (the copies piled up unbounded; #227) #288

Open
sharan104 wants to merge 1 commit from upstream-pr/288 into main
sharan104 commented 2026-11-26 14:31:30 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T14:31:30Z.


Refs #227 (one of the items it lists as open to anyone).

texstore::keep sends a full copy of each texture's memory (tiled.to_vec()) over an unbounded mpsc::channel to the single "texture store" thread, which digests, detiles and writes each one. When textures arrive faster than that thread keeps up (streaming in a new area), the copies pile up in the channel with no limit: whole texture memories, held until the thread reaches them.

Fix:

  • A sync_channel of WAITING (8) jobs, filled with try_send.
  • A texture that finds the queue full is taken back out of seen, so it's stored the next time it's read whole. The store loses nothing; it just catches up later.
  • If the store's thread is gone (the channel is disconnected), the texture stays in seen and isn't copied again on every read.

Test: textures_wait_for_the_store_in_bounds queues 13 textures into a channel nobody drains. Only the first 8 wait, and the other 5 are no longer in seen. With the receiver dropped, a texture stays seen. The test fails without the seen removal and passed 10 runs out of 10.

Results:

  • cargo test -p victory-gpu --locked passes, with and without --all-features.
  • Clippy adds nothing beyond main's existing watch.rs lint, which #241 fixes.

This touches different lines of texstore.rs from #283, which adds the asset-policy check to the store's folder. The two merge independently.

🤖 Generated with Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6628842269 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/288). Originally posted by [sharan104](https://github.com/sharan104) on 2026-11-26T14:31:30Z. --- Refs #227 (one of the items it lists as open to anyone). `texstore::keep` sends a full copy of each texture's memory (`tiled.to_vec()`) over an **unbounded** `mpsc::channel` to the single "texture store" thread, which digests, detiles and writes each one. When textures arrive faster than that thread keeps up (streaming in a new area), the copies pile up in the channel with no limit: whole texture memories, held until the thread reaches them. **Fix:** - A `sync_channel` of `WAITING` (8) jobs, filled with `try_send`. - A texture that finds the queue full is taken back out of `seen`, so it's stored the next time it's read whole. The store loses nothing; it just catches up later. - If the store's thread is gone (the channel is disconnected), the texture stays in `seen` and isn't copied again on every read. **Test:** `textures_wait_for_the_store_in_bounds` queues 13 textures into a channel nobody drains. Only the first 8 wait, and the other 5 are no longer in `seen`. With the receiver dropped, a texture stays seen. The test fails without the `seen` removal and passed 10 runs out of 10. **Results:** - `cargo test -p victory-gpu --locked` passes, with and without `--all-features`. - Clippy adds nothing beyond main's existing `watch.rs` lint, which #241 fixes. This touches different lines of `texstore.rs` from #283, which adds the asset-policy check to the store's folder. The two merge independently. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/288:upstream-pr/288'
git switch 'upstream-pr/288'

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 'main'
git merge --no-ff 'upstream-pr/288'
git switch 'upstream-pr/288'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/288'
git switch 'upstream-pr/288'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/288'
git switch 'main'
git merge --squash 'upstream-pr/288'
git switch 'main'
git merge --ff-only 'upstream-pr/288'
git switch 'main'
git merge 'upstream-pr/288'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!288
No description provided.