Game: the shader pack in an archive inflates through zlib-rs #2950

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

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 01:22 UTC · original
0xkn0wh3r3:game/shaderpack-inflates-with-zlib-rs → main · +89 −9 · 4 files · 1 commits · open

What

shaderpack::find() reads the shader pack an archive holds as a run of zlib streams of at most 64 KiB, and inflated each one with miniz_oxide. It now inflates each one with zlib-rs (pure Rust, runtime SIMD dispatch), in inflate_one. It's the same crate and version #1355 proposes for DirectStorage: zlib-rs = { version = "0.6.8", default-features = false, features = ["std"] }. miniz_oxide stays for the tests and the other users.

Measurement

600 streams of 64 KiB, release build, Ryzen 9 7900X, inflate_bench (ignored), medians of 5 rounds each:

time
miniz_oxide (as before) 19.7 ms
zlib-rs 10.0 ms

Where it came from

From DexNom's fork, DexNom/VIctory@570a941: find() with zlib_rs::Inflate. Credited with Co-authored-by: DexNom.

#1355 converts DirectStorage and the other inflaters but predates this function. Whichever lands second only needs the workspace dependency line deduplicated.

Tested

  • New test shaderpack::tests::one_stream_inflates_alone: a stream gives its output and the bytes it took even with data after it. A truncated stream, one larger than the chunk, and bytes that aren't a stream give nothing.
  • finds_a_pack_inside_an_archive passes as before.
  • cargo test -p victory-game: 16 passed.
  • cargo build --workspace: builds.
  • cargo clippy -p victory-game --all-targets -- -D warnings: clean.

Not tested

  • Not measured on the title's own archives, so the saving at startup is unknown.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 01:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2950) `0xkn0wh3r3:game/shaderpack-inflates-with-zlib-rs` → `main` · +89 −9 · 4 files · 1 commits · open ## What `shaderpack::find()` reads the shader pack an archive holds as a run of zlib streams of at most 64 KiB, and inflated each one with miniz_oxide. It now inflates each one with zlib-rs (pure Rust, runtime SIMD dispatch), in `inflate_one`. It's the same crate and version #1355 proposes for DirectStorage: `zlib-rs = { version = "0.6.8", default-features = false, features = ["std"] }`. miniz_oxide stays for the tests and the other users. ## Measurement 600 streams of 64 KiB, release build, Ryzen 9 7900X, `inflate_bench` (ignored), medians of 5 rounds each: | | time | |---|---:| | miniz_oxide (as before) | 19.7 ms | | zlib-rs | 10.0 ms | ## Where it came from From DexNom's fork, [DexNom/VIctory@570a941](https://github.com/DexNom/VIctory/commit/570a941e9b4e945121c26eb30dfc10c126845207): `find()` with `zlib_rs::Inflate`. Credited with `Co-authored-by: DexNom`. #1355 converts DirectStorage and the other inflaters but predates this function. Whichever lands second only needs the workspace dependency line deduplicated. ## Tested - New test `shaderpack::tests::one_stream_inflates_alone`: a stream gives its output and the bytes it took even with data after it. A truncated stream, one larger than the chunk, and bytes that aren't a stream give nothing. - `finds_a_pack_inside_an_archive` passes as before. - `cargo test -p victory-game`: 16 passed. - `cargo build --workspace`: builds. - `cargo clippy -p victory-game --all-targets -- -D warnings`: clean. ## Not tested - Not measured on the title's own archives, so the saving at startup is unknown.
