GPU capture: stream compressed PNG chunks to disk #3763

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3763 into main
andrewpozdnakov7-jpg commented 2026-11-28 16:57:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T16:57:05Z.


Write the PNG chunks through a buffered file writer. The compressed IDAT payload stays in its original allocation, and the uncompressed scanlines are released before opening the output file.

Five generated captures matched main byte for byte, including padded BGRA, one pixel, and both flat and high-entropy 4K inputs. An independent decoder verified all chunk CRCs and inflated the scanlines. With the normal half-size output, the high-entropy 4K input produced a 6,222,923-byte PNG on both revisions.

In the same optimized Windows test, peak live Rust allocations above the input buffer went from 31.11 MB to 18.92 MB for the high-entropy 4K input, and from 7.78 MB to 4.92 MB for 1080p. The flat 4K control stayed at about 9.59 MB. Across six alternating pairs, the measured encode-and-write medians varied by about 3–4% in either direction. This change targets the memory used by captures.

Six diagnostics capture tests passed, including the new byte-exact IDAT regression. Strict GPU Clippy, the asset policy and the diff check passed.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5542521132 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3763). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T16:57:05Z. --- Write the PNG chunks through a buffered file writer. The compressed IDAT payload stays in its original allocation, and the uncompressed scanlines are released before opening the output file. Five generated captures matched main byte for byte, including padded BGRA, one pixel, and both flat and high-entropy 4K inputs. An independent decoder verified all chunk CRCs and inflated the scanlines. With the normal half-size output, the high-entropy 4K input produced a 6,222,923-byte PNG on both revisions. In the same optimized Windows test, peak live Rust allocations above the input buffer went from 31.11 MB to 18.92 MB for the high-entropy 4K input, and from 7.78 MB to 4.92 MB for 1080p. The flat 4K control stayed at about 9.59 MB. Across six alternating pairs, the measured encode-and-write medians varied by about 3–4% in either direction. This change targets the memory used by captures. Six diagnostics capture tests passed, including the new byte-exact IDAT regression. Strict GPU Clippy, the asset policy and the diff check passed. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 17:00:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T17:00:44Z.


Windows CI passed on ed3c64c, including both Clippy configurations and the workspace tests. All five generated PNGs matched main byte for byte. On the high-entropy 4K input, peak additional live Rust allocations fell from 31.11 MB to 18.92 MB. The actual PNG file stayed at 6,222,923 bytes in both runs.

The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242684499 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3763#issuecomment-7242684499). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T17:00:44Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46167858112/job/141049311315) passed on `ed3c64c`, including both Clippy configurations and the workspace tests. All five generated PNGs matched main byte for byte. On the high-entropy 4K input, peak additional live Rust allocations fell from 31.11 MB to 18.92 MB. The actual PNG file stayed at 6,222,923 bytes in both runs. The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
cloph-dsp commented 2026-11-28 17:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T17:06:10Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3763 at head ed3c64cf115e605844034060d93ecafe4f61d2da, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::png_chunk_writes_the_type_and_payload_crc --exact --test-threads=1 --quiet → 1 passed, 0 failed, 247 filtered, exit 0. The diagnostics feature is required: mod capture is gated on all(windows, feature = "diagnostics") in lib.rs. Two pre-existing warnings in the victory-gpu lib test build.
  • git grep -F for the test name on the parent returned no match (test is new on this PR); git diff --check HEAD^ HEAD clean (1 file, +41/-23).
  • Per-worktree CARGO_TARGET_DIR (target-3763-watch), CARGO_BUILD_JOBS=2. Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only PNG chunk test over synthetic bytes, no D3D12 device). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242755518 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3763#issuecomment-7242755518). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T17:06:10Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3763 at head `ed3c64cf115e605844034060d93ecafe4f61d2da`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::png_chunk_writes_the_type_and_payload_crc --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 247 filtered, exit 0. The `diagnostics` feature is required: `mod capture` is gated on `all(windows, feature = "diagnostics")` in `lib.rs`. Two pre-existing warnings in the victory-gpu lib test build. - `git grep -F` for the test name on the parent returned no match (test is new on this PR); `git diff --check HEAD^ HEAD` clean (1 file, +41/-23). - Per-worktree `CARGO_TARGET_DIR` (target-3763-watch), `CARGO_BUILD_JOBS=2`. Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only PNG chunk test over synthetic bytes, no D3D12 device). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
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/3763:upstream-pr/3763'
git switch 'upstream-pr/3763'

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