startup: check the null binding cause labels #1490

Merged
Asimmimx merged 1 commit from upstream-pr/1497 into main 2026-11-24 13:29:58 +00:00
Asimmimx commented 2026-11-24 12:58:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T12:58:13Z.


Change

Refs #1149. This adds a device-free check for src/startup_stubs/null_binding_cause.h.

The header classifies why a translated draw bound a null descriptor. d3d12_draw.inl counts each null binding at the index given by its NullCause value. The x2w-render totals line in d3d12_xs_device.cpp then prints slots 0 to 4 under labels typed into its format string: entry, buffer, token, wrapper, dimension.

The only test that reaches the header is startup_null_views_<adapter>, through tests/null_binding_cause_cases.h, and it counts causes by enum name. It cannot see which slot a cause lands in, and no test reads the totals. So:

  • swapping two enumerators, e.g. buffer_unreadable and unknown_token, left startup_null_views_warp passing, while the totals line would print buffer counts as token and the reverse;
  • swapping two entries of null_cause_names also left it passing;
  • none = 0 failed it only through an out-of-bounds write, after 4.3 s.

startup_null_cause_labels includes only the header. It has one fact set per cause, built the way the texture and buffer call sites build them, and checks each cause's slot and name. It then counts a frame in which the five causes occur 1, 2, 4, 8 and 16 times, plus valid bindings that add nothing. It formats the totals twice, once with the device's format string and once with labels from null_cause_names. Both must equal the hand-written line null bindings 31 (entry 1, buffer 2, token 4, wrapper 8, dimension 16).

startup_null_cause_labels_buffer_token_control runs --mutate buffer-token and must fail (WILL_FAIL).

The change is test, CMake and docs/startup-runtime.md ("Null bindings in translated draws") only. The CMake block follows startup_null_views.

Verification

