GPU: keep edge samples in odd-sized diagnostic PNGs #2678

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/2680 into main
andrewpozdnakov7-jpg commented 2026-11-25 18:02:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T18:02:04Z.


Problem

The diagnostic PNG encoder selects rows and columns 0, 2, 4, and so on, but sizes the output by rounding the source dimensions down. An odd source dimension therefore loses its final selected row or column.

Change

Round the half-size dimensions up so the PNG can hold the complete sample grid.

Verification

  • The same pitched 3x5 BGRA fixture writes a 1x2 PNG on main 13f91ca and a 2x3 PNG after the patch. The regression reads the actual IHDR and inflates IDAT to check all six RGB pixels, including the final row, column, and corner.
  • All three diagnostic capture tests, strict victory-gpu Clippy, and the staged policy passed on Windows.

Coordination claim

AI-assisted (Codex 2). Please retain the Git author on cherry-pick or rebase. If folding this change into another commit, please retain Co-authored-by: andrewpozdnakov7-jpg [email protected].

<!-- greyfinch-sync:Marvisak/VIctory:issue:6610592291 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T18:02:04Z. --- ## Problem The diagnostic PNG encoder selects rows and columns 0, 2, 4, and so on, but sizes the output by rounding the source dimensions down. An odd source dimension therefore loses its final selected row or column. ## Change Round the half-size dimensions up so the PNG can hold the complete sample grid. ## Verification - The same pitched 3x5 BGRA fixture writes a 1x2 PNG on main 13f91ca and a 2x3 PNG after the patch. The regression reads the actual IHDR and inflates IDAT to check all six RGB pixels, including the final row, column, and corner. - All three diagnostic capture tests, strict victory-gpu Clippy, and the staged policy passed on Windows. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7170276383) AI-assisted (Codex 2). Please retain the Git author on cherry-pick or rebase. If folding this change into another commit, please retain Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.
oni-swr commented 2026-11-25 19:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T18:31:10Z.


Independent verification (review, not a task claim) — covered by the existing claim on #1633.

  • PR head: b44ce1ff5d4716f794eba6246ca765da09096eba (OPEN, non-draft, merges cleanly; merge-base == origin/main)
  • origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • Environment: Windows 11, VICTORY_WARP=1, VICTORY_D3D12_WARP=1, dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files. Every victory-gpu run used --features diagnostics.

Commands and results

  • cargo test --locked -p victory-gpu --features diagnostics --lib capture:: → 3 passed, 0 failed, 0 ignored.
  • cargo test --locked -p victory-gpu --features diagnostics (full): one run had 198 passed, 1 failed, 1 ignored. The failure was memory::tests::a_submission_that_missed_leaves_the_copies_at_once, in code this PR does not touch. Four reruns of --lib on the PR head all gave 199 passed, 0 failed, 1 ignored. On unmodified origin/main, 6 --lib runs gave 198 passed in 4 runs, and 2 runs failed (memory::tests::a_submission_that_missed_leaves_the_copies_at_once in both, plus descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait in one). Those are pre-existing flaky tests, not caused by this PR.
  • cargo clippy --locked -p victory-gpu --features diagnostics --all-targets → clean, no warnings.

Negative control

  • With the fix reverted (back to (width / 2).max(1), (height / 2).max(1)) capture::odd_capture_extents_keep_the_final_sampled_row_and_column FAILED: left: [1, 2], right: [2, 3] (2 passed, 1 failed). With the fix restored it passes.

Review notes

  • The fix is correct: the encoder samples source rows and columns 0, 2, 4, ..., so ceil(n/2) is exactly the sample count. The remaining .max(1) only matters for a zero extent and is harmless.
  • The test is solid. It runs in a child process so the VICTORY_CAPTURE environment variable does not leak into parallel tests, and it checks the IHDR size and all six decoded RGB pixels, including the last row, column and corner. It assumes a single IDAT chunk right after IHDR (fixed offsets 37/41), which holds for this encoder.
  • I found no bugs.

AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171017231 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7171017231). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:31:10Z. --- **Independent verification (review, not a task claim)** — covered by the existing claim on #1633. - PR head: `b44ce1ff5d4716f794eba6246ca765da09096eba` (OPEN, non-draft, merges cleanly; merge-base == `origin/main`) - `origin/main`: `13f91caee25f2fdf2c062be5f7a27f058e51cbca` - Environment: Windows 11, `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, `dxil.dll` 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), WARP only (physical GPU not used), no game files. Every `victory-gpu` run used `--features diagnostics`. **Commands and results** - `cargo test --locked -p victory-gpu --features diagnostics --lib capture::` → 3 passed, 0 failed, 0 ignored. - `cargo test --locked -p victory-gpu --features diagnostics` (full): one run had 198 passed, 1 failed, 1 ignored. The failure was `memory::tests::a_submission_that_missed_leaves_the_copies_at_once`, in code this PR does not touch. Four reruns of `--lib` on the PR head all gave 199 passed, 0 failed, 1 ignored. On unmodified `origin/main`, 6 `--lib` runs gave 198 passed in 4 runs, and 2 runs failed (`memory::tests::a_submission_that_missed_leaves_the_copies_at_once` in both, plus `descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait` in one). Those are pre-existing flaky tests, not caused by this PR. - `cargo clippy --locked -p victory-gpu --features diagnostics --all-targets` → clean, no warnings. **Negative control** - With the fix reverted (back to `(width / 2).max(1), (height / 2).max(1)`) `capture::odd_capture_extents_keep_the_final_sampled_row_and_column` FAILED: `left: [1, 2]`, `right: [2, 3]` (2 passed, 1 failed). With the fix restored it passes. **Review notes** - The fix is correct: the encoder samples source rows and columns 0, 2, 4, ..., so `ceil(n/2)` is exactly the sample count. The remaining `.max(1)` only matters for a zero extent and is harmless. - The test is solid. It runs in a child process so the `VICTORY_CAPTURE` environment variable does not leak into parallel tests, and it checks the IHDR size and all six decoded RGB pixels, including the last row, column and corner. It assumes a single IDAT chunk right after IHDR (fixed offsets 37/41), which holds for this encoder. - I found no bugs. AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).
kotekompotek commented 2026-11-25 19:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:37:57Z.


Right fix: samples are taken at even coordinates, so an odd source dimension's last row/column is a real sample the floor-divided output could not hold. div_ceil matches the sample grid; the test reads the actual IHDR and inflates IDAT, including the corner pixel.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171177212 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7171177212). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:37:57Z. --- Right fix: samples are taken at even coordinates, so an odd source dimension's last row/column is a real sample the floor-divided output could not hold. div_ceil matches the sample grid; the test reads the actual IHDR and inflates IDAT, including the corner pixel.
fuzeofficlal commented 2026-11-25 19:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:59:47Z.


Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of b44ce1ff (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • RTX 5090: cargo test --locked -p victory-gpu --features diagnostics --lib capture: 3 passed, 0 failed (including odd_capture_extents_keep_the_final_sampled_row_and_column).
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 199 passed, 0 failed, 1 ignored.
  • Merge compatibility in capture.rs: clean zero-conflict 3-way git merge-tree against both #2701 (a86d36ef) and #2702 (b48e6c74).

Review Notes

  • div_ceil(2).max(1) safely preserves the final sampled row/column for odd extents (2 * x <= width - 1, 2 * y <= height - 1), handles 1x1 / 1xN / Nx1 without underflow, and cannot overflow u32. Clean and ready to merge.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7171680792 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7171680792). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T18:59:47Z. --- Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of `b44ce1ff` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics`: **0 warnings**. - **RTX 5090:** `cargo test --locked -p victory-gpu --features diagnostics --lib capture`: **3 passed, 0 failed** (including `odd_capture_extents_keep_the_final_sampled_row_and_column`). - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1`: **199 passed, 0 failed, 1 ignored**. - **Merge compatibility in `capture.rs`:** clean zero-conflict 3-way `git merge-tree` against both #2701 (`a86d36ef`) and #2702 (`b48e6c74`). ### Review Notes - `div_ceil(2).max(1)` safely preserves the final sampled row/column for odd extents (`2 * x <= width - 1`, `2 * y <= height - 1`), handles `1x1` / `1xN` / `Nx1` without underflow, and cannot overflow `u32`. Clean and ready to merge.
