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

Open
AscilCH wants to merge 1 commit from upstream-pr/748 into main
AscilCH commented 2026-11-25 06:09:49 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T06:09:49Z.


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.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6598394800 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/748). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T06:09:49Z. --- ## 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.)*
yualk commented 2026-11-25 07:06:18 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by yualk on 2026-11-25T06:52:32Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155249772 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/748#issuecomment-7155249772). Originally posted by [yualk](https://github.com/yualk) on 2026-11-25T06:52:32Z. --- 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 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/748:upstream-pr/748'
git switch 'upstream-pr/748'

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