tooling: name the rule on an offscreen_check usage error #3948

Open
triggered02 wants to merge 3 commits from upstream-pr/3948 into main
triggered02 commented 2026-12-03 16:47:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T16:47:02Z.


offscreen_check returns 2 only for a command-line usage error, so a launcher log that records
only ended with exit code: 2 says nothing about what was rejected — and it looks like a renderer or
device failure even though the tool never reached a device. Three of its four usage-error paths
returned silently.

Refs #3911.

What changed

resolve_cli now reports every rejection the same way:

offscreen_check: <the rule that was broken>
command: <the command line it was started with>
usage: offscreen_check <warp|hardware> [<expected.bin> <pixels>] | <warp|hardware> <--operation> [operands] | --self-test
  • fewer than three arguments (offscreen_check, or offscreen_check warp);
  • a backend that is not warp or hardware;
  • a draw invocation whose argument count is neither 3 nor 5;
  • an unknown or malformed --operation: keeps the existing
    Unknown GPU operation or invalid arguments: <arg> line and adds whether the name is unknown or the
    operand count/form is wrong.

The echoed command line is bounded (200 characters, then ...) so a single stray operand cannot fill a
log, and the exit code stays 2. tests/offscreen_check.cpp only.

Verification

Environment: Linux, clang-cl 19 + xwin SDK, Release build, Wine + vkd3d-proton, GTX 1660 SUPER. The
launcher run that reported #3911 is on Windows and is not reproduced here.

Each path run directly, all exit 2:

$ wine ./offscreen_check.exe
[exit 2] offscreen_check: a run needs a backend and either an operation or an expected-image path and pixel count
         command: ...\offscreen_check.exe
         usage: offscreen_check <warp|hardware> [<expected.bin> <pixels>] | ...
$ wine ./offscreen_check.exe warp
[exit 2] offscreen_check: a run needs a backend and either an operation or an expected-image path and pixel count
$ wine ./offscreen_check.exe cpu --dual-uav
[exit 2] offscreen_check: the backend must be `warp` or `hardware`
$ wine ./offscreen_check.exe warp expected.bin 8 extra more
[exit 2] offscreen_check: a draw run takes an expected-image path and a pixel count, or neither
$ wine ./offscreen_check.exe warp --bvh-wave
[exit 2] Unknown GPU operation or invalid arguments: --bvh-wave
         offscreen_check: no operation has that name
$ wine ./offscreen_check.exe warp --dual-uav extra
[exit 2] Unknown GPU operation or invalid arguments: --dual-uav
         offscreen_check: the operation's operand count or operand form is wrong

--self-test gains the four paths plus two assertions that the echoed command line and the usage line
are present, and still passes:

$ wine ./offscreen_check.exe --self-test
[exit 0] offscreen_self_test: cli_validation=ok gate_skip=ok outcome_fail=ok outcome_throw=ok outcome_skip=ok outcome_pass=ok

Negative control: restoring the silent return for the backend path and rebuilding makes the self-test
fail with offscreen_check self-test failed: expected stderr substring (exit 1), so the new cases bite.

Not established

