CLI/shader+translate: slice raw DXBC sources to container total_size and stop warm-up walk early #748

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

@⁠AscilCH on GitHub · 2026-11-25 06:09 UTC · original
AscilCH:fix/cli-shader-raw-slice-and-warm-early-stop → main · +72 −10 · 2 files · 1 commits · open

Summary

Fixes two bugs in the CLI shader scanner and offline shader cache warm-up tool:

  1. Raw DXBC containers included trailing file bytes (apps/victory/src/shader.rs):
    • sources() previously constructed Source::Raw { offset, data: &data[offset..] } without slicing to the DXBC container's validated total_size field at offset 0x18..0x1c.
    • Every downstream consumer hashed, cached, or dumped the entire remainder of the enclosing file along with the container:
      • translate --warm <file> failed to match hashes logged at runtime for uncompressed containers;
      • translate --warm all cached raw containers under blake3(build || container || rest_of_file) (guaranteed cache miss at runtime) and performed O(N × file size) hashing;
      • VICTORY_TRANSLATE_ONLY, VICTORY_DUMP_MATCH, and VICTORY_FAIL_DUMP hashed/dumped trailing binary bytes.
    • sources() now slices each raw container to &tail[..total].
  2. Outer directory walk ignored stop conditions in translate::warm (apps/victory/src/translate.rs):
    • When VICTORY_WARM_SECONDS expired, only the inner per-file worker loop broke while the outer WalkDir loop continued reading every remaining file into memory and spawning threads.
    • warm() now breaks out of the outer walk immediately on timeout or once all hashes requested by --warm <file> have been processed (and checks timeout before unpacking each record).

Verification

  • cargo test -p victory --locked — 2 passed, 0 failed (including new shader::tests::raw_sources_slice_to_container_total_size)
  • cargo clippy -p victory --all-targets --all-features --locked --no-deps -- -D warnings — 0 warnings
  • cargo xtask policy — asset policy: 171 files ok

(AI-assisted; synthetic unit tests only, no game data.)

**@⁠AscilCH** on GitHub · 2026-11-25 06:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/748) `AscilCH:fix/cli-shader-raw-slice-and-warm-early-stop` → `main` · +72 −10 · 2 files · 1 commits · open ## Summary Fixes two bugs in the CLI shader scanner and offline shader cache warm-up tool: 1. **Raw DXBC containers included trailing file bytes (`apps/victory/src/shader.rs`)**: - `sources()` previously constructed `Source::Raw { offset, data: &data[offset..] }` without slicing to the DXBC container's validated `total_size` field at offset `0x18..0x1c`. - Every downstream consumer hashed, cached, or dumped the entire remainder of the enclosing file along with the container: - `translate --warm <file>` failed to match hashes logged at runtime for uncompressed containers; - `translate --warm all` cached raw containers under `blake3(build || container || rest_of_file)` (guaranteed cache miss at runtime) and performed O(N × file size) hashing; - `VICTORY_TRANSLATE_ONLY`, `VICTORY_DUMP_MATCH`, and `VICTORY_FAIL_DUMP` hashed/dumped trailing binary bytes. - `sources()` now slices each raw container to `&tail[..total]`. 2. **Outer directory walk ignored stop conditions in `translate::warm` (`apps/victory/src/translate.rs`)**: - When `VICTORY_WARM_SECONDS` expired, only the inner per-file worker loop broke while the outer `WalkDir` loop continued reading every remaining file into memory and spawning threads. - `warm()` now breaks out of the outer walk immediately on timeout or once all hashes requested by `--warm <file>` have been processed (and checks timeout before unpacking each record). ## Verification - `cargo test -p victory --locked` — `2 passed, 0 failed` (including new `shader::tests::raw_sources_slice_to_container_total_size`) - `cargo clippy -p victory --all-targets --all-features --locked --no-deps -- -D warnings` — 0 warnings - `cargo xtask policy` — `asset policy: 171 files ok` *(AI-assisted; synthetic unit tests only, no game data.)*
- `apps/victory/src/shader.rs`: `sources()` previously returned `&data[offset..]` (the entire remainder of the enclosing binary/archive) for `Source::Raw` DXBC containers instead of slicing to the container header's `total_size` (`0x18..0x1c`). That caused `translate --warm`, `VICTORY_TRANSLATE_ONLY`, `VICTORY_DUMP_MATCH`, and `VICTORY_FAIL_DUMP` to hash, cache, and dump trailing file bytes alongside every raw container, breaking hash matching and shader-cache hits at runtime. Slice each `Source::Raw` to `&tail[..total]`.
- `apps/victory/src/translate.rs`: stop the outer directory walk in `warm()` once `VICTORY_WARM_SECONDS` expires or all requested hashes in `--warm <file>` have been warmed, avoiding reading remaining files from disk after stopping.

Adds a synthetic unit test in `apps/victory/src/shader.rs` verifying exact container slicing and hash stability across offsets.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:12 +00:00
Author
Owner

@⁠yualk on GitHub · 2026-11-25 06:52 UTC · original

Independent Windows x64 locked diag check on fecaa1e9681cf8da8a19eb105fc25df73038a6d4: the focused source test passes. With two authored DXBCs concatenated in one file, targeting the first key publishes an actual runtime cache hit; the unrequested second key and changed wave setting stay cold. --warm all then hits both in separate actual runtime lookups, each matching a fresh translation's bytes and metadata. This covers the failure reported in #736; no duplicate fix needed.

Separate early-stop control: two explicit CLI input paths, a standalone authored DXBC already matching on both builds followed by 64 MiB of authored non-DXBC padding. Fresh cache per arm, one selected key and one worker. ABBA GetProcessIoCounters.ReadTransferCount was 67,111,542 / 2,678 / 2,678 / 67,111,542 bytes (8dd30ab / PR / PR / 8dd30ab). Putting padding first on the PR restored exactly 67,111,542 bytes. Every arm publishes the same valid runtime hit. That is process read volume on an owned fixture, not disk IOPS, a hard timeout guarantee, PSO warming, or gameplay performance. No title material used or attached. AI-assisted.

**@⁠yualk** on GitHub · 2026-11-25 06:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/748#issuecomment-7155249772) Independent Windows x64 locked `diag` check on `fecaa1e9681cf8da8a19eb105fc25df73038a6d4`: the focused source test passes. With two authored DXBCs concatenated in one file, targeting the first key publishes an actual runtime cache hit; the unrequested second key and changed wave setting stay cold. `--warm all` then hits both in separate actual runtime lookups, each matching a fresh translation's bytes and metadata. This covers the failure reported in #736; no duplicate fix needed. Separate early-stop control: two explicit CLI input paths, a standalone authored DXBC already matching on both builds followed by 64 MiB of authored non-DXBC padding. Fresh cache per arm, one selected key and one worker. ABBA `GetProcessIoCounters.ReadTransferCount` was 67,111,542 / 2,678 / 2,678 / 67,111,542 bytes (`8dd30ab` / PR / PR / `8dd30ab`). Putting padding first on the PR restored exactly 67,111,542 bytes. Every arm publishes the same valid runtime hit. That is process read volume on an owned fixture, not disk IOPS, a hard timeout guarantee, PSO warming, or gameplay performance. No title material used or attached. AI-assisted.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/748/head:github-bot/gh-748'
git switch 'github-bot/gh-748'

Merge

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