Skip to content

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

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
NiiRoZz:startup/indirect-refusal-counts
Nov 25, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
NiiRoZz:startup/indirect-refusal-counts

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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

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

NiiRoZz and others added 4 commits November 25, 2026 02:28
…kind

The slot-61 refusal log stops after 16 lines, so a run could not tell how
many calls fall under each reason. Keep 64-bit counters per outcome
(forwarded, graphics pipeline, compute pipeline, placeholder signature,
other) and signature kind, and print one x2w-render indirect line beside
the render totals heartbeat. Forwarding is unchanged.

startup_indirect_draw_indexed now refuses one call per counted reason,
presents 300 empty frames and asserts the line; the count-control run
expects one forwarded call too many and must report the mismatch.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rol to the counts

The draw and mesh variants no longer set X2W_TRAP_LOG, so they leave no log
file; the control must report the observed and the wrong forwarded count;
the line buffer fits every outcome with 19-digit counts; the docs paragraph
follows the totals comparison.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…sals under the signature kind

The control's pattern held a semicolon, so CMake split it into a list and
the expected-string half always matched. It now holds no semicolon and
requires the mismatch report's observed line with the real counts. The
signature kind is read before the first refusal, so a two-command call is
counted as other under its kind; the fixture now sends one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Keeps upstream's query-slot code beside list_execute_indirect; the refuse
path is unchanged upstream (19 refuse sites), so the counters apply as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@R0Y00
R0Y00 merged commit a2010c9 into R0Y00:main Nov 25, 2026
5 checks passed
clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…d, indirect clamp & action_offset

Implements five replay/barrier/indirect improvements on blend/stage2-replay-barriers-indirect:
- Placed/simultaneous-access texture preservation across LAYOUT_UNDEFINED enhanced barriers (DesignWithTommy/i95@08ae3e8, GPL-3.0; ResourceBinding::placed_texture + LEONIDA_PLACED_UNDEFINED=1 opt-out).
- Compute/copy queue graphics-only layout guard in TransitionBarrier, TextureBarrier, and DiscardResource (ThatRecompDev/five-star-recomp@9b0070d, GPL-3.0).
- ExecuteIndirect !cmd.has_draw out-of-renderpass skip + counter (no vkCmdDrawIndirect* outside a Vulkan render pass).
- Backwards-compatible CommandSignature trailing action_offset threaded through command_list.h, d3d12_com.{h,cpp}, and vulkan_replay.h (Marvisak/VIctory#956 GPL-3.0, R0Y00/Xbox2Windows#2091 MIT).
- Non-destructive GPU indirect argument clamping for DISPATCH/DRAW/DRAW_INDEXED/DISPATCH_MESH into submission-local scratch (LEONIDA_INDIRECT_CLAMP=0 kill-switch; ThatRecompDev/five-star-recomp@1936a2b, DesignWithTommy/i95@000516c GPL-3.0) + per-kind/outcome counters (R0Y00/Xbox2Windows#2180 MIT).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants