Replace the hardcoded operation chain in offscreen_check with a capability table #165

Closed
opened 2026-11-21 17:50:36 +00:00 by raulmoracode · 3 comments
raulmoracode commented 2026-11-21 17:50:36 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by raulmoracode on 2026-11-21T17:50:36Z.


Problem

tests/offscreen_check.cpp dispatches every GPU check through one if/else chain in main(). Adding an operation currently means editing three separate places:

  • the argument validation block near the top of main() (argc/operation pairing);
  • the capability list in needs_cs_6_5();
  • the dispatch chain itself.

The skip convention is also implicit. check_bvh_differential, check_bvh_waves, check_ray_query and check_dxr_update return false only for "unsupported", and main() turns that into return 77 at four separate sites. A real mismatch is a throw. That works, but a new operation can easily return 77 for a genuine failure and be recorded as a capability skip in the README table.

Proposed change

Replace the chain with a table of rows:

{name, minimum shader model, DXR tier required, argument shape, handler}

main() keeps the adapter and debug-layer setup, then selects a row and applies its capability gate. Exit codes become explicit:

  • 0 pass,
  • 77 only when the capability check fails,
  • 1 for a thrown failure.

A row cannot forget its own gate, and ctest -N names keep coming from the same row.

Alternatives

  • Keep the chain and add a comment listing every capability assumption. Cheaper, but does not prevent the next operation from being added without a gate.
  • Move capability checks into each check function and keep the chain. This is closer to the current code but leaves three edit points.

Verification path

No behaviour change is expected. Verification is that ctest --preset dev -N lists the same test names, every _warp and _hardware test returns the same result as before on WARP, and an added negative row returns 1 instead of 77 when its handler throws.

This touches tests/offscreen_check.cpp, which open pull requests #116, #118, #137 and #147 also edit, so it should land after those.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532352847 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/166). Originally posted by [raulmoracode](https://github.com/raulmoracode) on 2026-11-21T17:50:36Z. --- ## Problem `tests/offscreen_check.cpp` dispatches every GPU check through one `if`/`else` chain in `main()`. Adding an operation currently means editing three separate places: - the argument validation block near the top of `main()` (`argc`/operation pairing); - the capability list in `needs_cs_6_5()`; - the dispatch chain itself. The skip convention is also implicit. `check_bvh_differential`, `check_bvh_waves`, `check_ray_query` and `check_dxr_update` return `false` only for "unsupported", and `main()` turns that into `return 77` at four separate sites. A real mismatch is a `throw`. That works, but a new operation can easily return `77` for a genuine failure and be recorded as a capability skip in the README table. ## Proposed change Replace the chain with a table of rows: ```text {name, minimum shader model, DXR tier required, argument shape, handler} ``` `main()` keeps the adapter and debug-layer setup, then selects a row and applies its capability gate. Exit codes become explicit: - `0` pass, - `77` only when the capability check fails, - `1` for a thrown failure. A row cannot forget its own gate, and `ctest -N` names keep coming from the same row. ## Alternatives - Keep the chain and add a comment listing every capability assumption. Cheaper, but does not prevent the next operation from being added without a gate. - Move capability checks into each check function and keep the chain. This is closer to the current code but leaves three edit points. ## Verification path No behaviour change is expected. Verification is that `ctest --preset dev -N` lists the same test names, every `_warp` and `_hardware` test returns the same result as before on WARP, and an added negative row returns `1` instead of `77` when its handler throws. This touches `tests/offscreen_check.cpp`, which open pull requests #116, #118, #137 and #147 also edit, so it should land after those. _AI-assisted._
R0Y00 commented 2026-11-24 06:47:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:17:51Z.


Lead design decision requested before implementation: should the operation table own capability gates and argument shapes, or should each handler own its capability check? #118 and #137 have landed. #116 and #147 still touch the runner. A candidate can preserve the CTest names and compare pass, capability skip (77) and failure (1) across both configurations.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067149930 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/166#issuecomment-7067149930). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T18:17:51Z. --- Lead design decision requested before implementation: should the operation table own capability gates and argument shapes, or should each handler own its capability check? #118 and #137 have landed. #116 and #147 still touch the runner. A candidate can preserve the CTest names and compare pass, capability skip (77) and failure (1) across both configurations.
lambirou commented 2026-11-24 06:47:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-21T18:39:59Z.


