startup: check the null binding cause labels #1497

Manually merged
github merged 1 commit from gh-pr/1497/head into gh-pr/1497/base 2026-11-26 23:11:51 +00:00
Owner

@⁠Asimmimx on GitHub · 2026-11-24 12:58 UTC · original
Asimmimx:startup/null-binding-cause-check → main · +162 −1 · 3 files · 1 commits · merged 2026-11-24 13:29 UTC

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).

**@⁠Asimmimx** on GitHub · 2026-11-24 12:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1497) `Asimmimx:startup/null-binding-cause-check` → `main` · +162 −1 · 3 files · 1 commits · merged 2026-11-24 13:29 UTC ## 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).
src/startup_stubs/null_binding_cause.h classifies each null binding of
a translated draw. The device counts it at the index given by the
cause's enum value and prints slots 0 to 4 of the x2w-render totals line
under the fixed labels entry, buffer, token, wrapper and dimension. The
only test of the header, startup_null_views_<adapter>, counts causes by
enum name, so it cannot see which slot a cause lands in. Single-point
mutants that swap two enumerators or two entries of null_cause_names
passed startup_null_views_warp, and a mutant that sets none to 0 failed
it only through an out-of-bounds write.

startup_null_cause_labels includes the header without a device. For
one binding per cause, built the way the texture and buffer bindings
build their facts, it checks the slot and the header's name for it. It
then counts a frame in which each cause occurs a different power of two
times and compares the totals text, formatted as the device does and
again from null_cause_names, with a hand-written line. The
buffer-token control expects those two slots swapped and must fail.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:11:49 +00:00
github manually merged commit 7ba209aab5 into gh-pr/1497/base 2026-11-26 23:11:51 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 13:15 UTC · original · reviewed

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).
**@⁠tedin7** on GitHub · 2026-11-24 13:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1497#pullrequestreview-6039835483) · **reviewed** 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`).
This discussion has been locked. Commenting is limited to contributors.
No description provided.