Which argument a launcher actually passes is still unknown; this change makes the next report
self-describing instead of guessing at the caller. No behavior on a valid command line changed: a draw
run, an operation run and --self-test all keep their previous exit codes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5630895218 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948). Originally posted by [triggered02](https://github.com/triggered02) on 2026-12-03T16:47:02Z. --- `offscreen_check` returns **2 only for a command-line usage error**, so a launcher log that records only `ended with exit code: 2` says nothing about what was rejected — and it looks like a renderer or device failure even though the tool never reached a device. Three of its four usage-error paths returned silently. Refs #3911. ## What changed `resolve_cli` now reports every rejection the same way: ``` offscreen_check: <the rule that was broken> command: <the command line it was started with> usage: offscreen_check <warp|hardware> [<expected.bin> <pixels>] | <warp|hardware> <--operation> [operands] | --self-test ``` - fewer than three arguments (`offscreen_check`, or `offscreen_check warp`); - a backend that is not `warp` or `hardware`; - a draw invocation whose argument count is neither 3 nor 5; - an unknown or malformed `--operation`: keeps the existing `Unknown GPU operation or invalid arguments: <arg>` line and adds whether the name is unknown or the operand count/form is wrong. The echoed command line is bounded (200 characters, then `...`) so a single stray operand cannot fill a log, and the exit code stays 2. `tests/offscreen_check.cpp` only. ## Verification Environment: Linux, clang-cl 19 + xwin SDK, Release build, Wine + vkd3d-proton, GTX 1660 SUPER. The launcher run that reported #3911 is on Windows and is **not** reproduced here. Each path run directly, all exit 2: ``` $ wine ./offscreen_check.exe [exit 2] offscreen_check: a run needs a backend and either an operation or an expected-image path and pixel count command: ...\offscreen_check.exe usage: offscreen_check <warp|hardware> [<expected.bin> <pixels>] | ... $ wine ./offscreen_check.exe warp [exit 2] offscreen_check: a run needs a backend and either an operation or an expected-image path and pixel count $ wine ./offscreen_check.exe cpu --dual-uav [exit 2] offscreen_check: the backend must be `warp` or `hardware` $ wine ./offscreen_check.exe warp expected.bin 8 extra more [exit 2] offscreen_check: a draw run takes an expected-image path and a pixel count, or neither $ wine ./offscreen_check.exe warp --bvh-wave [exit 2] Unknown GPU operation or invalid arguments: --bvh-wave offscreen_check: no operation has that name $ wine ./offscreen_check.exe warp --dual-uav extra [exit 2] Unknown GPU operation or invalid arguments: --dual-uav offscreen_check: the operation's operand count or operand form is wrong ``` `--self-test` gains the four paths plus two assertions that the echoed command line and the usage line are present, and still passes: ``` $ wine ./offscreen_check.exe --self-test [exit 0] offscreen_self_test: cli_validation=ok gate_skip=ok outcome_fail=ok outcome_throw=ok outcome_skip=ok outcome_pass=ok ``` Negative control: restoring the silent return for the backend path and rebuilding makes the self-test fail with `offscreen_check self-test failed: expected stderr substring` (exit 1), so the new cases bite. ## Not established Which argument a launcher actually passes is still unknown; this change makes the next report self-describing instead of guessing at the caller. No behavior on a valid command line changed: a draw run, an operation run and `--self-test` all keep their previous exit codes.
chatgpt-codex-connector[bot] commented 2026-12-03 16:47:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T16:47:16Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T16:49:44.965135Z 6bac447 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7385447041 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#issuecomment-7385447041). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-12-03T16:47:16Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6bac447c5cb0400b953244dfddb4ad75b5cdd7dc","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-12-03T16:49:44.965135Z">2026-12-03T16:49:44.965135Z</relative-time> | `6bac447` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot] commented 2026-12-03 16:49:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T16:49:42Z.

Code review location: tests/offscreen_check.cpp; line 2004

@@ -1998,26 +1998,65 @@ const OperationSpec* find_operation(std::string_view name)
     return nullptr;
 }
 
+// A launcher log that shows only "exit code: 2" cannot say what was rejected, so
+// every usage error names the rule it broke and echoes the command line it saw.
+constexpr const char* kUsage =
+    "usage: offscreen_check <warp|hardware> [<expected.bin> <pixels>] | "

P2 Badge Show the draw form that the parser accepts

When a non-operation draw invocation has the wrong argument count, this usage line suggests an expected-image path and pixel count, but the parser accepts only a backend plus an output path, optionally followed by vertex and pixel shader paths; main passes argv[2] as the output and argv[3]/argv[4] as shaders. The matching error reason at line 2059 repeats the incorrect form, so users following the diagnostic will still get a rejected command. Show the actual draw arguments instead.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4788153435 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#discussion_r4788153435). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-12-03T16:49:42Z. **Code review location:** `tests/offscreen_check.cpp`; line 2004 ~~~~diff @@ -1998,26 +1998,65 @@ const OperationSpec* find_operation(std::string_view name) return nullptr; } +// A launcher log that shows only "exit code: 2" cannot say what was rejected, so +// every usage error names the rule it broke and echoes the command line it saw. +constexpr const char* kUsage = + "usage: offscreen_check <warp|hardware> [<expected.bin> <pixels>] | " ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Show the draw form that the parser accepts** When a non-operation draw invocation has the wrong argument count, this usage line suggests an expected-image path and pixel count, but the parser accepts only a backend plus an output path, optionally followed by vertex and pixel shader paths; `main` passes `argv[2]` as the output and `argv[3]`/`argv[4]` as shaders. The matching error reason at line 2059 repeats the incorrect form, so users following the diagnostic will still get a rejected command. Show the actual draw arguments instead. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-12-03 16:49:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T16:49:42Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6bac447c5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6174299794 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#pullrequestreview-6174299794). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-12-03T16:49:42Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `6bac447c5c` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
triggered02 commented 2026-12-03 17:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T17:01:07Z.


