startup: check the draw dump budget and removal fences #1543

Merged
Asimmimx merged 1 commit from upstream-pr/1550 into main 2026-11-24 16:22:20 +00:00
Asimmimx commented 2026-11-24 13:49:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:49:37Z.


Change

Refs #1149. This extends startup_dump_fence, the check for src/startup_stubs/draw_dump_tracking.h. That header is the tracker behind X2W_DRAW_DUMP_FRAME, the draw-dump capture. It does four things:

  • numbers captures from 1;
  • keeps a budget of 48 captures, counting copies that are pending, written and consumed;
  • finds the lists of a submitted batch;
  • attaches a fence per submission, publishes a copy only when its fence completes normally, and returns a failed queue Signal.

The only test, startup_dump_fence_warp, submits one list on a real WARP queue and checks one completed copy. No other test sets X2W_DRAW_DUMP_FRAME. So 8 of 10 mutants left it passing (table below). One example: a copy whose fence completes with UINT64_MAX, as on device removal, was published anyway.

The new run_budget() drives the tracker through ScriptedQueue, a stand-in ID3D12CommandQueue. Its GetDevice returns the real WARP device, so the tracker creates a real fence. Its Signal keeps that fence and returns a chosen HRESULT, and the test completes the fence from the CPU with 1 or UINT64_MAX. The expectations are hand-worked:

  • a two-list batch gives captures 1 and 2, with one Signal of 1;
  • with one copy pending and two written, full() is false before each of 45 records and true after them, and a 46th record fails;
  • a fence completed with UINT64_MAX publishes nothing and leaves 46 slots;
  • a failed Signal returns DXGI_ERROR_DEVICE_REMOVED; the copy is kept after discard, is never published, and leaves 45 slots.

The new startup_dump_fence_removed_control_warp (--mutate removed) expects the removed copy to be published, and must fail (WILL_FAIL).

The existing run() is unchanged. The change touches tests/startup_dump_fence.cpp, one CTest registered after startup_dump_fence_warp, and one sentence in the X2W_DRAW_DUMP_FRAME row of docs/startup-runtime.md.

Verification

Commit 309cfede (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_dump_fence_(removed_control_)?warp$' -V
#   2/2 passed, 3 of 3 runs; prints batch=2 budget=45 removed=0 after_removal=46 after_failure=45

tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed. The test is registered for WARP only, so it has no hardware variant.

Mutation probe

I applied each mutation to the header alone, rebuilt startup_dump_fence_check, ran the test, then reverted. None of this is committed.

Mutant Original test With the new cases
control: discard matches != killed killed
limit = 49 survived killed ("Budget open after 48 captures")
full() ignores consumed copies survived killed
record() checks > instead of >= survived killed
++consumed_ removed survived killed
indices start at 0 survived killed ("Expected a1 as capture 1")
batch search checks only the first list survived killed ("Expected both lists of the batch to complete")
removed copy (UINT64_MAX) published survived killed ("Capture published after device removal")
control: entry.recording = nullptr dropped killed killed
execute returns S_OK instead of the Signal HRESULT survived killed ("Signal failure was not returned")

Notes for review:

  • Not device-free. execute() calls queue->GetDevice() and CreateFence, so this uses a real WARP device and fakes only the queue. A fake ID3D12Device would need about 44 stubbed methods.
  • Simulated removal. The UINT64_MAX completion is signalled from the CPU as a stand-in for a real device removal.
  • Not pinned. Attaching the fence after a failed Signal is left alone, because no real caller can later complete such a fence.

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:6583273740 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1550). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T13:49:37Z. --- ## Change Refs #1149. This extends `startup_dump_fence`, the check for `src/startup_stubs/draw_dump_tracking.h`. That header is the tracker behind `X2W_DRAW_DUMP_FRAME`, the draw-dump capture. It does four things: - numbers captures from 1; - keeps a budget of 48 captures, counting copies that are pending, written and consumed; - finds the lists of a submitted batch; - attaches a fence per submission, publishes a copy only when its fence completes normally, and returns a failed queue `Signal`. The only test, `startup_dump_fence_warp`, submits one list on a real WARP queue and checks one completed copy. No other test sets `X2W_DRAW_DUMP_FRAME`. So 8 of 10 mutants left it passing (table below). One example: a copy whose fence completes with `UINT64_MAX`, as on device removal, was published anyway. The new `run_budget()` drives the tracker through `ScriptedQueue`, a stand-in `ID3D12CommandQueue`. Its `GetDevice` returns the real WARP device, so the tracker creates a real fence. Its `Signal` keeps that fence and returns a chosen HRESULT, and the test completes the fence from the CPU with 1 or `UINT64_MAX`. The expectations are hand-worked: - a two-list batch gives captures 1 and 2, with one `Signal` of 1; - with one copy pending and two written, `full()` is false before each of 45 records and true after them, and a 46th record fails; - a fence completed with `UINT64_MAX` publishes nothing and leaves 46 slots; - a failed `Signal` returns `DXGI_ERROR_DEVICE_REMOVED`; the copy is kept after `discard`, is never published, and leaves 45 slots. The new `startup_dump_fence_removed_control_warp` (`--mutate removed`) expects the removed copy to be published, and must fail (`WILL_FAIL`). The existing `run()` is unchanged. The change touches `tests/startup_dump_fence.cpp`, one CTest registered after `startup_dump_fence_warp`, and one sentence in the `X2W_DRAW_DUMP_FRAME` row of `docs/startup-runtime.md`. ## Verification Commit `309cfede` (`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_dump_fence_(removed_control_)?warp$' -V # 2/2 passed, 3 of 3 runs; prints batch=2 budget=45 removed=0 after_removal=46 after_failure=45 ``` `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. The test is registered for WARP only, so it has no hardware variant. ## Mutation probe I applied each mutation to the header alone, rebuilt `startup_dump_fence_check`, ran the test, then reverted. None of this is committed. | Mutant | Original test | With the new cases | |---|---|---| | control: `discard` matches `!=` | killed | killed | | `limit = 49` | **survived** | killed ("Budget open after 48 captures") | | `full()` ignores consumed copies | **survived** | killed | | `record()` checks `>` instead of `>=` | **survived** | killed | | `++consumed_` removed | **survived** | killed | | indices start at 0 | **survived** | killed ("Expected a1 as capture 1") | | batch search checks only the first list | **survived** | killed ("Expected both lists of the batch to complete") | | removed copy (`UINT64_MAX`) published | **survived** | killed ("Capture published after device removal") | | control: `entry.recording = nullptr` dropped | killed | killed | | `execute` returns `S_OK` instead of the `Signal` HRESULT | **survived** | killed ("Signal failure was not returned") | Notes for review: - **Not device-free.** `execute()` calls `queue->GetDevice()` and `CreateFence`, so this uses a real WARP device and fakes only the queue. A fake `ID3D12Device` would need about 44 stubbed methods. - **Simulated removal.** The `UINT64_MAX` completion is signalled from the CPU as a stand-in for a real device removal. - **Not pinned.** Attaching the fence after a failed `Signal` is left alone, because no real caller can later complete such a fence. ## 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 17:01:34 +00:00
tedin7 commented 2026-11-24 17:01:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:09:22Z.