find() reads the shader pack an archive holds as a run of zlib streams
of at most 64 KiB, each inflated through miniz_oxide. It now inflates
each through zlib-rs (pure Rust, runtime SIMD dispatch; the version
#1355 proposes for DirectStorage), in inflate_one.

600 streams of 64 KiB, release build, Ryzen 9 7900X (inflate_bench,
ignored; medians of 5 rounds each): miniz_oxide 19.7 ms, zlib-rs 10.0
ms.

Tests: one_stream_inflates_alone (output and bytes taken with data
after the stream; truncated, too large for the chunk and not a stream
give nothing); finds_a_pack_inside_an_archive as before.

From DexNom/VIctory@570a941e9b (find()
with zlib_rs::Inflate). #1355 converts DirectStorage and the other users
but predates this function.

Co-authored-by: DexNom <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:18:22 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:31 UTC · original

Code review and Windows 11 release benchmark verification at head 1d7602da385a on main (63bcca43c6a0):

  • Code review (crates/victory-game/src/shaderpack.rs:302-314, Cargo.toml/Cargo.lock):
    • Builds cleanly with --locked (zlib-rs 0.6.9, Zlib-licensed, pure Rust).
    • inflate_one uses Inflate::new(true, 15) into a fixed 0x20000 (128 KiB) buffer, requires Status::StreamEnd, rejects truncated/malformed/oversized (BufError) streams cleanly with None, and slices exact total_in() / total_out() lengths.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-game --tests -- -D warnings: 0 warnings
    • cargo test --locked -p victory-game: 16/16 passed (1 ignored bench, including one_stream_inflates_alone)
    • --release shaderpack::tests::inflate_bench: miniz_oxide: median 31.0 ms -> zlib-rs: median 14.5 ms (2.14x speedup).

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7179864865) Code review and Windows 11 release benchmark verification at head `1d7602da385a` on `main` (`63bcca43c6a0`): - **Code review (`crates/victory-game/src/shaderpack.rs:302-314`, `Cargo.toml`/`Cargo.lock`)**: - Builds cleanly with `--locked` (`zlib-rs 0.6.9`, Zlib-licensed, pure Rust). - `inflate_one` uses `Inflate::new(true, 15)` into a fixed `0x20000` (128 KiB) buffer, requires `Status::StreamEnd`, rejects truncated/malformed/oversized (`BufError`) streams cleanly with `None`, and slices exact `total_in()` / `total_out()` lengths. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-game --tests -- -D warnings`: 0 warnings - `cargo test --locked -p victory-game`: **16/16 passed** (1 ignored bench, including `one_stream_inflates_alone`) - `--release` `shaderpack::tests::inflate_bench`: `miniz_oxide: median 31.0 ms` -> `zlib-rs: median 14.5 ms` (**2.14x speedup**). LGTM.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 01:35 UTC · original

Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.

  • Diff against merge-base 842b0cb: 5 files, +93/-12. git diff --check flags one pre-existing-style trailing whitespace in README.md:17 (displayed. ); worth fixing.
  • Negative control: one_stream_inflates_alone is absent from the base commit.
  • cargo test --locked -p victory-game --lib -- shaderpack::tests::one_stream_inflates_alone --exact --quiet -> 1 passed, 16 filtered (CARGO_BUILD_JOBS=2).
  • Full crate: cargo test --locked -p victory-game --quiet -> 16 passed, 0 failed, 1 ignored.
  • Only a minor pre-existing warning in victory-hle.

AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-26 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7179918912) Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup. - Diff against merge-base 842b0cb: 5 files, +93/-12. `git diff --check` flags one pre-existing-style trailing whitespace in README.md:17 (`displayed. `); worth fixing. - Negative control: `one_stream_inflates_alone` is absent from the base commit. - `cargo test --locked -p victory-game --lib -- shaderpack::tests::one_stream_inflates_alone --exact --quiet` -> 1 passed, 16 filtered (CARGO_BUILD_JOBS=2). - Full crate: `cargo test --locked -p victory-game --quiet` -> 16 passed, 0 failed, 1 ignored. - Only a minor pre-existing warning in victory-hle. AI-assisted (Hy4 flash).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:29 UTC · original · edited 2026-11-26 07:19 UTC

Automated triage for the maintainers.

Thanks. No new push, so the verdict stays the same: this needs the maintainer's decision on bringing in zlib-rs. Both of your options work (land #1355 first and rebase this to only the inflate_one switch, or fold shaderpack.rs into #1355), and the maintainer can pick one.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7182644977) · edited 2026-11-26 07:19 UTC <!-- victory-triage v1 head=1d7602da385a9bf970159595c6a5565ac904a11d verdict=needs-work at=2026-11-26T07:19:00Z --> Automated triage for the maintainers. Thanks. No new push, so the verdict stays the same: this needs the maintainer's decision on bringing in `zlib-rs`. Both of your options work (land #1355 first and rebase this to only the `inflate_one` switch, or fold `shaderpack.rs` into #1355), and the maintainer can pick one. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 07:00 UTC · original

Agreed, the dependency should land once. #1355 (wbkepler) brings zlib-rs in for the larger users (the DirectStorage and formats inflate). This PR is only the shaderpack::find call site, which was added to main after #1355 branched, so #1355 doesn't cover it. I can't measure on the title's archives here.

Two options, whichever is easier for you:

  • merge #1355 first, and I rebase this down to the inflate_one switch plus its test, with no new dependency; or
  • fold the shaderpack.rs change into #1355 when it's rebased (it's conflicting right now), and close this.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 07:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7185000166) Agreed, the dependency should land once. #1355 (wbkepler) brings `zlib-rs` in for the larger users (the DirectStorage and formats inflate). This PR is only the `shaderpack::find` call site, which was added to main after #1355 branched, so #1355 doesn't cover it. I can't measure on the title's archives here. Two options, whichever is easier for you: - merge #1355 first, and I rebase this down to the `inflate_one` switch plus its test, with no new dependency; or - fold the `shaderpack.rs` change into #1355 when it's rebased (it's conflicting right now), and close this.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2950'
git switch 'github-bot/gh-2950'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2950'
git switch 'github-bot/gh-2950'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2950'
git switch 'main'
git merge --squash 'github-bot/gh-2950'
git switch 'main'
git merge --ff-only 'github-bot/gh-2950'
git switch 'main'
git merge 'github-bot/gh-2950'
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!2950
No description provided.