Use MD5's constant table instead of 64 sin() per block #64

Closed
github-bot wants to merge 1 commit from github-bot/gh-64 into main AGit
Owner

@⁠romainhedouin on GitHub · 2026-11-25 13:16 UTC · original
romainhedouin:perf/md5-constant-table → main · +25 −8 · 1 files · 1 commits · closed without merging

Every translated shader container is hashed with MD5. For each 64-byte block, md5_block allocated a Vec for the 16 message words and recomputed the 64 round constants with sin(). The constants are now the standard fixed table and the words live on the stack. The hash is bit-for-bit the same: a new test checks that each table entry equals the old sin() formula, and md5_core_matches_the_standard still passes.

Release mode, on a Mac Before After
md5_block throughput (same process, 3 runs) 233–245 MB/s 369–379 MB/s
Allocations / sin() calls per 64-byte block 1 / 64 0 / 0
Share of translating a 313 KB container ~9–10% ~5.8%

cargo test -p victory-shader passes. Speeds up shader translation (loading and stutters), not the frame itself.

🤖 Generated with Claude Code

**@⁠romainhedouin** on GitHub · 2026-11-25 13:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/64) `romainhedouin:perf/md5-constant-table` → `main` · +25 −8 · 1 files · 1 commits · closed without merging Every translated shader container is hashed with MD5. For each 64-byte block, `md5_block` allocated a `Vec` for the 16 message words and recomputed the 64 round constants with `sin()`. The constants are now the standard fixed table and the words live on the stack. The hash is bit-for-bit the same: a new test checks that each table entry equals the old `sin()` formula, and `md5_core_matches_the_standard` still passes. | Release mode, on a Mac | Before | After | |---|---|---| | `md5_block` throughput (same process, 3 runs) | 233–245 MB/s | 369–379 MB/s | | Allocations / `sin()` calls per 64-byte block | 1 / 64 | 0 / 0 | | Share of translating a 313 KB container | ~9–10% | ~5.8% | `cargo test -p victory-shader` passes. Speeds up shader translation (loading and stutters), not the frame itself. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:34:50 +00:00
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-25 16:36 UTC · original

Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at 336cd30: cargo test -p victory-shader --lib --locked: 267 passed, 0 failed, 6 ignored, hardware dispatch tests included (main at 01aadd1: 266 passed). Workspace tests only; not run in the title.

**@⁠ySKELLETONX** on GitHub · 2026-11-25 16:36 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/64#issuecomment-7168250009) Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at `336cd30`: `cargo test -p victory-shader --lib --locked`: **267 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). Workspace tests only; not run in the title.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:47 UTC · original

Checked against the game's shaders.rpf on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (336cd30) applied to 01aadd1 and its own target dir. victory translate --validate --list --host-lanes 32-64 with a hash of every emitted program's DXIL (a local, uncommitted patch): all 25,623 emitted programs are byte for byte the same as on 01aadd1, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of 01aadd1 give the same hashes, so the comparison is deterministic. cargo test -p victory-shader --lib -- --test-threads=1: 267 passed, 0 failed, 6 ignored. Not run in the game.

**@⁠adrianmjim** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/64#issuecomment-7170000911) Checked against the game's `shaders.rpf` on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (`336cd30`) applied to `01aadd1` and its own target dir. `victory translate --validate --list --host-lanes 32-64` with a hash of every emitted program's DXIL (a local, uncommitted patch): **all 25,623 emitted programs are byte for byte the same as on `01aadd1`**, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of `01aadd1` give the same hashes, so the comparison is deterministic. `cargo test -p victory-shader --lib -- --test-threads=1`: 267 passed, 0 failed, 6 ignored. Not run in the game.
github-bot closed this pull request 2026-11-27 01:00:47 +00:00
Author
Owner

@⁠romainhedouin on GitHub · 2026-11-26 22:54 UTC · original

Closing: a-publier already uses a constant K table and a stack [u32; 16] in md5_block (from 200bde4), so there are no sin() calls per block left to remove. Thanks for the test runs.

**@⁠romainhedouin** on GitHub · 2026-11-26 22:54 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/64#issuecomment-7205087027) Closing: `a-publier` already uses a constant `K` table and a stack `[u32; 16]` in `md5_block` (from 200bde4), so there are no `sin()` calls per block left to remove. Thanks for the test runs.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.