GPU capture: checksum PNG chunks by byte #3757

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3757 into main
andrewpozdnakov7-jpg commented 2026-11-28 15:43:13 +00:00 (Migrated from github.com)

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


Use a compile-time 256-entry table for the existing PNG CRC polynomial. A chunk now does one table lookup per byte. The checksum covers the chunk type and payload, and the writer stores it in PNG byte order. PNG specification

The optimized Windows fixture compared the exact old and new CRC code with miniz_oxide 0.9.1 and generated rows. After compression had produced the same IDAT bytes, the median time to assemble a PNG across 11 alternating pairs was:

Generated input IDAT bytes Before After
Patterned 1080p 44,217 0.283 ms 0.135 ms
Mixed 1080p 2,124,167 13.981 ms 6.904 ms
Noisy 1080p 6,222,866 42.615 ms 19.958 ms
Mixed 4K 8,498,511 56.968 ms 27.491 ms

All four PNGs matched the old output byte for byte. Independent zlib checks verified the three chunk CRCs and decoded rows in every file. Complete encode timings ran separately and varied more across repeats, with most time spent compressing the rows.

The capture tests, both strict GPU Clippy configurations, 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:5541865325 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3757). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T15:43:13Z. --- Use a compile-time 256-entry table for the existing PNG CRC polynomial. A chunk now does one table lookup per byte. The checksum covers the chunk type and payload, and the writer stores it in PNG byte order. [PNG specification](https://www.w3.org/TR/png-3/) The optimized Windows fixture compared the exact old and new CRC code with miniz_oxide 0.9.1 and generated rows. After compression had produced the same IDAT bytes, the median time to assemble a PNG across 11 alternating pairs was: | Generated input | IDAT bytes | Before | After | |---|---:|---:|---:| | Patterned 1080p | 44,217 | 0.283 ms | 0.135 ms | | Mixed 1080p | 2,124,167 | 13.981 ms | 6.904 ms | | Noisy 1080p | 6,222,866 | 42.615 ms | 19.958 ms | | Mixed 4K | 8,498,511 | 56.968 ms | 27.491 ms | All four PNGs matched the old output byte for byte. Independent zlib checks verified the three chunk CRCs and decoded rows in every file. Complete encode timings ran separately and varied more across repeats, with most time spent compressing the rows. The capture tests, both strict GPU Clippy configurations, 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 15:47:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T15:47:30Z.


Windows CI passed on 1cdd5c3, including both Clippy configurations and the workspace tests. All four generated PNGs matched byte for byte and passed independent CRC and decode checks. For the generated mixed 4K case, assembly from the compressed data took 56.968 ms before and 27.491 ms with this change across 11 alternating pairs. The five capture tests passed locally.

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:7241737457 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3757#issuecomment-7241737457). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T15:47:30Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46161344593/job/141029127223) passed on `1cdd5c3`, including both Clippy configurations and the workspace tests. All four generated PNGs matched byte for byte and passed independent CRC and decode checks. For the generated mixed 4K case, assembly from the compressed data took 56.968 ms before and 27.491 ms with this change across 11 alternating pairs. The five capture tests passed locally. 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.
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/3757:upstream-pr/3757'
git switch 'upstream-pr/3757'

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