startup: check that the last derived blend patch wins #1447

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

@⁠Asimmimx on GitHub · 2026-11-24 11:44 UTC · original
Asimmimx:startup/derived-blend-check → main · +117 −0 · 3 files · 1 commits · merged 2026-11-24 11:57 UTC

Change

Refs #1149. That issue asks for a specific untested stand-in behavior and a source-built control for it. This PR covers the slot-55 blend-patch scan in src/startup_stubs/derived_blend.h (x2w_derived_blend::last_blend).

Before this PR, the only CTest that reached the header was startup_stream_draw_{warp,hardware}, through the slot-55 derivation in tests/startup_stream_consumer.cpp. That draw catches the faults that change rendering. It cannot observe:

  • the descriptor offset the scan returns, which only appears in the blend from ... at +0x log line;
  • the whole-record size check;
  • the null check.

The device never passes anything other than count * record_size bytes, and it rejects a null list when count > 0.

This PR adds startup_derived_blend, a device-free C++ check with 11 cases:

  • one and two blend patches, where the later one wins;
  • a patch before, between and after other parts (tags 3, 1 and 0);
  • tags that only resemble 2 (0x102, 0x2000000, ~0);
  • the returned offset, plus a byte-for-byte check of the copied D3D12_BLEND_DESC against a counting pattern;
  • empty input, null input, a list one byte short and a list with a 4-byte prefix.

startup_derived_blend_first_wins_control runs the same check with --mutate first-wins and must fail (WILL_FAIL).

The change is test, CMake and docs/startup-runtime.md only. The header and d3d12_xs_device.cpp are unchanged.

Verification

Commit 92bd3362 (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0.

ctest --preset dev --no-tests=error -R '^(startup_derived_blend|startup_derived_blend_first_wins_control|startup_stream_draw_warp)$' -V
startup_derived_blend ......................   Passed   (startup_derived_blend: PASS (11 cases))
startup_derived_blend_first_wins_control ...   Passed   (2 of 11 FAILED, as the control expects)
startup_stream_draw_warp ...................   Passed

tests/docs_links_check.py (16 files, 324 links), tests/bidi_controls_check.py and git diff --check all passed. The new test is CPU-only: no device, Python or FXC.

Mutation probe

I applied each mutation to derived_blend.h alone, rebuilt, ran both tests, then reverted. None of this is committed.

Mutant startup_stream_draw_warp startup_derived_blend
scan from the front (first patch wins) killed killed
drop the bytes % record_size check survived killed
report the tag's offset (offset = at), copy unchanged survived killed
report and copy from the tag killed killed
drop the null check survived killed
match any tag killed killed
match tag 3 killed killed
skip the last record killed killed
skip the first record killed killed

With the size check or the null check dropped, the scan reads out of bounds, so the new test ends in an access violation rather than a clean failure. It prints the failing case name before that.

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 11:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1447) `Asimmimx:startup/derived-blend-check` → `main` · +117 −0 · 3 files · 1 commits · merged 2026-11-24 11:57 UTC ## Change Refs #1149. That issue asks for a specific untested stand-in behavior and a source-built control for it. This PR covers the slot-55 blend-patch scan in `src/startup_stubs/derived_blend.h` (`x2w_derived_blend::last_blend`). Before this PR, the only CTest that reached the header was `startup_stream_draw_{warp,hardware}`, through the slot-55 derivation in `tests/startup_stream_consumer.cpp`. That draw catches the faults that change rendering. It cannot observe: - the descriptor offset the scan returns, which only appears in the `blend from ... at +0x` log line; - the whole-record size check; - the null check. The device never passes anything other than `count * record_size` bytes, and it rejects a null list when count > 0. This PR adds `startup_derived_blend`, a device-free C++ check with 11 cases: - one and two blend patches, where the later one wins; - a patch before, between and after other parts (tags 3, 1 and 0); - tags that only resemble 2 (`0x102`, `0x2000000`, `~0`); - the returned offset, plus a byte-for-byte check of the copied `D3D12_BLEND_DESC` against a counting pattern; - empty input, null input, a list one byte short and a list with a 4-byte prefix. `startup_derived_blend_first_wins_control` runs the same check with `--mutate first-wins` and must fail (`WILL_FAIL`). The change is test, CMake and `docs/startup-runtime.md` only. The header and `d3d12_xs_device.cpp` are unchanged. ## Verification Commit `92bd3362` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0. ```powershell ctest --preset dev --no-tests=error -R '^(startup_derived_blend|startup_derived_blend_first_wins_control|startup_stream_draw_warp)$' -V ``` ```text startup_derived_blend ...................... Passed (startup_derived_blend: PASS (11 cases)) startup_derived_blend_first_wins_control ... Passed (2 of 11 FAILED, as the control expects) startup_stream_draw_warp ................... Passed ``` `tests/docs_links_check.py` (16 files, 324 links), `tests/bidi_controls_check.py` and `git diff --check` all passed. The new test is CPU-only: no device, Python or FXC. ## Mutation probe I applied each mutation to `derived_blend.h` alone, rebuilt, ran both tests, then reverted. None of this is committed. | Mutant | `startup_stream_draw_warp` | `startup_derived_blend` | |---|---|---| | scan from the front (first patch wins) | killed | killed | | drop the `bytes % record_size` check | **survived** | killed | | report the tag's offset (`offset = at`), copy unchanged | **survived** | killed | | report and copy from the tag | killed | killed | | drop the null check | **survived** | killed | | match any tag | killed | killed | | match tag 3 | killed | killed | | skip the last record | killed | killed | | skip the first record | killed | killed | With the size check or the null check dropped, the scan reads out of bounds, so the new test ends in an access violation rather than a clean failure. It prints the failing case name before that. ## 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).
x2w_derived_blend::last_blend was reached only through the slot 55 draw
in startup_stream_draw_{warp,hardware}. That draw kills a forward scan,
a wrong or missing tag match and an off-by-one at either end, but it
cannot see the descriptor offset the scan reports (only logged), and the
device never hands it a null list or one that is not whole records.
Mutants that report the tag's offset instead of the descriptor's, drop
the whole-record check or drop the null check all pass that test.

startup_derived_blend checks the header without a device: one and two
blend patches, a blend patch before, between and after other parts,
tags that only resemble 2, the returned offset and a byte-for-byte copy
of the descriptor, and empty, null, short and prefixed lists. The
first-wins control expects the earlier patch and must fail.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:07:50 +00:00
github manually merged commit d32b7feafb into gh-pr/1447/base 2026-11-26 23:07:51 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.