GPU: skip zero-sized frame captures #488

Closed
enzoduarte1 wants to merge 1 commit from upstream-pr/488 into main
enzoduarte1 commented 2026-11-24 03:58:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T03:58:28Z.


What

save_as in the frame-capture diagnostics computed the source row and pixel with height as usize - 1 and width as usize - 1. A zero-sized present underflowed (panic in debug, huge index in release) even though the code then clamped with min.

Zero-width or zero-height frames are now skipped: they have no pixels to sample, and the row slice can be empty. The clamping itself moved into a source_coord helper so its boundary behavior is testable without writing PNGs. Tests cover zero extent, normal clamping and the no-op on an empty frame.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (no MSVC linker on this machine).
  • cargo test -p victory-gpu --features diagnostics --lib: 46 passed, 1 ignored.
  • cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.
  • cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings: clean here; the pre-existing host.rs warning fixed by PR #355 appears on a full rebuild and was allowed locally.
  • git diff --check: clean. rustfmt --check shows only unrelated pre-existing formatting in this file; the added lines match it.
  • cargo xtask policy: 151 files ok. No game files or data taken from them were added.
  • Not tested: cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's /DELAYLOAD flag, which MinGW rejects here; the same failure occurs on unmodified main.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass — see the toolchain limitations above; the changed crate is clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6574281733 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/488). Originally posted by [enzoduarte1](https://github.com/enzoduarte1) on 2026-11-24T03:58:28Z. --- ## What `save_as` in the frame-capture diagnostics computed the source row and pixel with `height as usize - 1` and `width as usize - 1`. A zero-sized present underflowed (panic in debug, huge index in release) even though the code then clamped with `min`. Zero-width or zero-height frames are now skipped: they have no pixels to sample, and the row slice can be empty. The clamping itself moved into a `source_coord` helper so its boundary behavior is testable without writing PNGs. Tests cover zero extent, normal clamping and the no-op on an empty frame. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (no MSVC linker on this machine). - `cargo test -p victory-gpu --features diagnostics --lib`: 46 passed, 1 ignored. - `cargo test --workspace --exclude victory-loader -- --test-threads=1`: all suites passed. - `cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings`: clean here; the pre-existing `host.rs` warning fixed by PR #355 appears on a full rebuild and was allowed locally. - `git diff --check`: clean. `rustfmt --check` shows only unrelated pre-existing formatting in this file; the added lines match it. - `cargo xtask policy`: 151 files ok. No game files or data taken from them were added. - Not tested: `cargo test -p victory-loader --test load_probe`. Its fixture passes MSVC's `/DELAYLOAD` flag, which MinGW rejects here; the same failure occurs on unmodified `main`. ## Checklist - [ ] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass — see the toolchain limitations above; the changed crate is clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
DaviTostes commented 2026-11-24 06:55:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T04:02:53Z.


Verified 62cf5dd on Arch Linux x86_64, Windows MSVC release build under Wine 11.22 (victory-gpu, --test-threads=1): 43 passed, 0 failed, 1 ignored.

Not covered: a zero-sized capture actually requested at run time in the title (no game data here); the suite has no case for the capture path.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121657840 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/488#issuecomment-7121657840). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T04:02:53Z. --- Verified `62cf5dd` on **Arch Linux x86_64**, Windows MSVC release build under **Wine 11.22** (`victory-gpu`, `--test-threads=1`): **43 passed, 0 failed, 1 ignored**. Not covered: a zero-sized capture actually requested at run time in the title (no game data here); the suite has no case for the capture path.
mercuryVM commented 2026-11-24 08:02:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:57:51Z.

Review: APPROVED


Tested 62cf5dd on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed).

height as usize - 1 underflowed for a zero extent, which panics in debug before the min. Returning early for zero width or height and clamping with saturating_sub in source_coord covers it. The early return sits after folder(), so a capture that is off is still a no-op either way.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035566107 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/488#pullrequestreview-6035566107). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T07:57:51Z. **Review:** APPROVED --- Tested 62cf5dd on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (264 passed, 0 failed). `height as usize - 1` underflowed for a zero extent, which panics in debug before the `min`. Returning early for zero width or height and clamping with `saturating_sub` in `source_coord` covers it. The early return sits after `folder()`, so a capture that is off is still a no-op either way. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 00:05:31 +00:00
Marvisak commented 2026-11-25 00:06:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:03:19Z.


Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).

Guards the capture writer against a 0x0 frame, which cannot reach it: both callers pass the footprint of a live host texture (width and height >= 1). Its test's save(1, 0, 0, ..) returns at folder() before the new guard, so it tests nothing.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148087094 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/488#issuecomment-7148087094). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:03:19Z. --- Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current). Guards the capture writer against a 0x0 frame, which cannot reach it: both callers pass the footprint of a live host texture (width and height >= 1). Its test's save(1, 0, 0, ..) returns at folder() before the new guard, so it tests nothing. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!488
No description provided.