HLE & Formats: replace miniz_oxide with SIMD-accelerated zlib-rs #1355

Open
wbkepler wants to merge 1 commit from upstream-pr/1355 into main
wbkepler commented 2026-11-24 17:35:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T17:35:20Z.


Summary

Replaces scalar miniz_oxide across the workspace with pure-Rust, Zlib-licensed zlib-rs = "0.6.8" (default-features = false, features = ["std"], runtime AVX2/BMI2/SSE4.2 dispatch, zero C compiler/libc, zero new unsafe):

  • victory-hle (dstorage.rs): Reuses a thread-local zlib_rs::Inflate state per DirectStorage worker thread, handling empty destinations and preserving short-stream tolerance plus INVALID_DATA rejection on oversized, truncated, or bad-checksum streams.
  • victory-shader (native.rs XBCH) & victory-game (sgd5.rs raw deflate): Incremental streaming zlib_rs::Inflate capped at declared unpacked size with exact Status::StreamEnd and length verification.
  • victory-gpu (capture.rs): Switches diagnostic PNG IDAT compression to zlib_rs::compress_slice, removing miniz_oxide completely from Cargo.toml/Cargo.lock.
  • Adds 3 unit tests covering exact-fit, short-output, empty, oversized, truncated, and bad-checksum streams across dstorage, native, and sgd5.

Verification

  • cargo clippy --workspace --all-targets & -p victory --features diagnostics --all-targets — passed (0 new warnings)
  • cargo test --workspace — passed
  • cargo xtask policy — passed (151 files ok)
<!-- greyfinch-sync:Marvisak/VIctory:issue:6587735720 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1355). Originally posted by [wbkepler](https://github.com/wbkepler) on 2026-11-24T17:35:20Z. --- ## Summary Replaces scalar `miniz_oxide` across the workspace with pure-Rust, Zlib-licensed `zlib-rs = "0.6.8"` (`default-features = false, features = ["std"]`, runtime AVX2/BMI2/SSE4.2 dispatch, zero C compiler/`libc`, zero new `unsafe`): - **`victory-hle` (`dstorage.rs`)**: Reuses a thread-local `zlib_rs::Inflate` state per DirectStorage worker thread, handling empty destinations and preserving short-stream tolerance plus `INVALID_DATA` rejection on oversized, truncated, or bad-checksum streams. - **`victory-shader` (`native.rs` XBCH) & `victory-game` (`sgd5.rs` raw deflate)**: Incremental streaming `zlib_rs::Inflate` capped at declared unpacked size with exact `Status::StreamEnd` and length verification. - **`victory-gpu` (`capture.rs`)**: Switches diagnostic PNG IDAT compression to `zlib_rs::compress_slice`, removing `miniz_oxide` completely from `Cargo.toml`/`Cargo.lock`. - Adds 3 unit tests covering exact-fit, short-output, empty, oversized, truncated, and bad-checksum streams across `dstorage`, `native`, and `sgd5`. ## Verification - `cargo clippy --workspace --all-targets` & `-p victory --features diagnostics --all-targets` — passed (0 new warnings) - `cargo test --workspace` — passed - `cargo xtask policy` — passed (151 files ok)
catminou4 commented 2026-11-24 18:04:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:42:46Z.

Review: COMMENTED


miniz_oxide -> zlib-rs swap. Cargo.lock is consistent (miniz_oxide+adler2 out, zlib-rs in). On macOS I could only verify victory-game: it compiles and its 3 tests pass, and sgd5.rs uses the streaming Inflate/Deflate API. victory-hle/victory-formats are not buildable on macOS, so the HLE side of the swap is unverified here — if those call sites use the same zlib_rs API style it should be fine, but please make sure the Windows CI leg covers victory-hle before merge. zlib-rs is a reasonable, memory-safe choice (SIMD inflate, used by Firefox). Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host/diff_tests) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-game: 3 passed, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:review:6044389570 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1355#pullrequestreview-6044389570). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T17:42:46Z. **Review:** COMMENTED --- miniz_oxide -> zlib-rs swap. Cargo.lock is consistent (miniz_oxide+adler2 out, zlib-rs in). On macOS I could only verify victory-game: it compiles and its 3 tests pass, and sgd5.rs uses the streaming Inflate/Deflate API. victory-hle/victory-formats are not buildable on macOS, so the HLE side of the swap is unverified here — if those call sites use the same zlib_rs API style it should be fine, but please make sure the Windows CI leg covers victory-hle before merge. zlib-rs is a reasonable, memory-safe choice (SIMD inflate, used by Firefox). Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p <crate> --locked`. Shader execution tests (valu_tests/host/diff_tests) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. victory-game: 3 passed, 0 failed.
Marvisak commented 2026-11-25 02:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:23:48Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-game/src/sgd5.rs, crates/victory-shader/src/native.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149501422 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1355#issuecomment-7149501422). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:23:48Z. --- <!-- victory-triage v1 head=2e602026c13ae82c66ef672b27fe49f603e775c0 verdict=needs-rebase at=2026-11-25T01:23:46Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-game/src/sgd5.rs`, `crates/victory-shader/src/native.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 02:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:48:37Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 2e60202 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149982260 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1355#issuecomment-7149982260). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T01:48:37Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 2e60202 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 121, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Headache3318 commented 2026-11-25 02:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:50:39Z.


Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 2e60202 applied cleanly onto current main ccfb029.

  • cargo test -p victory-game --locked: 3 passed (the new zlib-rs streaming tests pass on Linux).
  • cargo test -p victory-shader --locked: 57 passed (fewer than main because GPU tests are skipped without dxil.dll).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 1 new unused-function error in test code (constant_color), but main has 4 pre-existing errors (unused imports, unused variable, dead field). The PR net-reduces clippy errors from 4 to 1.
  • cargo clippy --workspace --all-targets -- -D warnings: fails on victory-gpu (E0425) on Linux — same as main. This PR does not fix the Linux build.

Not tested: Windows MSVC build, the title itself. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150022354 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1355#issuecomment-7150022354). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T01:50:39Z. --- Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `2e60202` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-game --locked`: 3 passed (the new zlib-rs streaming tests pass on Linux). - `cargo test -p victory-shader --locked`: 57 passed (fewer than main because GPU tests are skipped without dxil.dll). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 1 new unused-function error in test code (`constant_color`), but main has 4 pre-existing errors (unused imports, unused variable, dead field). The PR net-reduces clippy errors from 4 to 1. - `cargo clippy --workspace --all-targets -- -D warnings`: fails on victory-gpu (E0425) on Linux — same as main. This PR does not fix the Linux build. Not tested: Windows MSVC build, the title itself. AI-assisted.
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/1355:upstream-pr/1355'
git switch 'upstream-pr/1355'

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