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

Open
github-bot wants to merge 1 commit from github-bot/gh-2680 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 18:02 UTC · original
andrewpozdnakov7-jpg:codex2/capture-odd-extents → main · +53 −1 · 1 files · 1 commits · open

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].

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 18:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2680) `andrewpozdnakov7-jpg:codex2/capture-odd-extents` → `main` · +53 −1 · 1 files · 1 commits · open ## 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://git.gtahub.st/github/Marvisak--VIctory/issues/1633) 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]>.
Round the sampled dimensions up because the PNG encoder keeps every other pixel starting at zero. The same pitched 3x5 fixture now reads as 2x3 with all six RGB samples.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:52 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:31 UTC · original

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).

**@⁠oni-swr** on GitHub · 2026-11-25 18:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7171017231) **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).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:37 UTC · original

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7171177212) 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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 18:59 UTC · original

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 18:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7171680792) 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.
Author
Owner

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

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

**@⁠Marvisak** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2680#issuecomment-7177535489) <!-- 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)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2680/head:github-bot/gh-2680'
git switch 'github-bot/gh-2680'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2680'
git switch 'github-bot/gh-2680'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2680'
git switch 'github-bot/gh-2680'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2680'
git switch 'main'
git merge --squash 'github-bot/gh-2680'
git switch 'main'
git merge --ff-only 'github-bot/gh-2680'
git switch 'main'
git merge 'github-bot/gh-2680'
git push origin 'main'
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!2680
No description provided.