gpu(native): hash big texture syncs on the rayon pool #603

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

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


Refs #179

What

The texture sync hashed every watched texture with blake3::hash on a single core — the scanner thread, each submission's Job::read, and the GPU-written copy-back all serialized there while the other 10 cores idled. On a 4K streamed texture set that is the dominant per-frame CPU cost of the sync.

Textures at or above 1 MiB now hash with blake3::Hasher::update_rayon, which splits the input over the rayon pool. Below the cutoff the single-shot blake3::hash is kept (no pool overhead for small textures). blake3 gains the rayon feature (Cargo.lock adds rayon + crossbeam-deque and deps).

  • scan_round accumulates the read into one buffer for big textures and hashes it with hash_of; small ones keep the incremental per-chunk hash.
  • Job::read and the two hashes in the GPU-written copy-back path call hash_of.

Correctness

The hash value is unchanged — update_rayon is the same BLAKE3 tree hash. A unit test asserts hash_of(bytes) == blake3::hash(bytes) for sizes straddling the 1 MiB cutoff (0, 1, 63..65, 1 MiB-1/+1/+63, 3 MiB+7).

Testing

  • cargo test -p victory-hle -p victory -p victory-gpu -p xtask (host arm64) — all pass, incl. hash_of_matches_blake3_across_the_parallel_threshold
  • cargo test --target x86_64-apple-darwin -p victory-gpu --lib — 448 pass; 1-2 native::tests remap tests flake under the full Rosetta run, reproducible on clean upstream/main (pre-existing, unrelated to this change); each passes in isolation
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — clean
  • cargo xtask policy — 404 files ok

Checklist

  • One change, one PR
  • Branch vibe/blake3-rayon-1705ac from upstream/main, pushed to my fork only
  • No game/GDK files, no dumps/logs in the repo
  • No AI attribution in the diff
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5539833124 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/603). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T11:51:37Z. --- Refs #179 ## What The texture sync hashed every watched texture with `blake3::hash` on a single core — the scanner thread, each submission's `Job::read`, and the GPU-written copy-back all serialized there while the other 10 cores idled. On a 4K streamed texture set that is the dominant per-frame CPU cost of the sync. Textures at or above 1 MiB now hash with `blake3::Hasher::update_rayon`, which splits the input over the rayon pool. Below the cutoff the single-shot `blake3::hash` is kept (no pool overhead for small textures). `blake3` gains the `rayon` feature (Cargo.lock adds rayon + crossbeam-deque and deps). - `scan_round` accumulates the read into one buffer for big textures and hashes it with `hash_of`; small ones keep the incremental per-chunk hash. - `Job::read` and the two hashes in the GPU-written copy-back path call `hash_of`. ## Correctness The hash value is unchanged — `update_rayon` is the same BLAKE3 tree hash. A unit test asserts `hash_of(bytes) == blake3::hash(bytes)` for sizes straddling the 1 MiB cutoff (0, 1, 63..65, 1 MiB-1/+1/+63, 3 MiB+7). ## Testing - [x] `cargo test -p victory-hle -p victory -p victory-gpu -p xtask` (host arm64) — all pass, incl. `hash_of_matches_blake3_across_the_parallel_threshold` - [x] `cargo test --target x86_64-apple-darwin -p victory-gpu --lib` — 448 pass; 1-2 `native::tests` remap tests flake under the full Rosetta run, reproducible on clean `upstream/main` (pre-existing, unrelated to this change); each passes in isolation - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — clean - [x] `cargo xtask policy` — 404 files ok ## Checklist - [x] One change, one PR - [x] Branch `vibe/blake3-rayon-1705ac` from `upstream/main`, pushed to my fork only - [x] No game/GDK files, no dumps/logs in the repo - [x] No AI attribution in the diff
AnastasisKon commented 2026-11-28 11:59:44 +00:00 (Migrated from github.com)

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


CI green (check + macos-scripts SUCCESS), marked ready. Host 4-crate tests, x86_64-apple-darwin victory-gpu tests, windows-target clippy --locked -D warnings and cargo xtask policy all pass locally; the two native::tests remap flakes under the full Rosetta run reproduce on clean upstream/main and are unrelated.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238919455 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/603#issuecomment-7238919455). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T11:59:44Z. --- CI green (check + macos-scripts SUCCESS), marked ready. Host 4-crate tests, x86_64-apple-darwin victory-gpu tests, windows-target clippy --locked -D warnings and cargo xtask policy all pass locally; the two native::tests remap flakes under the full Rosetta run reproduce on clean upstream/main and are unrelated.
AnastasisKon commented 2026-11-28 12:49:14 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:49:14Z.


Note for review: #603, #604, #605, #608, #610 and #609 were cherry-picked together onto a local integration branch off main; host 4-crate tests, x86_64-apple-darwin tests (victory-gpu/victory-loader/victory-hle), windows-target clippy --locked -D warnings and cargo xtask policy all pass on the composed result (the scan_round hunks of #603/#605/#608 resolve to: par_iter scan_one, big textures via read_into + hash_of). Happy to rebase any of these onto another once it merges.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239489129 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/603#issuecomment-7239489129). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:49:14Z. --- Note for review: #603, #604, #605, #608, #610 and #609 were cherry-picked together onto a local integration branch off main; host 4-crate tests, x86_64-apple-darwin tests (victory-gpu/victory-loader/victory-hle), windows-target clippy --locked -D warnings and cargo xtask policy all pass on the composed result (the scan_round hunks of #603/#605/#608 resolve to: par_iter scan_one, big textures via read_into + hash_of). Happy to rebase any of these onto another once it merges.
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/603:upstream-pr/603'
git switch 'upstream-pr/603'

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