GPU capture: use the PNG Up filter for coherent scanlines #3779

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3779 into main
andrewpozdnakov7-jpg commented 2026-11-28 18:32:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T18:32:49Z.


The diagnostic PNG writer now tries the PNG Up filter when a small sample finds horizontal variation and substantially smaller differences from the preceding row. Unselected images keep the existing filter. The predictor works in place on the RGB scanlines before zlib compression. PNG filtering specification

I compared 50 generated PNG pairs from the actual writer, including RGBA and BGRA input, padded rows, odd sizes and one-pixel extents. An independent decoder checked every RGB sample, dimension and CRC. Twelve selected files were smaller and all 38 controls were byte-identical.

With miniz_oxide 0.9.1 and generated 4K output scanlines, the five-pair local medians for predictor plus compression were:

Pattern Compressed data, before → after Median, before → after
Horizontal gradient 268,833 → 30,190 bytes 163 → 141 ms
Two-axis gradient 456,031 → 62,328 bytes 163 → 153 ms
Dithered gradient 17,255,069 → 15,842,964 bytes 1,013 → 853 ms
UI blocks 210,037 → 38,584 bytes 145 → 135 ms

The flat, vertical-only and high-entropy controls used their original encoded bytes. The 13 capture tests, strict GPU Clippy and the asset policy 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:5543349659 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3779). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T18:32:49Z. --- The diagnostic PNG writer now tries the PNG Up filter when a small sample finds horizontal variation and substantially smaller differences from the preceding row. Unselected images keep the existing filter. The predictor works in place on the RGB scanlines before zlib compression. [PNG filtering specification](https://www.w3.org/TR/png-3/#9Filters) I compared 50 generated PNG pairs from the actual writer, including RGBA and BGRA input, padded rows, odd sizes and one-pixel extents. An independent decoder checked every RGB sample, dimension and CRC. Twelve selected files were smaller and all 38 controls were byte-identical. With miniz_oxide 0.9.1 and generated 4K output scanlines, the five-pair local medians for predictor plus compression were: | Pattern | Compressed data, before → after | Median, before → after | | --- | ---: | ---: | | Horizontal gradient | 268,833 → 30,190 bytes | 163 → 141 ms | | Two-axis gradient | 456,031 → 62,328 bytes | 163 → 153 ms | | Dithered gradient | 17,255,069 → 15,842,964 bytes | 1,013 → 853 ms | | UI blocks | 210,037 → 38,584 bytes | 145 → 135 ms | The flat, vertical-only and high-entropy controls used their original encoded bytes. The 13 capture tests, strict GPU Clippy and the asset policy 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 18:37:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T18:37:13Z.


Windows CI passed on d9e1ac9, including both Clippy configurations and the workspace tests. The independent decoder matched the dimensions, RGB bytes and chunk CRCs for 50 generated PNG pairs. All 12 selected PNGs were smaller and all 38 controls stayed byte-identical.

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:7243928656 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3779#issuecomment-7243928656). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T18:37:13Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46176451123/job/141076146483) passed on `d9e1ac9`, including both Clippy configurations and the workspace tests. The independent decoder matched the dimensions, RGB bytes and chunk CRCs for 50 generated PNG pairs. All 12 selected PNGs were smaller and all 38 controls stayed byte-identical. 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-29 00:24:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-29T00:24:36Z.


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

  • PR #3779 at head d9e1ac9e60803f8f8a1a66a6782ec986d6c1a211, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::coherent_png_rows_use_the_up_filter --exact --test-threads=1 --quiet → 1 passed, 0 failed, 248 filtered, exit 0. The diagnostics feature is required because mod capture is cfg-gated.
  • git grep -F for the new test name on the parent returned no match (test is new on this PR); git diff --check HEAD^ HEAD clean (1 file, +74/-0).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2. Two pre-existing fetch_update warnings in the library test build.
  • Only the named synthetic PNG-filter test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only synthetic PNG row data). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7248092945 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3779#issuecomment-7248092945). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-29T00:24:36Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3779 at head `d9e1ac9e60803f8f8a1a66a6782ec986d6c1a211`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-gpu --lib --features diagnostics -- capture::tests::coherent_png_rows_use_the_up_filter --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 248 filtered, exit 0. The `diagnostics` feature is required because `mod capture` is cfg-gated. - `git grep -F` for the new test name on the parent returned no match (test is new on this PR); `git diff --check HEAD^ HEAD` clean (1 file, +74/-0). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. Two pre-existing `fetch_update` warnings in the library test build. - Only the named synthetic PNG-filter test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only synthetic PNG row data). 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/3779:upstream-pr/3779'
git switch 'upstream-pr/3779'

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