startup: count ExecuteIndirect calls by refusal reason and signature kind #2172

Merged
NiiRoZz merged 4 commits from upstream-pr/2180 into main 2026-11-25 03:14:20 +00:00
NiiRoZz commented 2026-11-25 03:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T03:01:22Z.


Change

list_execute_indirect (command-list slot 61) logs its first 16 refusals and then goes quiet, so a run cannot tell how many calls fall under each reason or signature kind. In a one-frame capture of a local run, every slot-61 call was refused, for three reasons: no matching desktop graphics pipeline and root, no desktop compute pipeline and root, or a placeholder signature.

This change:

  • Gives the refuse path an outcome index: graphics-pipeline, compute-pipeline, placeholder-signature, or other (every remaining refusal). Forwarded calls are counted too.
  • Keeps volatile LONG64 counters per outcome × signature kind (draw, drawindexed, dispatch, dispatchmesh, other for a placeholder or unknown signature). The kind is read before the first check, so even an early refusal, such as a call with two commands, is counted under its signature's kind. They are cumulative and never reset, so they neither wrap nor stall. The existing 16-line first_calls log is unchanged.
  • Prints one line beside the 300-frame x2w-render totals heartbeat:
x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; other: drawindexed 3

Nothing else changes: the same calls are forwarded and refused.

Refs #1759 (ExecuteIndirect), #1412 (the compute-pipeline reason), #870.

Overlap: open #2173 (rectangle-list indirect Draw arguments) edits refusal lines in the same function, so a textual conflict is expected with whichever lands second; this change only adds a reason index to those calls, and I will rebase it on #2173 if that merges first.

Verification

Head c8668856 (origin/main e3e39c43 merged in), branch startup/indirect-refusal-counts. Windows 11 build 26300, release preset, D3D12 debug layer enabled in every run. Adapters: WARP (Microsoft Basic Render Driver, 10.0.26100.10068) and NVIDIA GeForce RTX 5090 (driver 32.0.16.2135).

cmake --build --preset release --target startup_indirect_dispatch startup_indirect_draw_indexed
ctest --preset release --no-tests=error -R '^startup_indirect_(dispatch|root_constants|draw_indexed|draw|mesh|counts_control)_(warp|hardware)$'
# 100% tests passed, 0 tests failed out of 11 (no capability skips)
python -B tests/docs_links_check.py
# Checked 18 Markdown files and 401 links.

How the line is checked: startup_indirect_draw_indexed (the indexed variant) now does three extra things.

  • It sends one call per counted refusal reason: a null signature, a draw-indexed call with no desktop pipeline bound, a dispatch call with no compute pipeline bound, and a draw-indexed call with two commands.
  • It presents 300 empty console frames (queue slot 32, no planes, picture signature off). No surface is passed, so no window is created or shown.
  • It reads X2W_TRAP_LOG and compares the last x2w-render indirect line with the expected counts. The expected forwarded count is 3 (the unrefused runs). The three other refusals come from the existing short-argument and invalid-index cases and the two-command call.

Negative control: startup_indirect_counts_control_warp runs the same test but expects one forwarded call too many (4). The test prints got '<line>' only when it reports a mismatch. The control's PASS_REGULAR_EXPRESSION is a single pattern, written without semicolons because CMake would split it into a list where any one item could match. It requires got followed by the whole observed line with the real counts. So the control passes only when the mismatch is reported and the observed counts are right. A crash or an empty line does not pass it.

Mutants, each built and run with both tests (startup_indirect_draw_indexed_warp / startup_indirect_counts_control_warp):

Mutant Positive test Control
Forwarded calls not counted fail fail
Kind read after the early refusals fail fail
The control expects the real count pass fail
The comparison never reports pass fail
None (restored) pass pass

