GPU: guard zero/overflowing stride in expand_rects and add primitive.rs unit tests #1204

Merged
geiyiliyabumo merged 1 commit from upstream-pr/1204 into main 2026-11-25 00:13:21 +00:00
geiyiliyabumo commented 2026-11-24 16:25:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T16:25:16Z.


Summary

Closes #1061

Full verification details and change notes are documented in #1061 (commit e3c9dd0, based on main ffe310e).

 crates/victory-gpu/src/primitive.rs | 89 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 2 deletions(-)

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check on edited files: PASS
  • cargo xtask policy: PASS (zero game files/data)
  • cargo clippy --all-targets --locked -- -D warnings (default + --features diagnostics where applicable): PASS
  • Targeted & crate unit/GPU tests: PASS

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586456566 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1204). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T16:25:16Z. --- ### Summary Closes #1061 Full verification details and change notes are documented in #1061 (commit `e3c9dd0`, based on `main` `ffe310e`). ```text crates/victory-gpu/src/primitive.rs | 89 ++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) ``` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check` on edited files: **PASS** - `cargo xtask policy`: **PASS** (zero game files/data) - `cargo clippy --all-targets --locked -- -D warnings` (default + `--features diagnostics` where applicable): **PASS** - Targeted & crate unit/GPU tests: **PASS** *AI-assisted; synthetic tests only, no game files.*
Aniseto commented 2026-11-24 17:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-24T16:48:05Z.


Ran the primitive tests at e3c9dd0:

Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

cargo test -p victory-gpu primitive
7 passed; 0 failed; 0 ignored      (exit 0)

The three new tests pass (zero_or_overflowing_stride_is_ignored_without_panicking, unorm16_unorm8_clamping_and_unknown_formats_expand_correctly, multiple_rectangles_and_f32_f16_vector_formats_expand_in_sequence) and the four existing ones are unaffected. They are unit-level tests, so the adapter is not the variable; the datapoint is the pinned 1.98.1 toolchain. No test report on this PR yet.

Not tested: a title that hits a zero or overflowing stride (no game data here), RDNA2/RDNA4 and Intel GPUs.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; no game data was used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138227673 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1204#issuecomment-7138227673). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-24T16:48:05Z. --- Ran the `primitive` tests at `e3c9dd0`: Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. ``` cargo test -p victory-gpu primitive 7 passed; 0 failed; 0 ignored (exit 0) ``` The three new tests pass (`zero_or_overflowing_stride_is_ignored_without_panicking`, `unorm16_unorm8_clamping_and_unknown_formats_expand_correctly`, `multiple_rectangles_and_f32_f16_vector_formats_expand_in_sequence`) and the four existing ones are unaffected. They are unit-level tests, so the adapter is not the variable; the datapoint is the pinned 1.98.1 toolchain. No test report on this PR yet. Not tested: a title that hits a zero or overflowing stride (no game data here), RDNA2/RDNA4 and Intel GPUs. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash 1017** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; no game data was used.
Zipettte commented 2026-11-24 18:06:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:00:09Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at e3c9dd0: cargo test -p victory-gpu passes, 53 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140014161 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1204#issuecomment-7140014161). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:00:09Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at e3c9dd0: `cargo test -p victory-gpu` passes, 53 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
mercuryVM commented 2026-11-24 19:02:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T18:36:03Z.

Review: APPROVED


Tested e3c9dd0d on Windows 11, RTX 5070, MSVC:

  • cargo test -p victory-gpu passes on the head (53 passed, 1 ignored).
  • Merged into our fork: workspace tests, shader tests and clippy -D warnings (default and all features) are all clean.

The guard is right. chunks_exact(0) panics, and 3 * stride could overflow before. Both now return early and leave dst untouched. The new expansion test pins the UNORM16/UNORM8 clamps and the verbatim copy of unknown formats.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045151262 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1204#pullrequestreview-6045151262). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T18:36:03Z. **Review:** APPROVED --- Tested e3c9dd0d on Windows 11, RTX 5070, MSVC: - `cargo test -p victory-gpu` passes on the head (53 passed, 1 ignored). - Merged into our fork: workspace tests, shader tests and `clippy -D warnings` (default and all features) are all clean. The guard is right. `chunks_exact(0)` panics, and `3 * stride` could overflow before. Both now return early and leave `dst` untouched. The new expansion test pins the UNORM16/UNORM8 clamps and the verbatim copy of unknown formats. AI-assisted (Claude Code).
upipibi commented 2026-11-24 21:03:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T20:33:44Z.


Duplicate check: this PR and #1158 have the same diff (91 changed lines, no differences) and commits by the same author (给伊莉雅补魔). Only one of the two needs review; the other can be closed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143734837 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1204#issuecomment-7143734837). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T20:33:44Z. --- Duplicate check: this PR and #1158 have the same diff (91 changed lines, no differences) and commits by the same author (给伊莉雅补魔). Only one of the two needs review; the other can be closed.
geiyiliyabumo commented 2026-11-24 21:28:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T21:07:10Z.


Thanks @upipibi for flagging this! Just to clarify provenance: this PR (#1204) is the original author PR (authored by geiyiliyabumo, already reviewed/approved by @mercuryVM and @Aniseto). #1158 was opened by another account (@Vittorio17) using our commit from our fork branch, so #1204 is the canonical one to keep.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144500576 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1204#issuecomment-7144500576). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T21:07:10Z. --- Thanks @upipibi for flagging this! Just to clarify provenance: this PR (#1204) is the original author PR (authored by `geiyiliyabumo`, already reviewed/approved by @mercuryVM and @Aniseto). #1158 was opened by another account (`@Vittorio17`) using our commit from our fork branch, so #1204 is the canonical one to keep. *AI-assisted; synthetic tests only, no game files.*
upstream-sync closed this pull request 2026-11-25 01:05:56 +00:00
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!1204
No description provided.