Grow DirectStorage BCPack intermediates as zlib inflates #1238

Closed
github-bot wants to merge 1 commit from gh-pr/1238/head into gh-pr/1238/base
Owner

@⁠Jitheswar on GitHub · 2026-11-24 16:43 UTC · original
directstorage-sized-intermediate → main · +36 −8 · 1 files · 1 commits · closed without merging

BCPack requests with a zlib stage inflate into an intermediate buffer before BCPack decoding. That buffer was allocated at the request's intermediate_size up front, vec![0; intermediate_size], and truncated after inflating. Titles pass a generous limit there, so each such request zero-filled a buffer far larger than its data (64 MiB for a small texture in the test fixture).

What changes: inflate_intermediate uses miniz_oxide's decompress_to_vec_zlib_with_limit. The buffer grows as bytes arrive and never exceeds the limit. Inflate errors map to INVALID_DATA, as before.

Test (synthetic): zlib_intermediate_grows_with_output_and_respects_its_limit:

  • 2 KiB of data inflates identically with a 64 MiB limit, and the buffer's capacity stays below the limit;
  • an exact limit works, and one byte short is refused;
  • a corrupted Adler-32 checksum is still refused with room to spare.

For the BC4 fixture, intermediate capacity drops from 64 MiB to 116 bytes, with identical decoded output. Windows-target clippy and the asset policy pass. victory-hle tests for the Windows target under Proton 11, merged onto 940d32f: 142 passed / 2 failed. Plain 940d32f gives 141 / 2 with the same two Wine-host failures (only_loopback_is_reachable, a_kept_blob_past_the_link_limit_is_copied); this PR adds the test above. Not run in the game for this change. Merges cleanly onto 940d32f.

AI-assisted (Claude Code, Codex).

🤖 Generated with Claude Code

**@⁠Jitheswar** on GitHub · 2026-11-24 16:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1238) `directstorage-sized-intermediate` → `main` · +36 −8 · 1 files · 1 commits · closed without merging BCPack requests with a zlib stage inflate into an intermediate buffer before BCPack decoding. That buffer was allocated at the request's `intermediate_size` up front, `vec![0; intermediate_size]`, and truncated after inflating. Titles pass a generous limit there, so each such request zero-filled a buffer far larger than its data (64 MiB for a small texture in the test fixture). **What changes:** `inflate_intermediate` uses `miniz_oxide`'s `decompress_to_vec_zlib_with_limit`. The buffer grows as bytes arrive and never exceeds the limit. Inflate errors map to `INVALID_DATA`, as before. **Test (synthetic):** `zlib_intermediate_grows_with_output_and_respects_its_limit`: - 2 KiB of data inflates identically with a 64 MiB limit, and the buffer's capacity stays below the limit; - an exact limit works, and one byte short is refused; - a corrupted Adler-32 checksum is still refused with room to spare. For the BC4 fixture, intermediate capacity drops from 64 MiB to 116 bytes, with identical decoded output. Windows-target clippy and the asset policy pass. `victory-hle` tests for the Windows target under Proton 11, merged onto `940d32f`: 142 passed / 2 failed. Plain `940d32f` gives 141 / 2 with the same two Wine-host failures (`only_loopback_is_reachable`, `a_kept_blob_past_the_link_limit_is_copied`); this PR adds the test above. Not run in the game for this change. Merges cleanly onto `940d32f`. AI-assisted (Claude Code, Codex). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:24:37 +00:00
github-bot closed this pull request 2026-11-26 04:24:37 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 17:59 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 591932a: cargo test -p victory-hle passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 17:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1238#issuecomment-7140000135) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 591932a: `cargo test -p victory-hle` passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

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

Automated triage for the maintainers.

Needs work. In execute (crates/victory-hle/src/modules/dstorage.rs), the zlib-then-BCPack path now inflates with decompress_to_vec_zlib_with_limit instead of zeroing a buffer of intermediate_size up front. The change is correct: the limit is still enforced, the Adler-32 checksum is still checked, and the error mapping is unchanged. zlib_intermediate_grows_with_output_and_respects_its_limit covers all three.

The benefit isn't shown for the title, though. The "64 MiB → 116 bytes" figure comes from a synthetic test limit. If the title's requests give an intermediate_size close to the inflated size, as the existing inflate comment suggests its chunks do, this only adds reallocations and copies as the vector grows. Please show the gap between intermediate_size and the inflated size on real requests (the existing dstorage trace logs intermediate_size), or a measurement where the up-front allocation costs something.

CI: not run.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1238#issuecomment-7149559083) <!-- victory-triage v1 head=591932ac8ce4645e42d702bf72f0d96b298987bf verdict=needs-work at=2026-11-25T01:27:00Z --> Automated triage for the maintainers. **Needs work.** In `execute` (`crates/victory-hle/src/modules/dstorage.rs`), the zlib-then-BCPack path now inflates with `decompress_to_vec_zlib_with_limit` instead of zeroing a buffer of `intermediate_size` up front. The change is correct: the limit is still enforced, the Adler-32 checksum is still checked, and the error mapping is unchanged. `zlib_intermediate_grows_with_output_and_respects_its_limit` covers all three. The benefit isn't shown for the title, though. The "64 MiB → 116 bytes" figure comes from a synthetic test limit. If the title's requests give an `intermediate_size` close to the inflated size, as the existing `inflate` comment suggests its chunks do, this only adds reallocations and copies as the vector grows. Please show the gap between `intermediate_size` and the inflated size on real requests (the existing `dstorage` trace logs `intermediate_size`), or a measurement where the up-front allocation costs something. CI: not run. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Jitheswar on GitHub · 2026-11-25 02:38 UTC · original

Measured as requested, and the review was right. I logged intermediate_size against the inflated length on every zlib-then-BCPack request, local probe only, Grand Theft Auto VI Xbox Series 1.0.2.1 (my own dump), RTX 3050 6 GB under Proton. Two runs, through boot, the menus and about two minutes into the story load and world streaming: zero such requests. On what this title does early on, the path never runs, so there's no measured benefit to set against the extra reallocations you pointed out. Closing; I'll reopen with numbers if a later phase turns out to use it. Thanks for the careful review. AI-assisted (Claude Code).

**@⁠Jitheswar** on GitHub · 2026-11-25 02:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1238#issuecomment-7150978521) Measured as requested, and the review was right. I logged `intermediate_size` against the inflated length on every zlib-then-BCPack request, local probe only, Grand Theft Auto VI Xbox Series 1.0.2.1 (my own dump), RTX 3050 6 GB under Proton. Two runs, through boot, the menus and about two minutes into the story load and world streaming: **zero such requests**. On what this title does early on, the path never runs, so there's no measured benefit to set against the extra reallocations you pointed out. Closing; I'll reopen with numbers if a later phase turns out to use it. Thanks for the careful review. AI-assisted (Claude Code).

Pull request closed

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!1238
No description provided.