Shaders found as is end where their header says, not at the end of the file (their hashes matched no run) #263

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

@⁠sharan104 on GitHub · 2026-11-26 13:35 UTC · original
sharan104:fix/raw-container-size → main · +45 −5 · 1 files · 1 commits · open

apps/victory/src/shader.rs sources() finds uncompressed containers by their DXBC magic. But it handed each one on as everything from its offset to the end of the file. Container::parse tolerates the trailing bytes, so nothing failed. Every caller that hashes or stores the bytes, though, took the whole tail:

  • the #hash that shader-info and translate print
  • VICTORY_TRANSLATE_ONLY
  • translate --warm's matching against a run's log
  • the cache key in victory shaders
  • replay --retranslate
  • the .cdxil dumps

A run hashes only the container the title passes (victory-gpu pipeline.rs, shader()). So for raw containers no hash matched, and victory shaders cached them under keys no run looks up. Each one also hashed the rest of the file, which is quadratic over a file with many containers.

Fix: a raw container is cut to the total size in its header (offset 0x18), the same way SGD5 records already are. Containers whose header size runs past the file are dropped.

Test: shader::tests::raw_containers_end_where_their_header_says uses synthetic containers with bytes before, between and after them. It checks each source is exactly its container, and that the same container hashes the same wherever it sits. It fails before the change and passes after it (10 runs out of 10).

Results:

  • cargo test -p victory --locked passes.
  • cargo clippy -p victory --all-targets --locked --no-deps -- -D warnings is clean, with and without --all-features.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 13:35 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/263) `sharan104:fix/raw-container-size` → `main` · +45 −5 · 1 files · 1 commits · open `apps/victory/src/shader.rs` `sources()` finds uncompressed containers by their `DXBC` magic. But it handed each one on as **everything from its offset to the end of the file**. `Container::parse` tolerates the trailing bytes, so nothing failed. Every caller that hashes or stores the bytes, though, took the whole tail: - the `#hash` that `shader-info` and `translate` print - `VICTORY_TRANSLATE_ONLY` - `translate --warm`'s matching against a run's log - the cache key in `victory shaders` - `replay --retranslate` - the `.cdxil` dumps A run hashes only the container the title passes (`victory-gpu` `pipeline.rs`, `shader()`). So for raw containers no hash matched, and `victory shaders` cached them under keys no run looks up. Each one also hashed the rest of the file, which is quadratic over a file with many containers. **Fix:** a raw container is cut to the total size in its header (offset `0x18`), the same way SGD5 records already are. Containers whose header size runs past the file are dropped. **Test:** `shader::tests::raw_containers_end_where_their_header_says` uses synthetic containers with bytes before, between and after them. It checks each source is exactly its container, and that the same container hashes the same wherever it sits. It fails before the change and passes after it (10 runs out of 10). **Results:** - `cargo test -p victory --locked` passes. - `cargo clippy -p victory --all-targets --locked --no-deps -- -D warnings` is clean, with and without `--all-features`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sources() gave a container found by its DXBC magic as everything from
its offset to the end of the file. Container::parse accepts that (it
slices to the header's size itself), but every caller that hashes or
keeps the bytes took the whole tail: shader-info's and translate's
`#hash`, VICTORY_TRANSLATE_ONLY, translate --warm's match against a
run's log, `victory shaders`' cache key, replay --retranslate, and the
.cdxil dumps. A run hashes and caches the container the title passes,
so none of those hashes named it and `victory shaders` and
translate --warm cached the uncompressed containers under keys no run
looks up (and hashed a tail of the file per container doing it).

The raw source is now the container alone, by the size in its header,
as SGD5 records already are. The new test fails before the change and
passes after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:38:14 +00:00
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/263/head:github-bot/gh-263'
git switch 'github-bot/gh-263'

Merge

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