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

Open
0xkn0wh3r3 wants to merge 1 commit from upstream-pr/2950 into main
0xkn0wh3r3 commented 2026-11-26 01:22:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T01:22:12Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6617339545 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2950). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T01:22:12Z. --- ## 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.
fuzeofficlal commented 2026-11-26 02:07:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:31:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179864865 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7179864865). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:31:55Z. --- 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.
cloph-dsp commented 2026-11-26 02:07:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T01:35:06Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179918912 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7179918912). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T01:35:06Z. --- 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).
kotekompotek commented 2026-11-26 03:04:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:24:16Z.

Review: COMMENTED


Verified: inflate_one preserves the exact semantics the archive scan needs — StreamEnd + total_in/total_out for chained zlib streams at 16-byte alignment. zlib-rs 0.6.x is a solid choice (pure Rust, runtime SIMD). The pinned lock entry and the new edge tests (truncated, oversized, non-zlib, trailing bytes) cover the contract.

<!-- greyfinch-sync:Marvisak/VIctory:review:6067731144 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2950#pullrequestreview-6067731144). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T02:24:16Z. **Review:** COMMENTED --- Verified: inflate_one preserves the exact semantics the archive scan needs — StreamEnd + total_in/total_out for chained zlib streams at 16-byte alignment. zlib-rs 0.6.x is a solid choice (pure Rust, runtime SIMD). The pinned lock entry and the new edge tests (truncated, oversized, non-zlib, trailing bytes) cover the contract.
Marvisak commented 2026-11-26 05:04:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:29:47Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182644977 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7182644977). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:29:47Z. --- <!-- 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)_
0xkn0wh3r3 commented 2026-11-26 07:01:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T07:00:30Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7185000166 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2950#issuecomment-7185000166). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T07:00:30Z. --- 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 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/2950:upstream-pr/2950'
git switch 'upstream-pr/2950'

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