Second commit cd4f01ba adds the process-level assertions: tests/offscreen_invalid_operation.cmake already runs the built binary for the invalid-operation and positional-draw paths, so it now also checks that the draw path names its rule and echoes the command line, plus a bare invocation and a wrong backend (exit 2, reason, usage line).

Run on this host by wrapping the Windows binary in wine:

$ cmake -DRENDERER=/tmp/ocwine.sh -DCMAKE_CURRENT_BINARY_DIR=/tmp/ocinv -P tests/offscreen_invalid_operation.cmake
[exit 0]
$ wine ./offscreen_check.exe --self-test
offscreen_self_test: cli_validation=ok gate_skip=ok outcome_fail=ok outcome_throw=ok outcome_skip=ok outcome_pass=ok

Negative control for the cmake script too: making the bare-invocation message generic (bad arguments) fails it with Expected a usage error for a bare invocation, got exit 2.

The first commit already ran green on the hosted jobs (Windows, gfx1013, Linux Python); this one is the same change plus assertions, so the new run is the check.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7385826477 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#issuecomment-7385826477). Originally posted by [triggered02](https://github.com/triggered02) on 2026-12-03T17:01:07Z. --- Second commit `cd4f01ba` adds the process-level assertions: `tests/offscreen_invalid_operation.cmake` already runs the built binary for the invalid-operation and positional-draw paths, so it now also checks that the draw path names its rule and echoes the command line, plus a bare invocation and a wrong backend (exit 2, reason, usage line). Run on this host by wrapping the Windows binary in `wine`: ``` $ cmake -DRENDERER=/tmp/ocwine.sh -DCMAKE_CURRENT_BINARY_DIR=/tmp/ocinv -P tests/offscreen_invalid_operation.cmake [exit 0] $ wine ./offscreen_check.exe --self-test offscreen_self_test: cli_validation=ok gate_skip=ok outcome_fail=ok outcome_throw=ok outcome_skip=ok outcome_pass=ok ``` Negative control for the cmake script too: making the bare-invocation message generic (`bad arguments`) fails it with `Expected a usage error for a bare invocation, got exit 2`. The first commit already ran green on the hosted jobs (Windows, gfx1013, Linux Python); this one is the same change plus assertions, so the new run is the check.
triggered02 commented 2026-12-03 17:10:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T17:10:20Z.


Hosted jobs on cd4f01ba are green: Build and test on Windows SUCCESS (the full suite, which includes offscreen_capability_table_self_test and offscreen_invalid_operation_warp, so both the in-process and the process-level assertions ran there), gfx1013 SUCCESS, Linux Python checks SUCCESS. The previous head 6bac447c was also fully green.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7386078996 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#issuecomment-7386078996). Originally posted by [triggered02](https://github.com/triggered02) on 2026-12-03T17:10:20Z. --- Hosted jobs on `cd4f01ba` are green: **Build and test on Windows** SUCCESS (the full suite, which includes `offscreen_capability_table_self_test` and `offscreen_invalid_operation_warp`, so both the in-process and the process-level assertions ran there), gfx1013 SUCCESS, Linux Python checks SUCCESS. The previous head `6bac447c` was also fully green.
R0Y00 commented 2026-12-03 17:21:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T17:21:17Z.

Review: CHANGES_REQUESTED


On cd4f01ba I rebuilt offscreen_check; its registered self-test passed. Independently running offscreen_check warp output.bin extra-argument returns 2 and still prints “a draw run takes an expected-image path and a pixel count, or neither” plus the same expected.bin/pixels form in usage. The actual draw entry point accepts an output path and optional vertex/pixel shader paths. Please align the text and the process-level assertion with the parser. The new end-to-end test currently locks in the misleading syntax flagged in the open thread.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6174841329 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#pullrequestreview-6174841329). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T17:21:17Z. **Review:** CHANGES_REQUESTED --- On cd4f01ba I rebuilt offscreen_check; its registered self-test passed. Independently running offscreen_check warp output.bin extra-argument returns 2 and still prints “a draw run takes an expected-image path and a pixel count, or neither” plus the same expected.bin/pixels form in usage. The actual draw entry point accepts an output path and optional vertex/pixel shader paths. Please align the text and the process-level assertion with the parser. The new end-to-end test currently locks in the misleading syntax flagged in the open thread.
triggered02 commented 2026-12-03 17:32:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T17:32:10Z.