Evidence and follow-up

  • The fixture is source-built: the existing HLSL and compute writers in tests/startup_indirect_draw_indexed.cpp. No new inputs.
  • The line counts slot-61 calls since the start. It is not a per-frame rate.
  • CI reach: startup_indirect_draw_indexed_warp and the control run in the pr preset (regex extended) and in the full non-hardware suites. Each test process uses its own X2W_TRAP_LOG file in %TEMP% and deletes it.
  • The graphics-pipeline refusal is also where a translation request could be written for console pipelines used only through slot 61. That is a separate change, startup/indirect-pipeline-requests. It touches the same refuse(...) line, so whichever lands second needs a trivial rebase.
  • An earlier version of the control used a pattern with semicolons. An independent review found that it passed under every mutant; this version fixes it.
  • Upstream did not change the refuse path (still 19 refuse sites). The merge kept the query-slot code it added beside list_execute_indirect.
  • Overlap search (read-only):
    • #1803 (open) changes list_execute_indirect context that is already on main, so a textual conflict is possible.
    • #1972, #2067, #2070 and #2098 do not change the refuse path.
    • No open PR or issue counts ExecuteIndirect refusals.

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 (docs/startup-runtime.md, section 3).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6596202170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2180). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T03:01:22Z. --- ## Change `list_execute_indirect` (command-list slot 61) logs its first 16 refusals and then goes quiet, so a run cannot tell how many calls fall under each reason or signature kind. In a one-frame capture of a local run, every slot-61 call was refused, for three reasons: no matching desktop graphics pipeline and root, no desktop compute pipeline and root, or a placeholder signature. This change: - Gives the refuse path an outcome index: graphics-pipeline, compute-pipeline, placeholder-signature, or other (every remaining refusal). Forwarded calls are counted too. - Keeps `volatile LONG64` counters per outcome × signature kind (`draw`, `drawindexed`, `dispatch`, `dispatchmesh`, `other` for a placeholder or unknown signature). The kind is read before the first check, so even an early refusal, such as a call with two commands, is counted under its signature's kind. They are cumulative and never reset, so they neither wrap nor stall. The existing 16-line `first_calls` log is unchanged. - Prints one line beside the 300-frame `x2w-render totals` heartbeat: ``` x2w-render indirect: forwarded: drawindexed 3; refused graphics-pipeline: drawindexed 1; compute-pipeline: dispatch 1; placeholder-signature: other 1; other: drawindexed 3 ``` Nothing else changes: the same calls are forwarded and refused. Refs #1759 (ExecuteIndirect), #1412 (the compute-pipeline reason), #870. Overlap: open #2173 (rectangle-list indirect Draw arguments) edits refusal lines in the same function, so a textual conflict is expected with whichever lands second; this change only adds a reason index to those calls, and I will rebase it on #2173 if that merges first. ## Verification Head `c8668856` (`origin/main` `e3e39c43` merged in), branch `startup/indirect-refusal-counts`. Windows 11 build 26300, release preset, D3D12 debug layer enabled in every run. Adapters: WARP (Microsoft Basic Render Driver, 10.0.26100.10068) and NVIDIA GeForce RTX 5090 (driver 32.0.16.2135). ```powershell cmake --build --preset release --target startup_indirect_dispatch startup_indirect_draw_indexed ctest --preset release --no-tests=error -R '^startup_indirect_(dispatch|root_constants|draw_indexed|draw|mesh|counts_control)_(warp|hardware)$' # 100% tests passed, 0 tests failed out of 11 (no capability skips) python -B tests/docs_links_check.py # Checked 18 Markdown files and 401 links. ``` How the line is checked: `startup_indirect_draw_indexed` (the indexed variant) now does three extra things. - It sends one call per counted refusal reason: a null signature, a draw-indexed call with no desktop pipeline bound, a dispatch call with no compute pipeline bound, and a draw-indexed call with two commands. - It presents 300 empty console frames (queue slot 32, no planes, picture signature off). No surface is passed, so no window is created or shown. - It reads `X2W_TRAP_LOG` and compares the last `x2w-render indirect` line with the expected counts. The expected forwarded count is 3 (the unrefused runs). The three `other` refusals come from the existing short-argument and invalid-index cases and the two-command call. Negative control: `startup_indirect_counts_control_warp` runs the same test but expects one forwarded call too many (4). The test prints `got '<line>'` only when it reports a mismatch. The control's `PASS_REGULAR_EXPRESSION` is a single pattern, written without semicolons because CMake would split it into a list where any one item could match. It requires `got` followed by the whole observed line with the real counts. So the control passes only when the mismatch is reported and the observed counts are right. A crash or an empty line does not pass it. Mutants, each built and run with both tests (`startup_indirect_draw_indexed_warp` / `startup_indirect_counts_control_warp`): | Mutant | Positive test | Control | |---|---|---| | Forwarded calls not counted | fail | fail | | Kind read after the early refusals | fail | fail | | The control expects the real count | pass | fail | | The comparison never reports | pass | fail | | None (restored) | pass | pass | ## Evidence and follow-up - The fixture is source-built: the existing HLSL and compute writers in `tests/startup_indirect_draw_indexed.cpp`. No new inputs. - The line counts slot-61 calls since the start. It is not a per-frame rate. - CI reach: `startup_indirect_draw_indexed_warp` and the control run in the `pr` preset (regex extended) and in the full non-hardware suites. Each test process uses its own `X2W_TRAP_LOG` file in `%TEMP%` and deletes it. - The graphics-pipeline refusal is also where a translation request could be written for console pipelines used only through slot 61. That is a separate change, `startup/indirect-pipeline-requests`. It touches the same `refuse(...)` line, so whichever lands second needs a trivial rebase. - An earlier version of the control used a pattern with semicolons. An independent review found that it passed under every mutant; this version fixes it. - Upstream did not change the refuse path (still 19 refuse sites). The merge kept the query-slot code it added beside `list_execute_indirect`. - Overlap search (read-only): - #1803 (open) changes `list_execute_indirect` context that is already on `main`, so a textual conflict is possible. - #1972, #2067, #2070 and #2098 do not change the refuse path. - No open PR or issue counts ExecuteIndirect refusals. ## 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 (`docs/startup-runtime.md`, section 3). - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 04:04:08 +00:00
tedin7 commented 2026-11-25 04:04:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:08:32Z.

