gpu(native): scanner hands its reads to submissions; adaptive sync threads #595

Open
AnastasisKon wants to merge 1 commit from upstream-pr/595 into main
AnastasisKon commented 2026-11-28 11:06:39 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T11:06:39Z.


What this changes

Step toward #179 (world frame rate): the texture scanner already read a changed texture's memory whole on its own thread, and the submission then read the same memory again to hash and detile it. Now the scanner keeps what it read (up to 64 MiB per texture, 512 MiB total, evicted oldest-first) in Watch::stashed, and the submission's Job detiles those bytes directly (Job::stashed) — a scanner-found change is no longer read twice. Also, the sync read threads were a fixed 6; sync_threads() now uses all the host's cores but two (6 on an 8-core base M1, 10 on a 12-core M1 Pro), matching the other thread pools' available_parallelism pattern. Refs #179

How it was tested

  • cargo test -p victory-gpu — 456 passed, 0 failed; 6 new tests: scanner stashes changed bytes+hash, cap eviction (5x1024 into a 4096 cap), per-texture cap, Job::read detiles stashed bytes without touching memory (bogus address proves no read), unreadable stash falls back to reading, blank stash needs no detile, sync_threads sizing
  • cargo test --target x86_64-apple-darwin -p victory-gpu --lib textures:: — 25 passed under Rosetta
  • cargo test -p victory-hle -p victory -p victory-gpu -p xtask — all ok
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — RC=0
  • cargo xtask policy — 404 files ok
  • Game run: not yet (game download still in progress; measure with VICTORY_TRACE_TEXTURE_SYNC=1 when it lands)

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md — torn-stash shortcut marked in code and docs ("Texture sync without the host's lock")
  • New diagnostics are behind a VICTORY_* variable and documented — n/a, no new switch
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5539472433 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/595). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T11:06:39Z. --- ## What this changes Step toward #179 (world frame rate): the texture scanner already read a changed texture's memory whole on its own thread, and the submission then read the same memory again to hash and detile it. Now the scanner keeps what it read (up to 64 MiB per texture, 512 MiB total, evicted oldest-first) in `Watch::stashed`, and the submission's `Job` detiles those bytes directly (`Job::stashed`) — a scanner-found change is no longer read twice. Also, the sync read threads were a fixed 6; `sync_threads()` now uses all the host's cores but two (6 on an 8-core base M1, 10 on a 12-core M1 Pro), matching the other thread pools' `available_parallelism` pattern. Refs #179 ## How it was tested - [x] `cargo test -p victory-gpu` — 456 passed, 0 failed; 6 new tests: scanner stashes changed bytes+hash, cap eviction (5x1024 into a 4096 cap), per-texture cap, `Job::read` detiles stashed bytes without touching memory (bogus address proves no read), unreadable stash falls back to reading, blank stash needs no detile, `sync_threads` sizing - [x] `cargo test --target x86_64-apple-darwin -p victory-gpu --lib textures::` — 25 passed under Rosetta - [x] `cargo test -p victory-hle -p victory -p victory-gpu -p xtask` — all ok - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — RC=0 - [x] `cargo xtask policy` — 404 files ok - [ ] Game run: not yet (game download still in progress; measure with `VICTORY_TRACE_TEXTURE_SYNC=1` when it lands) ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md — torn-stash shortcut marked in code and docs ("Texture sync without the host's lock") - [x] New diagnostics are behind a `VICTORY_*` variable and documented — n/a, no new switch
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/595:upstream-pr/595'
git switch 'upstream-pr/595'

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/595'
git switch 'upstream-pr/595'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/595'
git switch 'upstream-pr/595'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/595'
git switch 'main'
git merge --squash 'upstream-pr/595'
git switch 'main'
git merge --ff-only 'upstream-pr/595'
git switch 'main'
git merge 'upstream-pr/595'
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
LakshanSivakumar/Native-Victory-macOS!595
No description provided.