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

Open
github-bot wants to merge 1 commit from github-bot/gh-1355 into main AGit
Owner

@⁠wbkepler on GitHub · 2026-11-24 17:35 UTC · original
wbkepler:hle/simd-zlib-decompression → main · +304 −50 · 10 files · 1 commits · open

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)
**@⁠wbkepler** on GitHub · 2026-11-24 17:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1355) `wbkepler:hle/simd-zlib-decompression` → `main` · +304 −50 · 10 files · 1 commits · open ## 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)
Replace the scalar miniz_oxide dependency across the workspace with
zlib-rs 0.6.8 (pure Rust, Zlib-licensed, runtime AVX2/BMI2/SSE4.2
dispatch, rust-allocator via std with no C allocator or libc).

- victory-hle (dstorage): reuse a thread-local zlib_rs::Inflate state
  on DirectStorage worker threads to avoid per-chunk state allocations,
  preserving short-stream tolerance and exact error rejection on
  oversized, truncated, or bad-checksum streams.
- victory-shader (native XBCH) and victory-game (SGD5 raw deflate):
  inflate incrementally up to the stated unpacked size with exact
  StreamEnd and length checks without eagerly allocating absurd header
  sizes up front.
- victory-gpu (capture): switch diagnostic PNG IDAT compression to
  zlib_rs::compress_slice so miniz_oxide can be dropped completely from
  the workspace.
- Add unit tests covering exact-fit, short-output, empty, oversized,
  truncated, and bad-checksum streams across dstorage, native, and sgd5.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:35 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:23 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1355#issuecomment-7149501422) <!-- 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)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 01:48 UTC · original

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).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 01:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1355#issuecomment-7149982260) ### 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).
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:50 UTC · original

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.

**@⁠Headache3318** on GitHub · 2026-11-25 01:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1355#issuecomment-7150022354) 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 has changes conflicting with the target branch.
  • crates/victory-game/src/sgd5.rs
  • crates/victory-shader/src/native.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1355/head:github-bot/gh-1355'
git switch 'github-bot/gh-1355'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1355'
git switch 'github-bot/gh-1355'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1355'
git switch 'github-bot/gh-1355'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1355'
git switch 'main'
git merge --squash 'github-bot/gh-1355'
git switch 'main'
git merge --ff-only 'github-bot/gh-1355'
git switch 'main'
git merge 'github-bot/gh-1355'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1355
No description provided.