Marvisak commented 2026-11-26 00:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:25:15Z.


Automated triage for the maintainers.

In save_as (crates/victory-gpu/src/capture.rs) the half-size PNG samples source rows and columns 0, 2, 4, …, but was sized with width / 2 and height / 2, so an odd extent lost its last sampled row or column; div_ceil(2) matches the sample grid, and the existing .min(width - 1) clamps keep indexing in bounds. The new test re-runs the test binary as a child to set VICTORY_CAPTURE (the same pattern other tests in the workspace use) and checks the IHDR size and all six decoded pixels of a 3x5 input, using the miniz_oxide dependency the crate already has. CI (check) passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177535489 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7177535489). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:25:15Z. --- <!-- victory-triage v1 head=b44ce1ff5d4716f794eba6246ca765da09096eba verdict=merge-candidate at=2026-11-25T23:25:07Z --> Automated triage for the maintainers. In `save_as` (`crates/victory-gpu/src/capture.rs`) the half-size PNG samples source rows and columns 0, 2, 4, …, but was sized with `width / 2` and `height / 2`, so an odd extent lost its last sampled row or column; `div_ceil(2)` matches the sample grid, and the existing `.min(width - 1)` clamps keep indexing in bounds. The new test re-runs the test binary as a child to set `VICTORY_CAPTURE` (the same pattern other tests in the workspace use) and checks the IHDR size and all six decoded pixels of a 3x5 input, using the `miniz_oxide` dependency the crate already has. CI (`check`) passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 05:02:57 +00:00 (Migrated from github.com)

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

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-gpu --features diagnostics --lib capture::: 6 passed, 0 failed (including new odd_capture_extents_keep_the_final_sampled_row_and_column).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068570994 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680#pullrequestreview-6068570994). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T04:30:47Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-gpu --features diagnostics --lib capture::`: **6 passed, 0 failed** (including new `odd_capture_extents_keep_the_final_sampled_row_and_column`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
andrewpozdnakov7-jpg commented 2026-11-28 17:37:12 +00:00 (Migrated from github.com)

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


I checked b44ce1f with the full-resolution option from #3652, the byte-wise CRC from #3757 and the streaming writer from #3763. Combined 2555f2f preserves both tested parents. The merge rounds up the sampled extent using the active sampling step and keeps the regression that reads and decodes the saved PNG.

I compared 32 pairs of PNGs produced from generated RGBA and BGRA frames with padded rows. Ten odd-size thumbnails now include the expected edge pixels. The other 22 pairs are byte-identical, including every full-resolution image, both even-size controls, and the 1×1 control. An independent decoder checked dimensions, chunk CRCs and every RGB sample. All 14 diagnostic capture tests, strict GPU Clippy and the asset policy passed.

The maintainer can use this branch if the capture changes land together. Please retain the Git authors on cherry-pick or rebase.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7243156297 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7243156297). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T17:37:12Z. --- I checked b44ce1f with the full-resolution option from #3652, the byte-wise CRC from #3757 and the streaming writer from #3763. [Combined 2555f2f](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/2555f2f3b907ed2e41498fc69b51b749b80dc549) preserves both tested parents. The merge rounds up the sampled extent using the active sampling step and keeps the regression that reads and decodes the saved PNG. I compared 32 pairs of PNGs produced from generated RGBA and BGRA frames with padded rows. Ten odd-size thumbnails now include the expected edge pixels. The other 22 pairs are byte-identical, including every full-resolution image, both even-size controls, and the 1×1 control. An independent decoder checked dimensions, chunk CRCs and every RGB sample. All 14 diagnostic capture tests, strict GPU Clippy and the asset policy passed. The maintainer can use this branch if the capture changes land together. Please retain the Git authors on cherry-pick or rebase. 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/2680:upstream-pr/2680'
git switch 'upstream-pr/2680'

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