gpu: reject invalid pixel readback dimensions before device setup #2239

Merged
RavenCurseBurg merged 1 commit from upstream-pr/2247 into main 2026-11-25 08:16:01 +00:00
RavenCurseBurg commented 2026-11-25 07:33:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T07:33:20Z.


The pixel readback CLI accepted a numeric prefix for either dimension. I drew an 8 × 4 synthetic triangle on WARP with a 32-pixel reference. The valid invocation, a width of 8x4, and a height of 4junk all returned 0 with all 32 pixels matched.

Validate the complete base-10 values during CLI resolution, before adapter selection or file access. Both dimensions must be in the inclusive range 1–64. The parser keeps the earlier behavior for valid values such as 08 and +4. The existing CLI self-test covers both positions, the limits, decimal fractions, suffixes and overflow.

Windows 2025 verification at bfb1f61a built the exact revision with MSVC and ran:

  • offscreen_capability_table_self_test and the existing startup_gfx2hlsl_dpp_quad_swap_warp draw, both passed.
  • The executable with 8x4 4 and 8 4junk. Both returned usage exit 2 before GPU setup.

The documentation link check (419 links), bidirectional controls check and git diff --check also passed.

Reproduce the two CTests with ctest --preset dev --no-tests=error -V -R '^(offscreen_capability_table_self_test|startup_gfx2hlsl_dpp_quad_swap_warp)$'.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6599545269 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2247). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T07:33:20Z. --- The pixel readback CLI accepted a numeric prefix for either dimension. I drew an 8 × 4 synthetic triangle on WARP with a 32-pixel reference. The valid invocation, a width of `8x4`, and a height of `4junk` all returned 0 with `all 32 pixels matched`. Validate the complete base-10 values during CLI resolution, before adapter selection or file access. Both dimensions must be in the inclusive range 1–64. The parser keeps the earlier behavior for valid values such as `08` and `+4`. The existing CLI self-test covers both positions, the limits, decimal fractions, suffixes and overflow. [Windows 2025 verification at bfb1f61a](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45568654208) built the exact revision with MSVC and ran: - `offscreen_capability_table_self_test` and the existing `startup_gfx2hlsl_dpp_quad_swap_warp` draw, both passed. - The executable with `8x4 4` and `8 4junk`. Both returned usage exit 2 before GPU setup. The documentation link check (419 links), bidirectional controls check and `git diff --check` also passed. Reproduce the two CTests with `ctest --preset dev --no-tests=error -V -R '^(offscreen_capability_table_self_test|startup_gfx2hlsl_dpp_quad_swap_warp)$'`.
tedin7 commented 2026-11-25 08:05:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:41:41Z.

Review: COMMENTED


Review of head bfb1f61ae5a1279c28e759ee2a92717d74a85bec (only tests/offscreen_check.cpp).

Findings: 0 P1, 0 P2.

  • --startup-pixel-words width/height are now validated in the CLI table (validate_pixel_words_args) before any device setup, so a bad extent exits with usage error (2) instead of failing late. pixel_extent uses strtol with full-string match and a 1..64 range; empty, trailing junk, decimals, 0, 65, negatives and overflow are rejected; 08 and +4 stay accepted (same as the old stoul parsing). The argc check runs before the validator, so argv[5]/argv[6] are always present (argc is 8).
  • The self-test extends the existing check_cli table in run_self_test (good and bad extents on both positions). No concurrent open or recent merged PR touches this operation.
  • Clean-room: test-harness argument parsing only, no ISA or third-party content.

Commands executed locally:

  • git diff --stat origin/main...HEAD (1 file, +23/-10)
  • python3 tests/docs_links_check.py PASS, python3 tests/bidi_controls_check.py PASS, git diff --check origin/main...HEAD clean
  • Mutation: the file is Windows-only (D3D12), so I compiled a standalone copy of pixel_extent with the same good/bad cases. Upper bound 64 -> 65 gives failures=1 (the 65 case), the original gives failures=0.
  • Windows Server 2025, MSVC 14.44, WARP: python3 x2w_pipe.py win2025 2247 --scope direct --targets offscreen_check --regex 'offscreen_capability_table_self_test|startup_pixel_words' -> Debug (dev) 1/1 passed, Release /O2 1/1 passed (offscreen_capability_table_self_test).
  • GitHub CI: Build and test on Windows SUCCESS.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053607587 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2247#pullrequestreview-6053607587). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T07:41:41Z. **Review:** COMMENTED --- Review of head `bfb1f61ae5a1279c28e759ee2a92717d74a85bec` (only `tests/offscreen_check.cpp`). Findings: 0 P1, 0 P2. - `--startup-pixel-words` width/height are now validated in the CLI table (`validate_pixel_words_args`) before any device setup, so a bad extent exits with usage error (2) instead of failing late. `pixel_extent` uses strtol with full-string match and a 1..64 range; empty, trailing junk, decimals, 0, 65, negatives and overflow are rejected; `08` and `+4` stay accepted (same as the old stoul parsing). The argc check runs before the validator, so `argv[5]`/`argv[6]` are always present (argc is 8). - The self-test extends the existing `check_cli` table in `run_self_test` (good and bad extents on both positions). No concurrent open or recent merged PR touches this operation. - Clean-room: test-harness argument parsing only, no ISA or third-party content. Commands executed locally: - `git diff --stat origin/main...HEAD` (1 file, +23/-10) - `python3 tests/docs_links_check.py` PASS, `python3 tests/bidi_controls_check.py` PASS, `git diff --check origin/main...HEAD` clean - Mutation: the file is Windows-only (D3D12), so I compiled a standalone copy of `pixel_extent` with the same good/bad cases. Upper bound 64 -> 65 gives `failures=1` (the `65` case), the original gives `failures=0`. - Windows Server 2025, MSVC 14.44, WARP: `python3 x2w_pipe.py win2025 2247 --scope direct --targets offscreen_check --regex 'offscreen_capability_table_self_test|startup_pixel_words'` -> Debug (`dev`) 1/1 passed, Release /O2 1/1 passed (`offscreen_capability_table_self_test`). - GitHub CI: `Build and test on Windows` SUCCESS. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 09:03:59 +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
R0Y00/Xbox2Windows!2239
No description provided.