Review: COMMENTED


Review of head c8668856ea100a483dbb504db7a6fbc0a271cf3f (comment only).

Summary: the per-reason / per-kind ExecuteIndirect counters look correct. I found no P1 or P2.

Checked by reading src/startup_stubs/d3d12_xs_device.cpp:

  • IndirectCommand has 5 values (none, dispatch, draw, draw_indexed, dispatch_mesh). The [outcomes][5] array, the kinds[] names in the printer and the static_cast<int>(kind) index all line up.
  • sig is now resolved before the first refusal. as_wrapper(nullptr) is handled and own() is only touched after the null check, so a null signature counts as none ("other").
  • Every return refuse(...) is counted exactly once. The forwarded counter is bumped only after list->ExecuteIndirect(...), so a call cannot be counted twice.
  • 64-bit InterlockedIncrement64 counters, never reset. The 1024-byte line buffer fits the worst case (5 outcomes x 5 kinds x 19 digits plus labels).
  • The new line is printed in the same frame % 300 style as the existing totals, and the refused log still stops after 16.

Commands executed locally (worktree at the head SHA):

  • git diff --stat origin/main...HEAD: 5 files, +113/-7.
  • python3 tests/docs_links_check.py: pass (18 Markdown files, 401 links).
  • python3 tests/bidi_controls_check.py: pass (1456 files).
  • git diff --check origin/main...HEAD: clean.
  • python3 x2w_pipe.py win2025 2180 --wait 1200 (Win2025, WARP, release /O2): ctest 25/25 passed, including startup_indirect_draw_indexed_warp and startup_indirect_counts_control_warp.
  • CI when I looked: Linux Python checks pass, Windows jobs still pending.

Findings:

  • P1: none.
  • P2: none.
  • nit: CMakeLists.txt (PASS_REGULAR_EXPRESSION of startup_indirect_counts_control_warp) hard-codes the whole expected line. A later change in how the other draw tests count calls will break it with a hard-to-read failure. A short comment saying which calls produce each number would help.
  • nit: tests/startup_indirect_draw_indexed.cpp writes a log file to the temp dir. Please make sure it is deleted on every exit path, including a failing check.
  • Scope: I did not run a source mutation of the counter logic. The negative-control test covers "one forwarded call too many", and the Windows run above exercised it.
  • Clean-room, MIT and title: neutral, no concerns.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051274820 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2180#pullrequestreview-6051274820). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:08:32Z. **Review:** COMMENTED --- Review of head `c8668856ea100a483dbb504db7a6fbc0a271cf3f` (comment only). Summary: the per-reason / per-kind ExecuteIndirect counters look correct. I found no P1 or P2. Checked by reading `src/startup_stubs/d3d12_xs_device.cpp`: - `IndirectCommand` has 5 values (`none, dispatch, draw, draw_indexed, dispatch_mesh`). The `[outcomes][5]` array, the `kinds[]` names in the printer and the `static_cast<int>(kind)` index all line up. - `sig` is now resolved before the first refusal. `as_wrapper(nullptr)` is handled and `own()` is only touched after the null check, so a null signature counts as `none` ("other"). - Every `return refuse(...)` is counted exactly once. The forwarded counter is bumped only after `list->ExecuteIndirect(...)`, so a call cannot be counted twice. - 64-bit `InterlockedIncrement64` counters, never reset. The 1024-byte line buffer fits the worst case (5 outcomes x 5 kinds x 19 digits plus labels). - The new line is printed in the same `frame % 300` style as the existing totals, and the `refused` log still stops after 16. Commands executed locally (worktree at the head SHA): - `git diff --stat origin/main...HEAD`: 5 files, +113/-7. - `python3 tests/docs_links_check.py`: pass (18 Markdown files, 401 links). - `python3 tests/bidi_controls_check.py`: pass (1456 files). - `git diff --check origin/main...HEAD`: clean. - `python3 x2w_pipe.py win2025 2180 --wait 1200` (Win2025, WARP, release `/O2`): ctest 25/25 passed, including `startup_indirect_draw_indexed_warp` and `startup_indirect_counts_control_warp`. - CI when I looked: Linux Python checks pass, Windows jobs still pending. Findings: - P1: none. - P2: none. - nit: `CMakeLists.txt` (`PASS_REGULAR_EXPRESSION` of `startup_indirect_counts_control_warp`) hard-codes the whole expected line. A later change in how the other draw tests count calls will break it with a hard-to-read failure. A short comment saying which calls produce each number would help. - nit: `tests/startup_indirect_draw_indexed.cpp` writes a log file to the temp dir. Please make sure it is deleted on every exit path, including a failing check. - Scope: I did not run a source mutation of the counter logic. The negative-control test covers "one forwarded call too many", and the Windows run above exercised it. - Clean-room, MIT and title: neutral, no concerns. 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!2172
No description provided.