Review: COMMENTED


Reviewed at a3a6c3184bfa412ee795753b7f700f1491d58fdf.

The new run_budget() coverage in tests/startup_dump_fence.cpp exercises the 48-capture budget (entries_.size() + consumed_ >= limit), 1-based capture numbering across a multi-list batch, unwritten release on UINT64_MAX fence completion, and retention across discard() when ID3D12CommandQueue::Signal fails. ScriptedQueue delegates GetDevice to the WARP device so fence creation uses a real D3D12 fence while Signal returns the scripted HRESULT.

Checks executed locally:

  • Hygiene (tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check): passed.
  • Win2025 Debug (cmake --build --preset dev --target startup_dump_fence_check, ctest --preset dev -R '^(startup_dump_fence_removed_control_warp|startup_dump_fence_warp)$' --no-tests=error --output-on-failure): 2/2 passed.
  • Win2025 Release /O2 (cmake --build --preset release --target startup_dump_fence_check, ctest --preset release -R '^(startup_dump_fence_removed_control_warp|startup_dump_fence_warp)$' --no-tests=error --output-on-failure): 2/2 passed.
  • Mutation control (startup_dump_fence_removed_control_warp via --mutate removed, WILL_FAIL TRUE): passed (failed as expected when expecting a UINT64_MAX-completed capture to be published).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6042942806 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1550#pullrequestreview-6042942806). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:09:22Z. **Review:** COMMENTED --- Reviewed at `a3a6c3184bfa412ee795753b7f700f1491d58fdf`. The new `run_budget()` coverage in `tests/startup_dump_fence.cpp` exercises the 48-capture budget (`entries_.size() + consumed_ >= limit`), 1-based capture numbering across a multi-list batch, unwritten release on `UINT64_MAX` fence completion, and retention across `discard()` when `ID3D12CommandQueue::Signal` fails. `ScriptedQueue` delegates `GetDevice` to the WARP device so fence creation uses a real D3D12 fence while `Signal` returns the scripted `HRESULT`. Checks executed locally: - Hygiene (`tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `git diff --check`): passed. - Win2025 Debug (`cmake --build --preset dev --target startup_dump_fence_check`, `ctest --preset dev -R '^(startup_dump_fence_removed_control_warp|startup_dump_fence_warp)$' --no-tests=error --output-on-failure`): 2/2 passed. - Win2025 Release `/O2` (`cmake --build --preset release --target startup_dump_fence_check`, `ctest --preset release -R '^(startup_dump_fence_removed_control_warp|startup_dump_fence_warp)$' --no-tests=error --output-on-failure`): 2/2 passed. - Mutation control (`startup_dump_fence_removed_control_warp` via `--mutate removed`, `WILL_FAIL TRUE`): passed (failed as expected when expecting a `UINT64_MAX`-completed capture to be published). AI-assisted; commands listed were executed locally.
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!1543
No description provided.