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

Open
sharan104 wants to merge 1 commit from upstream-pr/263 into main
sharan104 commented 2026-11-26 13:35:37 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T13:35:37Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6627818044 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/263). Originally posted by [sharan104](https://github.com/sharan104) on 2026-11-26T13:35:37Z. --- `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)
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/263:upstream-pr/263'
git switch 'upstream-pr/263'

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/263'
git switch 'upstream-pr/263'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/263'
git switch 'upstream-pr/263'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/263'
git switch 'main'
git merge --squash 'upstream-pr/263'
git switch 'main'
git merge --ff-only 'upstream-pr/263'
git switch 'main'
git merge 'upstream-pr/263'
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
avatarmanz/VIctory-7900XTX!263
No description provided.