You are right, and the mistake is mine in a way worth naming: I described the positional draw from the fixtures that invoke it instead of from what draw() does with argv[2] and argv[3..4]. 6ae283ef fixes the text and the assertion that was pinning it.

The draw entry point is offscreen_check <warp|hardware> <output-image> [<vertex-shader> <pixel-shader>]. The expected image and pixel count belong to --startup-pixel-words, not to the positional form — which is exactly the kind of confusion my "expected-image path and a pixel count" wording created.

What changed:

usage: offscreen_check <warp|hardware> <output-image> [<vertex-shader> <pixel-shader>] | <warp|hardware> <--operation> [operands] | --self-test
offscreen_check: a draw run takes an output image, optionally followed by a vertex and a pixel shader

The bare-invocation reason now says "an output image" too, and tests/offscreen_invalid_operation.cmake asserts the corrected strings (so the process-level test no longer locks in the wrong syntax).

Evidence on this host (clang-cl 19 xwin build, Wine + vkd3d-proton):

$ wine ./offscreen_check.exe warp output.bmp extra-argument        # exit 2
offscreen_check: a draw run takes an output image, optionally followed by a vertex and a pixel shader
command: ...\offscreen_check.exe warp output.bmp extra-argument
usage: offscreen_check <warp|hardware> <output-image> [<vertex-shader> <pixel-shader>] | ...

$ wine ./offscreen_check.exe warp /tmp/out.bmp /tmp/missing_vs.cso /tmp/missing_ps.cso
adapter=NVIDIA GeForce GTX 1660 SUPER ...        # exit 1, only because the shader files are absent:
                                                # the five-argument form parses and reaches the device

$ wine ./offscreen_check.exe warp out.bmp vs.cso                   # exit 2: one shader without its pair
$ wine ./offscreen_check.exe --self-test                           # exit 0
$ cmake -DRENDERER=<wine wrapper> -P tests/offscreen_invalid_operation.cmake   # passes

The self-test already asserted {warp, out.bmp} and {hardware, out.bmp, vs.cso, ps.cso} as valid draw forms and {warp, out.bmp, vs.cso} as a usage error; those stay as the parser-level positives.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7386666635 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3948#issuecomment-7386666635). Originally posted by [triggered02](https://github.com/triggered02) on 2026-12-03T17:32:10Z. --- You are right, and the mistake is mine in a way worth naming: I described the positional draw from the *fixtures that invoke it* instead of from what `draw()` does with `argv[2]` and `argv[3..4]`. `6ae283ef` fixes the text and the assertion that was pinning it. The draw entry point is `offscreen_check <warp|hardware> <output-image> [<vertex-shader> <pixel-shader>]`. The expected image and pixel count belong to `--startup-pixel-words`, not to the positional form — which is exactly the kind of confusion my "expected-image path and a pixel count" wording created. What changed: ``` usage: offscreen_check <warp|hardware> <output-image> [<vertex-shader> <pixel-shader>] | <warp|hardware> <--operation> [operands] | --self-test offscreen_check: a draw run takes an output image, optionally followed by a vertex and a pixel shader ``` The bare-invocation reason now says "an output image" too, and `tests/offscreen_invalid_operation.cmake` asserts the corrected strings (so the process-level test no longer locks in the wrong syntax). Evidence on this host (clang-cl 19 xwin build, Wine + vkd3d-proton): ``` $ wine ./offscreen_check.exe warp output.bmp extra-argument # exit 2 offscreen_check: a draw run takes an output image, optionally followed by a vertex and a pixel shader command: ...\offscreen_check.exe warp output.bmp extra-argument usage: offscreen_check <warp|hardware> <output-image> [<vertex-shader> <pixel-shader>] | ... $ wine ./offscreen_check.exe warp /tmp/out.bmp /tmp/missing_vs.cso /tmp/missing_ps.cso adapter=NVIDIA GeForce GTX 1660 SUPER ... # exit 1, only because the shader files are absent: # the five-argument form parses and reaches the device $ wine ./offscreen_check.exe warp out.bmp vs.cso # exit 2: one shader without its pair $ wine ./offscreen_check.exe --self-test # exit 0 $ cmake -DRENDERER=<wine wrapper> -P tests/offscreen_invalid_operation.cmake # passes ``` The self-test already asserted `{warp, out.bmp}` and `{hardware, out.bmp, vs.cso, ps.cso}` as valid draw forms and `{warp, out.bmp, vs.cso}` as a usage error; those stay as the parser-level positives.
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/3948:upstream-pr/3948'
git switch 'upstream-pr/3948'

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