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

Merged
Asimmimx merged 1 commit from upstream-pr/1447 into main 2026-11-24 11:57:11 +00:00
Asimmimx commented 2026-11-24 11:44:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T11:44:25Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581003886 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1447). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T11:44:25Z. --- ## 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).
upstream-sync closed this pull request 2026-11-24 12:03:05 +00:00
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!1440
No description provided.