victory-gpu: chain heap-worker passes and read textures ahead on threads while slots are left due (stacked on #1007) #1287

Open
Exopus-0x65f7ad0 wants to merge 4 commits from upstream-pr/1290 into main
Exopus-0x65f7ad0 commented 2026-11-26 11:16:11 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Exopus-0x65f7ad0 on 2026-11-26T11:16:11Z.


Stacked on #1007 (heap worker). Only the last commit is new.

What

  • draw.rs: BACKLOG_LEFT records whether the last pass over textures picked by index left slots due. That is the case when the pass was handed a full 4096 slots, or stopped early on bytes, time or make_way.
  • heap_worker.rs: after a pass, if slots are left due and no newer heap is waiting, the worker hands itself the same heap again. Turn this off with VICTORY_HEAP_WORKER_CHAIN=0.
  • host.rs: refresh_textures_ahead reads textures on scoped threads, but only while the queue is behind. VICTORY_REFRESH_WIDE=<n> sets the thread count (default 4, clamped to 1-8); 0 or 1 keeps the old single-thread path. When the queue is not behind it stays sequential, so it does not compete with the submitting thread's copies.

Why

I profiled the opening cutscene on a 16 GB machine where texture reads page-fault heavily. The heap worker sat idle about half of each frame (112 of 220 ms) waiting for the next kick, while ~20k slots were still due. Those due slots read null or stale views and show up as black or red faces at shot changes.

With both changes, faces stay textured across the shot changes in my runs. Frame time is unchanged, since that machine is memory-bound anyway.

Tests

  • cargo test -p victory-gpu: 171 passed.
  • No new tests: the change is scheduling only, and both env switches restore the old behaviour.

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6625472638 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1290). Originally posted by [Exopus-0x65f7ad0](https://github.com/Exopus-0x65f7ad0) on 2026-11-26T11:16:11Z. --- Stacked on #1007 (heap worker). Only the last commit is new. ## What - `draw.rs`: `BACKLOG_LEFT` records whether the last pass over textures picked by index left slots due. That is the case when the pass was handed a full 4096 slots, or stopped early on bytes, time or `make_way`. - `heap_worker.rs`: after a pass, if slots are left due and no newer heap is waiting, the worker hands itself the same heap again. Turn this off with `VICTORY_HEAP_WORKER_CHAIN=0`. - `host.rs`: `refresh_textures_ahead` reads textures on scoped threads, but only while the queue is behind. `VICTORY_REFRESH_WIDE=<n>` sets the thread count (default 4, clamped to 1-8); `0` or `1` keeps the old single-thread path. When the queue is not behind it stays sequential, so it does not compete with the submitting thread's copies. ## Why I profiled the opening cutscene on a 16 GB machine where texture reads page-fault heavily. The heap worker sat idle about half of each frame (112 of 220 ms) waiting for the next kick, while ~20k slots were still due. Those due slots read null or stale views and show up as black or red faces at shot changes. With both changes, faces stay textured across the shot changes in my runs. Frame time is unchanged, since that machine is memory-bound anyway. ## Tests - `cargo test -p victory-gpu`: 171 passed. - No new tests: the change is scheduling only, and both env switches restore the old behaviour. 🤖 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/1290:upstream-pr/1290'
git switch 'upstream-pr/1290'

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/1290'
git switch 'upstream-pr/1290'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1290'
git switch 'upstream-pr/1290'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1290'
git switch 'main'
git merge --squash 'upstream-pr/1290'
git switch 'main'
git merge --ff-only 'upstream-pr/1290'
git switch 'main'
git merge 'upstream-pr/1290'
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
fxceless/victory-fork!1287
No description provided.