Shaders: speed up DXBC container MD5 hashing by 16-43% #2808
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2808
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2808"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@brainbudt on GitHub · 2026-11-25 21:06 UTC · original
brainbudt:perf/dxbc-md5-hash→main· +190 −58 · 2 files · 1 commits · openEvery emitted DXBC container is MD5-hashed, and the compressor previously selected word schedules and rotation amounts inside its 64-step loop while allocating a temporary buffer to finalize each digest.
What changed
crates/victory-shader/src/emit/container.rs.Benchmark (8,652-byte synthetic 5-part container, median of 5 alternating release runs)
Verification
cargo check -p victory-shader --target x86_64-pc-windows-msvc --testsand all-target Clippy-D warningspassed (default and all features).Reviewed with mistral-loop: 2 rounds with Mistral Large 4 and DeepSeek V4.1 Flash on high. Verdict: approved.
Created with gpt-6.2-astra in Codex (orchestrated with Gemini 4 Neon in T3 Code).
@fuzeofficlal on GitHub · 2026-11-25 21:23 UTC · original
Reviewed and benchmarked
7d7efe35on Windows 11 againstmain(13f91ca).Code review & byte-exactness
as_chunks::<64>()/as_chunks::<4>()), unrolling all 4 MD5 rounds and removing the temporarytailVecallocation while preserving DXBC's non-standard padding (len << 3andlen << 1 | 1) across bothrest.len() < 56andrest.len() >= 56boundaries.0..=256(all 64-byte remainder classes plus block boundaries55, 56, 63, 64, 119, 120, 128) as well as511, 512, 513, 4095, 4096against13f91ca: 100% byte-identical digests.Verification & same-machine
--releasebenchmark (rustc 1.98.1MSVC, Windows SDK10.0.26100.0)emit::container dxbc::): 6/6 passed; WARP +dxil.dllfullvictory-shader --features host: 270 passed, 0 failed (skipping only the 3 hardware-onlysynthetic_tests).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok; cleangit merge-treevs13f91ca.container_throughput(--release, 5-run median, 8,652 B 5-part container):build + hash:10,264.1 ns/op(13f91ca) ->9,385.8 ns/op(-8.6% / 1.09× on MSVC, withbuild()container allocation dominating the remainder).@cloph-dsp on GitHub · 2026-11-25 21:25 UTC · original
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup, CARGO_BUILD_JOBS=2.
cargo test --locked -p victory-shader --lib container --quiet-> 3 passed, 1 ignored benchmark, 0 failed (273 filtered out).cargo test --locked -p victory-shader --lib reports_malformed_fields --quiet-> 1 passed.git diff --check origin/main..HEADclean.odd_parts_match_wire_bytes,dxbc_hash_padding_boundariesandreports_malformed_fieldsare all absent from origin/main, so the wire-byte, digest-boundary and malformed-field coverage is new here.emit::memory_tests::heap_direct_texture_reads_mark_their_heap_indexcrashes on unmodified base13f91caon this machine (pre-existing).AI-assisted (Hy4 flash).
@Marvisak on GitHub · 2026-11-26 02:18 UTC · original
Automated triage for the maintainers.
This speeds up the DXBC container hash in
emit/container.rs:hashbuilds its padded tail in a stack array instead of aVec, andmd5_blockis unrolled by round. I checked the unrolled step order, the per-round message schedules ((5i+1),(3i+5),7imod 16 give the same words as the global index), and both tail cases (rest < 56and>= 56) against the old code. They match, anddxbc_hash_padding_boundariespins the old digests at the block boundaries. The newreports_malformed_fieldstest covers existing parse errors. The benchmark is#[ignore]d.CI: passing.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.