gpu(native): detile big textures on the rayon pool #608

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

@⁠AnastasisKon on GitHub · 2026-11-28 11:57 UTC · original
AnastasisKon:vibe/detile-rayon-1705ac → main · +161 −21 · 4 files · 1 commits · open

Refs #179

What

A changed texture was detiled mip by mip, slice by slice on a single submission thread. A 4K RGBA texture (32 MiB mip 0) spent its whole detile serialized on one core while the other 11 idled — the dominant CPU cost of uploading a big streamed texture, and exactly what stands between the native host and Series X-class frame times on M1.

Each (mip, slice) level reads the tiled bytes and writes only its own staging buffer, so levels are independent: detile_changed now collects the work items and runs them on the rayon pool when the texture is at least 1 MiB. Smaller textures stay serial (no pool scheduling overhead). The all-zero fine-mip skip now checks its slices with into_par_iter().all(..) on big textures, and is_all_zero checks ranges >= 1 MiB with par_iter as well.

Results are sorted back into (mip, slice) order, so upload order and the detiled_mips bitmask are exactly what the serial loop produced. Error behavior: the first error is reported, as before.

Adds rayon as a workspace dependency of victory-gpu (already in the lock via blake3's rayon feature; the rayon crate itself is new to the lock).

Correctness

A unit test detile a 1024x1024 array-of-4 RGBA texture (22 MiB, takes the parallel path) with uploaded_mips = u32::MAX and compares every level — mip, slice, row, slice_pitch, and every texel byte — against the serial per-level detile_level, plus the bitmask.

Testing

  • cargo test -p victory-hle -p victory -p victory-gpu -p xtask (host arm64) — all pass, incl. detile_changed_parallel_path_matches_serial_level_by_level
  • cargo test --target x86_64-apple-darwin -p victory-gpu --lib textures:: — 19 pass, 0 fail
  • 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/detile-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:57 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/604) `AnastasisKon:vibe/detile-rayon-1705ac` → `main` · +161 −21 · 4 files · 1 commits · open Refs #179 ## What A changed texture was detiled mip by mip, slice by slice on a single submission thread. A 4K RGBA texture (32 MiB mip 0) spent its whole detile serialized on one core while the other 11 idled — the dominant CPU cost of uploading a big streamed texture, and exactly what stands between the native host and Series X-class frame times on M1. Each (mip, slice) level reads the tiled bytes and writes only its own staging buffer, so levels are independent: `detile_changed` now collects the work items and runs them on the rayon pool when the texture is at least 1 MiB. Smaller textures stay serial (no pool scheduling overhead). The all-zero fine-mip skip now checks its slices with `into_par_iter().all(..)` on big textures, and `is_all_zero` checks ranges >= 1 MiB with `par_iter` as well. Results are sorted back into (mip, slice) order, so upload order and the `detiled_mips` bitmask are exactly what the serial loop produced. Error behavior: the first error is reported, as before. Adds `rayon` as a workspace dependency of `victory-gpu` (already in the lock via blake3's rayon feature; the `rayon` crate itself is new to the lock). ## Correctness A unit test detile a 1024x1024 array-of-4 RGBA texture (22 MiB, takes the parallel path) with `uploaded_mips = u32::MAX` and compares every level — mip, slice, row, slice_pitch, and every texel byte — against the serial per-level `detile_level`, plus the bitmask. ## Testing - [x] `cargo test -p victory-hle -p victory -p victory-gpu -p xtask` (host arm64) — all pass, incl. `detile_changed_parallel_path_matches_serial_level_by_level` - [x] `cargo test --target x86_64-apple-darwin -p victory-gpu --lib textures::` — 19 pass, 0 fail - [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/detile-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
A changed texture was detiled mip by mip, slice by slice on one
submission thread; a 4K RGBA texture spends its whole detile serialized
there while the other cores idle. Levels read the tiled bytes and write
only their own staging buffer, so they detile independently:
detile_changed now collects the (mip, slice) work and runs it on the
rayon pool when the texture is at least 1 MiB (smaller ones stay serial,
no pool overhead). The all-zero mip skip checks its slices on the pool
too, and is_all_zero checks big ranges on the pool.

Results are sorted back into mip/slice order, so upload order and the
detiled-mips bitmask are unchanged. A test detile a 1024x1024x4 RGBA
texture (parallel path) and compares every level byte-for-byte with the
serial per-level detile.

Adds rayon as a workspace dependency of victory-gpu.

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:59:58 +00:00
Author
Owner

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

CI green (check + macos-scripts SUCCESS), marked ready for review.

**@⁠AnastasisKon** on GitHub · 2026-11-28 12:05 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/604#issuecomment-7238982885) CI green (check + macos-scripts SUCCESS), marked ready for review.
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/608/head:github-bot/gh-604'
git switch 'github-bot/gh-604'

Merge

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