perf(shader): speed up DXBC container hashing #334

Open
brainbudt wants to merge 1 commit from upstream-pr/334 into main
brainbudt commented 2026-11-26 17:26:13 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by brainbudt on 2026-11-26T17:26:13Z.


Problem

Emitting a DXBC container allocates a temporary heap buffer for MD5 padding and computes the message index and rotation per compression step at runtime.

Change

Build the final one or two blocks in a 128-byte stack buffer and unroll all 64 MD5 steps in pure safe Rust (crates/victory-shader/src/emit/container.rs), preserving DXBC's non-standard padding byte-for-byte.

Verification

  • cargo test -p victory-shader --lib container (5 passed) and dxbc (2 passed), cargo clippy -p victory-shader --lib -- -D warnings, and cargo xtask policy (266 files) all passed.
  • Padded blocks and digests matched HEAD byte-for-byte across 1,155 independent length comparisons covering the 55/56-byte padding boundary.
  • Hash microbenchmark: 1.69–1.93× speedup on macOS ARM64 across 0 B–1 MiB (1.17–1.29× on Linux x86-64).

Reviewed by GPT-6.2 Sol in Codex (APPROVE); implemented with Mistral Large 4 in Mistral Vibe (orchestrated with Gemini 4 Neon in T3 Code).

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6631927113 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/334). Originally posted by [brainbudt](https://github.com/brainbudt) on 2026-11-26T17:26:13Z. --- ## Problem Emitting a DXBC container allocates a temporary heap buffer for MD5 padding and computes the message index and rotation per compression step at runtime. ## Change Build the final one or two blocks in a 128-byte stack buffer and unroll all 64 MD5 steps in pure safe Rust (`crates/victory-shader/src/emit/container.rs`), preserving DXBC's non-standard padding byte-for-byte. ## Verification - `cargo test -p victory-shader --lib container` (5 passed) and `dxbc` (2 passed), `cargo clippy -p victory-shader --lib -- -D warnings`, and `cargo xtask policy` (266 files) all passed. - Padded blocks and digests matched HEAD byte-for-byte across 1,155 independent length comparisons covering the 55/56-byte padding boundary. - Hash microbenchmark: 1.69–1.93× speedup on macOS ARM64 across 0 B–1 MiB (1.17–1.29× on Linux x86-64). --- Reviewed by GPT-6.2 Sol in Codex (APPROVE); implemented with Mistral Large 4 in Mistral Vibe (orchestrated with Gemini 4 Neon in T3 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/334:upstream-pr/334'
git switch 'upstream-pr/334'

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