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

Open
github-bot wants to merge 1 commit from github-bot/gh-603 into main AGit
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 11:51 UTC · original
AnastasisKon:vibe/blake3-rayon-1705ac → main · +78 −6 · 3 files · 1 commits · open

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
**@⁠AnastasisKon** on GitHub · 2026-11-28 11:51 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/603) `AnastasisKon:vibe/blake3-rayon-1705ac` → `main` · +78 −6 · 3 files · 1 commits · open 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
The scanner, the per-submission read, and the GPU-written copy-back all
hashed whole textures with blake3::hash on one core while the other cores
idled. Textures at or above 1 MiB now hash with Hasher::update_rayon, which
splits the input over the rayon pool; smaller ones keep the single-shot
hash. The hash is unchanged: a test checks hash_of against blake3::hash for
sizes straddling the cutoff.

blake3 gains the rayon feature (Cargo.lock: rayon, crossbeam-deque and
deps).

Refs #179

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 11:52:47 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 11:59 UTC · original

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** on GitHub · 2026-11-28 11:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/603#issuecomment-7238919455) 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.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 12:49 UTC · original

Note for review: #607, #608, #609, #612, #614 and #613 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 #607/#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.

**@⁠AnastasisKon** on GitHub · 2026-11-28 12:49 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/603#issuecomment-7239489129) Note for review: #607, #608, #609, #612, #614 and #613 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 #607/#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 can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/607/head:github-bot/gh-603'
git switch 'github-bot/gh-603'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-603'
git switch 'github-bot/gh-603'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-603'
git switch 'github-bot/gh-603'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-603'
git switch 'main'
git merge --squash 'github-bot/gh-603'
git switch 'main'
git merge --ff-only 'github-bot/gh-603'
git switch 'main'
git merge 'github-bot/gh-603'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.