I'd like to take on #166. My preference is for the operation table to own each named command's argument shape and unconditional prerequisites, with scenario-dependent checks handled by the test itself.

  • Put the argument shape, static Shader Model or DXR requirements where applicable, and handler in one row per named operation. Keep the positional shader-file invocation available for existing callers.
  • Keep the wave-width decisions in check_wave_shuffle. It can run the native case and then decide which forced widths the adapter supports. A mismatch in any executed case remains a failure even when another width is unsupported.
  • Map outcomes to exit codes in the runner. Preserve 0 for success, 77 for a capability skip, 1 for a test or D3D12 failure, and the existing usage-error paths.

For verification, I'd compare the ctest --preset dev -N lists before and after, then compare exit codes on my RX 9060 XT and in-box WARP. The baseline from #145 gives a pass and a capability skip for the same operation. I'd also verify that a deterministic failed check still produces 1.

Does this split match what you want? If so, I can coordinate the patch with #116 and #147 so it preserves the adapter selection and app-local WARP paths.

AI-assisted proposal based on the current runner and the local #145 test run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067421352 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/166#issuecomment-7067421352). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-21T18:39:59Z. --- I'd like to take on #166. My preference is for the operation table to own each named command's argument shape and unconditional prerequisites, with scenario-dependent checks handled by the test itself. - Put the argument shape, static Shader Model or DXR requirements where applicable, and handler in one row per named operation. Keep the positional shader-file invocation available for existing callers. - Keep the wave-width decisions in `check_wave_shuffle`. It can run the native case and then decide which forced widths the adapter supports. A mismatch in any executed case remains a failure even when another width is unsupported. - Map outcomes to exit codes in the runner. Preserve `0` for success, `77` for a capability skip, `1` for a test or D3D12 failure, and the existing usage-error paths. For verification, I'd compare the `ctest --preset dev -N` lists before and after, then compare exit codes on my RX 9060 XT and in-box WARP. The baseline from #145 gives a pass and a capability skip for the same operation. I'd also verify that a deterministic failed check still produces `1`. Does this split match what you want? If so, I can coordinate the patch with #116 and #147 so it preserves the adapter selection and app-local WARP paths. _AI-assisted proposal based on the current runner and the local #145 test run._
raulmoracode commented 2026-11-24 06:47:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by raulmoracode on 2026-11-21T18:42:22Z.


This split matches what I would expect: the table owns the argument shape and the unconditional prerequisites, and a handler owns checks that depend on the scenario.

One addition matters for the original problem. The current convention is implicit: a handler returns false for unsupported, throws for failure, and the runner turns false into 77. That is how a real mismatch can be recorded as a capability skip. The table should make the outcome explicit — for example a small result type {pass, skip(reason), fail(detail)}, or a Skip type distinct from a failure. Only the table, after evaluating the row's capability predicate, should be able to produce 77; a handler should not be able to return it directly.

Two points I would add to the verification plan:

  • Compare the SKIP_RETURN_CODE properties as well as the ctest -N names.
  • Add a row whose handler throws and must exit 1, and a row whose capability predicate is false and must exit 77 with a named reason. That pair is the control that the two paths cannot be confused again.
  • Query shader model, DXR tier and lane range once in a shared helper, rather than once in the table and again in the wave check.

On coordination: #116 and #147 change the runner's adapter selection and app-local WARP paths. Writing the table after they land, or against their final signature, avoids a third rebase.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067450897 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/166#issuecomment-7067450897). Originally posted by [raulmoracode](https://github.com/raulmoracode) on 2026-11-21T18:42:22Z. --- This split matches what I would expect: the table owns the argument shape and the unconditional prerequisites, and a handler owns checks that depend on the scenario. One addition matters for the original problem. The current convention is implicit: a handler returns `false` for unsupported, throws for failure, and the runner turns `false` into `77`. That is how a real mismatch can be recorded as a capability skip. The table should make the outcome explicit — for example a small result type `{pass, skip(reason), fail(detail)}`, or a `Skip` type distinct from a failure. Only the table, after evaluating the row's capability predicate, should be able to produce `77`; a handler should not be able to return it directly. Two points I would add to the verification plan: - Compare the `SKIP_RETURN_CODE` properties as well as the `ctest -N` names. - Add a row whose handler throws and must exit `1`, and a row whose capability predicate is false and must exit `77` with a named reason. That pair is the control that the two paths cannot be confused again. - Query shader model, DXR tier and lane range once in a shared helper, rather than once in the table and again in the wave check. On coordination: #116 and #147 change the runner's adapter selection and app-local WARP paths. Writing the table after they land, or against their final signature, avoids a third rebase. _AI-assisted._
Sign in to join this conversation.
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#165
No description provided.