Commit 93672b99 (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.

ctest --preset dev --no-tests=error -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' -V
#   startup_null_views_warp ... Passed
#   startup_null_cause_labels ... Passed
#   startup_null_cause_labels_buffer_token_control ... Passed (6 of 14 cases fail, as the control intends)

tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed.

Mutation probe

I applied each mutation to the header alone, rebuilt the affected targets, ran the tests, then reverted. None of this is committed.

Mutant startup_null_views_warp startup_null_cause_labels
control: dimension ternary inverted killed fails
buffer_unreadable and unknown_token swapped in the enum survived fails
none = -1 changed to none = 0 killed, only through an out-of-bounds write fails
null_cause_names token and wrapper swapped survived fails
!f.texture && f.bound → f.bound survived survived (equivalent)
drop from_table && on the unknown-token line survived survived (equivalent)
texture branch !token_magic → !token_known survived survived (equivalent)
drop from_table && on the table-entry line killed fails
!resource_wrapper returns dimension_mismatch killed fails

The three equivalent mutants are not pinned, because no input the device builds tells them apart. Textures always have from_table=true and bound=false, token_known is only set together with token_magic, and vertex and root bindings have no table entry.

Two notes for the reviewer:

  • The check copies the device's totals format string, so an edit to that string in src/ would not be noticed. It catches mismatches inside the header: enum order, the none value and the order of the names.
  • null_cause_names is not used in src/ today. It is checked here as the header's stated label table. If you would rather remove it, say so and I will drop that part.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6582309825 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1497). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T12:58:13Z. --- ## Change Refs #1149. This adds a device-free check for `src/startup_stubs/null_binding_cause.h`. The header classifies why a translated draw bound a null descriptor. `d3d12_draw.inl` counts each null binding at the index given by its `NullCause` value. The `x2w-render` totals line in `d3d12_xs_device.cpp` then prints slots 0 to 4 under labels typed into its format string: `entry`, `buffer`, `token`, `wrapper`, `dimension`. The only test that reaches the header is `startup_null_views_<adapter>`, through `tests/null_binding_cause_cases.h`, and it counts causes by enum name. It cannot see which slot a cause lands in, and no test reads the totals. So: - swapping two enumerators, e.g. `buffer_unreadable` and `unknown_token`, left `startup_null_views_warp` passing, while the totals line would print buffer counts as `token` and the reverse; - swapping two entries of `null_cause_names` also left it passing; - `none = 0` failed it only through an out-of-bounds write, after 4.3 s. `startup_null_cause_labels` includes only the header. It has one fact set per cause, built the way the texture and buffer call sites build them, and checks each cause's slot and name. It then counts a frame in which the five causes occur 1, 2, 4, 8 and 16 times, plus valid bindings that add nothing. It formats the totals twice, once with the device's format string and once with labels from `null_cause_names`. Both must equal the hand-written line `null bindings 31 (entry 1, buffer 2, token 4, wrapper 8, dimension 16)`. `startup_null_cause_labels_buffer_token_control` runs `--mutate buffer-token` and must fail (`WILL_FAIL`). The change is test, CMake and `docs/startup-runtime.md` ("Null bindings in translated draws") only. The CMake block follows `startup_null_views`. ## Verification Commit `93672b99` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818. ```powershell ctest --preset dev --no-tests=error -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' -V # startup_null_views_warp ... Passed # startup_null_cause_labels ... Passed # startup_null_cause_labels_buffer_token_control ... Passed (6 of 14 cases fail, as the control intends) ``` `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. ## Mutation probe I applied each mutation to the header alone, rebuilt the affected targets, ran the tests, then reverted. None of this is committed. | Mutant | `startup_null_views_warp` | `startup_null_cause_labels` | |---|---|---| | control: dimension ternary inverted | killed | fails | | `buffer_unreadable` and `unknown_token` swapped in the enum | **survived** | fails | | `none = -1` changed to `none = 0` | killed, only through an out-of-bounds write | fails | | `null_cause_names` `token` and `wrapper` swapped | **survived** | fails | | `!f.texture && f.bound` → `f.bound` | survived | survived (equivalent) | | drop `from_table &&` on the unknown-token line | survived | survived (equivalent) | | texture branch `!token_magic` → `!token_known` | survived | survived (equivalent) | | drop `from_table &&` on the table-entry line | killed | fails | | `!resource_wrapper` returns `dimension_mismatch` | killed | fails | The three equivalent mutants are not pinned, because no input the device builds tells them apart. Textures always have `from_table=true` and `bound=false`, `token_known` is only set together with `token_magic`, and vertex and root bindings have no table entry. Two notes for the reviewer: - The check copies the device's totals format string, so an edit to that string in `src/` would not be noticed. It catches mismatches inside the header: enum order, the `none` value and the order of the names. - `null_cause_names` is not used in `src/` today. It is checked here as the header's stated label table. If you would rather remove it, say so and I will drop that part. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 14:02:57 +00:00
tedin7 commented 2026-11-24 14:02:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:15:10Z.

Review: COMMENTED


Reviewed 7ba209aab55de98c07c2afe257ba353d3bd885f5 (CMakeLists.txt, docs/startup-runtime.md, tests/startup_null_cause_labels_check.cpp).

Audit

  • Slot & label mapping: startup_null_cause_labels_check verifies x2w_local::null_cause_count == 5, checks null_cause_names[0..4] against {"entry", "buffer", "token", "wrapper", "dimension"}, tests each NullCause classification into slots 0..4, and checks power-of-two per-slot totals in the formatted totals line.
  • Negative control: --mutate buffer-token (startup_null_cause_labels_buffer_token_control, WILL_FAIL TRUE) swaps the expected buffer and token slots and fails as intended.
  • Note: As noted in the PR description, the test duplicates the totals format string from src/startup_stubs/d3d12_xs_device.cpp rather than driving the device log, so it guards src/startup_stubs/null_binding_cause.h directly rather than catching a format-string edit in d3d12_xs_device.cpp. docs/startup-runtime.md is updated accurately and remains title-neutral.

Checks

  • Linux: tests/docs_links_check.py (16 Markdown files, 334 links), tests/bidi_controls_check.py (1223 tracked files), and git diff --check all passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): built startup_null_cause_labels_check (3.10s); ctest --preset dev -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' --no-tests=error — 3/3 passed (0.15s).
    • Release /O2 (--preset release): built startup_null_cause_labels_check (0.44s); ctest --preset release -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' --no-tests=error — 3/3 passed (0.13s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039835483 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1497#pullrequestreview-6039835483). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:15:10Z. **Review:** COMMENTED --- Reviewed `7ba209aab55de98c07c2afe257ba353d3bd885f5` (`CMakeLists.txt`, `docs/startup-runtime.md`, `tests/startup_null_cause_labels_check.cpp`). ### Audit - **Slot & label mapping**: `startup_null_cause_labels_check` verifies `x2w_local::null_cause_count == 5`, checks `null_cause_names[0..4]` against `{"entry", "buffer", "token", "wrapper", "dimension"}`, tests each `NullCause` classification into slots `0..4`, and checks power-of-two per-slot totals in the formatted totals line. - **Negative control**: `--mutate buffer-token` (`startup_null_cause_labels_buffer_token_control`, `WILL_FAIL TRUE`) swaps the expected `buffer` and `token` slots and fails as intended. - **Note**: As noted in the PR description, the test duplicates the totals format string from `src/startup_stubs/d3d12_xs_device.cpp` rather than driving the device log, so it guards `src/startup_stubs/null_binding_cause.h` directly rather than catching a format-string edit in `d3d12_xs_device.cpp`. `docs/startup-runtime.md` is updated accurately and remains title-neutral. ### Checks - **Linux**: `tests/docs_links_check.py` (16 Markdown files, 334 links), `tests/bidi_controls_check.py` (1223 tracked files), and `git diff --check` all passed. - **Windows Server 2025** (Build 26100, MSVC 14.44.35207 + D3D12 WARP): - **Debug (`--preset dev`)**: built `startup_null_cause_labels_check` (`3.10s`); `ctest --preset dev -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' --no-tests=error` — **3/3 passed** (`0.15s`). - **Release `/O2` (`--preset release`)**: built `startup_null_cause_labels_check` (`0.44s`); `ctest --preset release -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' --no-tests=error` — **3/3 passed** (`0.13s`).
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!1490
No description provided.