startup: opt-in snapshot of an untracked indirect argument record #3939

Manually merged
github merged 9 commits from github-bot/gh-3937 into gh-pr/3937/base 2026-12-03 16:09:40 +00:00 AGit
Owner

@⁠triggered02 on GitHub · 2026-12-03 13:49 UTC · original
triggered02:feat/3899b-argument-snapshot → main · +350 −25 · 5 files · 9 commits · merged 2026-12-03 16:01 UTC

Draft — a follow-up to #3937, not for review until that one settles. Both touch list_execute_indirect, and reviewing them side by side is easier than interleaved.

Part of #3901. An ExecuteIndirect whose argument record has no proven desktop resource is refused today with argument has no desktop resource or argument record is outside a unique placed buffer — the two argument refusals of the indirect census. A survey of all 37 indirect_other codes ranked this the cheapest safe extension: only three of them are "a range has no proven desktop resource" shaped, and the count word is deliberately excluded because it is read at execution time.

What it does. X2W_INDIRECT_ARGUMENT_SNAPSHOT=1, off by default and gated on a translated draw exactly like X2W_INDIRECT_INDEX_SNAPSHOT: when the record range (count-1)*indirect_bytes + bytes cannot be proven, it is copied from title memory into the title-input snapshot pool while the draw is recorded and the desktop ExecuteIndirect submits that copy. Above the bound, on unreadable memory, or on a failed copy, the record is still refused with today's message and the cause is logged once.

Why 64 KiB. A translated graphics signature runs one command, so the record is exactly 16 or 20 bytes; 64 KiB matches the index switch's bound, uses the same pool, and is far below the pool's 32 MiB per-reservation cap. The ~1 MiB range a batched rootless Dispatch could present is out of reach by construction, because this switch requires translated and a Dispatch is never translated — that is also the case whose bytes would be execution-time data.

Default behaviour is unchanged. With the switch off the snapshot lambda short-circuits before doing any work, and every refusal is the same call in the same order with the same text and code. The fixture's existing argument_outside_placed_buffer case still expects its refusal.

Record-time semantics, documented: a title that rewrites the record before Submit executes the bytes it had at the recording, and data a GPU pass wrote into such a range (mesh XMem leases exist for that) is not seen.

Verified: d3d12_xs_shim builds with clang-cl + xwin from main 4567a71a (exit 0, [22/22] Linking CXX shared library d3d12_xs.dll), and tests/docs_links_check.py / tests/bidi_controls_check.py pass.

Not verified, stated plainly: no D3D12/WARP fixture run and no title run, so neither the census conversion nor pool behaviour under real submission is measured. The upload-heap argument buffer path (the desktop commands submit the pool copy) is unrun; D3D12 permits it and the copy is only bound through paths that skip barriers on fixed heaps, but that is reasoning, not evidence. Default-behaviour preservation is by inspection of the diff, not by a passing negative control.

One question for review: the shared argument record is outside a unique placed buffer refusal covers both found.reject (range crossing placed buffers) and found.owner != buffer, so both now attempt the snapshot. index_view_overlap was deliberately left untouched because a range that provably straddles placed buffers suggests a tracking inconsistency; if you want the same distinction here, it needs a separate refusal code.

**@⁠triggered02** on GitHub · 2026-12-03 13:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937) `triggered02:feat/3899b-argument-snapshot` → `main` · +350 −25 · 5 files · 9 commits · merged 2026-12-03 16:01 UTC **Draft — a follow-up to #3937, not for review until that one settles.** Both touch `list_execute_indirect`, and reviewing them side by side is easier than interleaved. Part of #3901. An `ExecuteIndirect` whose argument record has no proven desktop resource is refused today with `argument has no desktop resource` or `argument record is outside a unique placed buffer` — the two argument refusals of the indirect census. A survey of all 37 `indirect_other` codes ranked this the cheapest safe extension: only three of them are "a range has no proven desktop resource" shaped, and the count word is deliberately excluded because it is read at execution time. **What it does.** `X2W_INDIRECT_ARGUMENT_SNAPSHOT=1`, off by default and gated on a translated draw exactly like `X2W_INDIRECT_INDEX_SNAPSHOT`: when the record range `(count-1)*indirect_bytes + bytes` cannot be proven, it is copied from title memory into the title-input snapshot pool while the draw is recorded and the desktop `ExecuteIndirect` submits that copy. Above the bound, on unreadable memory, or on a failed copy, the record is still refused with today's message and the cause is logged once. **Why 64 KiB.** A translated graphics signature runs one command, so the record is exactly 16 or 20 bytes; 64 KiB matches the index switch's bound, uses the same pool, and is far below the pool's 32 MiB per-reservation cap. The ~1 MiB range a batched rootless Dispatch could present is out of reach by construction, because this switch requires `translated` and a Dispatch is never translated — that is also the case whose bytes would be execution-time data. **Default behaviour is unchanged.** With the switch off the snapshot lambda short-circuits before doing any work, and every refusal is the same call in the same order with the same text and code. The fixture's existing `argument_outside_placed_buffer` case still expects its refusal. **Record-time semantics, documented:** a title that rewrites the record before `Submit` executes the bytes it had at the recording, and data a GPU pass wrote into such a range (mesh XMem leases exist for that) is not seen. **Verified:** `d3d12_xs_shim` builds with clang-cl + xwin from `main` 4567a71a (exit 0, `[22/22] Linking CXX shared library d3d12_xs.dll`), and `tests/docs_links_check.py` / `tests/bidi_controls_check.py` pass. **Not verified, stated plainly:** no D3D12/WARP fixture run and no title run, so neither the census conversion nor pool behaviour under real submission is measured. The upload-heap argument buffer path (the desktop commands submit the pool copy) is unrun; D3D12 permits it and the copy is only bound through paths that skip barriers on fixed heaps, but that is reasoning, not evidence. Default-behaviour preservation is by inspection of the diff, not by a passing negative control. **One question for review:** the shared `argument record is outside a unique placed buffer` refusal covers both `found.reject` (range crossing placed buffers) and `found.owner != buffer`, so both now attempt the snapshot. `index_view_overlap` was deliberately left untouched because a range that provably straddles placed buffers suggests a tracking inconsistency; if you want the same distinction here, it needs a separate refusal code.
An ExecuteIndirect whose argument record has no proven desktop resource is refused
with 'argument has no desktop resource' or 'argument record is outside a unique
placed buffer'. Those are the two argument refusals of the indirect census (#3899).

This adds X2W_INDIRECT_ARGUMENT_SNAPSHOT, off by default, which copies the record
range from title memory into the title-input snapshot pool while the draw is
recorded (at most 64 KiB) and lets the desktop ExecuteIndirect submit that copy.
Like X2W_INDIRECT_INDEX_SNAPSHOT it requires a translated draw, so a graphics
signature's one record is 16-20 bytes. Above the bound, on unreadable memory, or
when the copy or the address fails, the record is still refused and the cause is
logged once.

Deliberately opt-in: refusing is a documented contract (docs/experiments.md:
readable memory with no registered GPU backing may be stale or unrelated, so
copying it would execute a record the title never uploaded), so the default
behaviour is byte-for-byte unchanged. The switch exists to measure how much of
that census a copy would turn into draws before anyone changes the default.

The copy is taken at record time, not at submit: a title that rewrites the record
before Submit executes the bytes it had at the recording, and data a GPU pass
wrote into such a range (mesh XMem leases exist for that) is not seen. Both are
stated in the documentation added here. The count-buffer path is unchanged,
because its word is read at execution time.

Refs #3899
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 13:55:08 +00:00
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 14:30 UTC · original

Un-drafting: #3937 merged, so this now sits on top of it rather than beside it.

  • Merged current main (adfc0d94, which carries #3937, #3940 and #3938) into this branch with no conflicts — the two changes touch different parts of list_execute_indirect, as intended.
  • Rebuilt after the merge: d3d12_xs_shim links ([12/12] Linking CXX shared library d3d12_xs.dll), no warnings on the changed lines.
  • Diff against main is now only this change: docs/experiments.md +12, src/startup_stubs/d3d12_xs_device.cpp +64/−13.

What still differs from #3937 in evidence quality: #3937 got a fixture and R0Y00 measured it on hardware. This one has no fixture yet — the argument record is a single 16- or 20-byte range rather than a stream of indices, so the natural case is "the record lives where the shim cannot prove a desktop resource", and the wrapper for it does not exist in the current fixture. I would rather say that than dress the build result up as verification.

If you want it merged on the same footing as #3937, the next thing I should add is that fixture case. Say the word and I will write it; otherwise treat this as the measurement switch the issue asked for and I will leave it off by default.

**@⁠triggered02** on GitHub · 2026-12-03 14:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7381562052) Un-drafting: #3937 merged, so this now sits on top of it rather than beside it. - Merged current `main` (`adfc0d94`, which carries #3937, #3940 and #3938) into this branch with no conflicts — the two changes touch different parts of `list_execute_indirect`, as intended. - Rebuilt after the merge: `d3d12_xs_shim` links (`[12/12] Linking CXX shared library d3d12_xs.dll`), no warnings on the changed lines. - Diff against `main` is now only this change: `docs/experiments.md` +12, `src/startup_stubs/d3d12_xs_device.cpp` +64/−13. **What still differs from #3937 in evidence quality:** #3937 got a fixture and R0Y00 measured it on hardware. This one has no fixture yet — the argument record is a single 16- or 20-byte range rather than a stream of indices, so the natural case is "the record lives where the shim cannot prove a desktop resource", and the wrapper for it does not exist in the current fixture. I would rather say that than dress the build result up as verification. If you want it merged on the same footing as #3937, the next thing I should add is that fixture case. Say the word and I will write it; otherwise treat this as the measurement switch the issue asked for and I will leave it off by default.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-03 14:30 UTC · original · edited 2026-12-03 14:36 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T14:36:23.369187Z ce9541a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-03 14:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7381568596) · edited 2026-12-03 14:36 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ce9541add73bfeea7d18536a457ca8cf415b008a","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-12-03T14:36:23.369187Z">2026-12-03T14:36:23.369187Z</relative-time> | `ce9541a` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-03 14:36 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce9541add7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-03 14:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#pullrequestreview-6171867084) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `ce9541add7` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -4989,0 +4993,4 @@
// title that rewrites the record before Submit executes the bytes it had at the recording, and data a GPU
// pass wrote into such a range (mesh XMem leases exist for that) is not seen.
constexpr u64 max_argument_snapshot_bytes = 64 * 1024;
const bool snapshot_opted_in = translated && x2w_local::env_on("X2W_INDIRECT_ARGUMENT_SNAPSHOT");
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-03 14:36 UTC · original

P2 Badge Exercise the opt-in argument snapshot path

When X2W_INDIRECT_ARGUMENT_SNAPSHOT=1, this is the route that copies an unproven argument range for submission, but a repository-wide search finds no fixture that sets this switch; the existing argument_outside_placed_buffer assertion checks only the default refusal, and the commit reports no WARP fixture run. The new copy, offset, and pool-lifetime behavior is therefore unverified; add an opt-in positive fixture with refusal controls and run it.

AGENTS.md reference: AGENTS.md:L343-L351

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-03 14:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#discussion_r4786286594) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Exercise the opt-in argument snapshot path** When `X2W_INDIRECT_ARGUMENT_SNAPSHOT=1`, this is the route that copies an unproven argument range for submission, but a repository-wide search finds no fixture that sets this switch; the existing `argument_outside_placed_buffer` assertion checks only the default refusal, and the commit reports no WARP fixture run. The new copy, offset, and pool-lifetime behavior is therefore unverified; add an opt-in positive fixture with refusal controls and run it. AGENTS.md reference: [AGENTS.md:L343-L351](https://github.com/R0Y00/Xbox2Windows/blob/ce9541add73bfeea7d18536a457ca8cf415b008a/AGENTS.md#L343-L351) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 14:36 UTC · original · requested changes

The runtime change adds a new source of ExecuteIndirect records; this head has no source-built fixture for it. Please extend the existing indirect snapshot fixture to exercise a known readable argument range with no proven desktop backing at a nonzero argument offset. Check that it refuses with the switch unset, draws from the recorded bytes after the guest record changes before Submit when enabled, and still refuses an invalid or unreadable record. The existing index snapshot test cannot prove that the argument upload resource and snapshot offset reach the desktop call.

**@⁠R0Y00** on GitHub · 2026-12-03 14:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#pullrequestreview-6171875272) · **requested changes** The runtime change adds a new source of ExecuteIndirect records; this head has no source-built fixture for it. Please extend the existing indirect snapshot fixture to exercise a known readable argument range with no proven desktop backing at a nonzero argument offset. Check that it refuses with the switch unset, draws from the recorded bytes after the guest record changes before Submit when enabled, and still refuses an invalid or unreadable record. The existing index snapshot test cannot prove that the argument upload resource and snapshot offset reach the desktop call.
New mode translated-argument-snapshot in startup_indirect_draw_indexed, registered through
tests/cmake/startup_indirect_argument_snapshot.cmake for warp and hardware, and selected in the pr
preset as a flat alternative (the filter stays at 30 groups). Five runs in one process:

  * both argument shapes are refused with X2W_INDIRECT_ARGUMENT_SNAPSHOT unset: a record range that
    crosses its own placed buffer, and a record whose wrapper has no desktop object.
  * both shapes draw with the switch on, and the snapshot pool grows by exactly 512 bytes each,
    which no other consumer of that slot can cause: the 20-byte DrawIndexed record rounds to the
    same 512-byte chunk unit as the index views.
  * a decommitted title page keeps the record refused with the switch on, so the readability probe
    is what gates the copy and a page that faults is never copied inside the recording.

The shape without a desktop object is a slot 133 title-memory texture that the final Release leaves
to X2W_D3D12_RELEASE_RETIRED: its drain clears own().real and keeps title_memory, and a buffer
cannot stand in because buffers never leave the desktop. That switch is cached by the shim, so the
whole mode runs with it on; the only wrapper it reaches is the one the fixture releases, and the
fixture fails with a clear message if the drain never claims it, which would make the refused
control take the placement branch instead.

The stale-copy semantics are pinned too: the record bytes are overwritten with 0x4d after recording
and before Submit, so a draw that still paints executed the copy. The refusal census must show two
(key, reason) pairs, two calls on missing_argument_resource (the unset control and the unreadable
one) and one on argument_outside_placed_buffer, so a control that starts failing for a different
reason still fails here.

The 64 KiB snapshot bound has no control: a translated graphics draw records one command, so its
record is 20 bytes, and the shim refuses count > 1 as graphics_multi_command before it reads the
bound.

Refs #3899
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 14:47 UTC · original

Fixture added: this PR now has the same evidence structure as #3937 (which you measured on hardware) instead of a compile-only claim.

New mode translated-argument-snapshot, registered through tests/cmake/startup_indirect_argument_snapshot.cmake for warp and hardware, selected in the pr preset as a flat alternative (the filter stays at 30 parenthesised groups).

Five runs in one process, all in startup_indirect_draw_indexed:

  • a record range crossing its own placed buffer (64-byte buffer, record at offset 48) and a record whose wrapper has no desktop object — both refused with the switch unset;
  • the same two shapes with the switch on — both draw, and the snapshot pool grows by exactly 512 bytes each, which no other consumer of that slot can cause;
  • the missing-resource shape with its title page decommitted — still refused with the switch on, so the readability probe is what gates the copy.

The record-time semantics are pinned the same way as the index fixture: the 20-byte record is written immediately before slot<Execute>(61) and overwritten with 0x4d after recording and before Submit. A draw that still paints therefore executed the copy — a submit-time read would execute IndexCount = 0x4d4d4d4d.

Census names the two codes rather than a key count, in the spirit of your last note: total 3, two rows, 2 calls on missing_argument_resource and 1 on argument_outside_placed_buffer, and any other reason fails. A control that starts failing for a different reason still fails the test.

One case deliberately absent, with the reason in the code: the 64 KiB bound has no control here. span = (count-1)*stride + bytes and a translated graphics draw is forced to count == 1, bytes == 20, so a 20-byte span cannot reach 64 KiB — the shim refuses count > 1 as graphics_multi_command before it ever reads the bound. The decommitted-page control above occupies that slot instead.

Build verified here (not just claimed): cmake --build out/build/clang --target startup_indirect_draw_indexed d3d12_xs_shim -j 8 → both link, .exe 684,032 bytes, d3d12_xs.dll 16,061,440 bytes; ctest -N lists both new registrations.

Still needs Windows: this host has no working D3D12 device, so no case has actually run. The least-certain construction is the retired-title texture that produces the "no desktop resource" wrapper — buffers never lose their desktop object, so a slot-133 texture released under X2W_D3D12_RELEASE_RETIRED is the only reachable shape, and the fixture fails loudly if the retire drain does not claim it. The first ctest --preset pr -R '^startup_indirect_translated_argument_snapshot_warp$' -V on Windows is the real check.

**@⁠triggered02** on GitHub · 2026-12-03 14:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7382029155) Fixture added: this PR now has the same evidence structure as #3937 (which you measured on hardware) instead of a compile-only claim. **New mode `translated-argument-snapshot`**, registered through `tests/cmake/startup_indirect_argument_snapshot.cmake` for `warp` and `hardware`, selected in the `pr` preset as a flat alternative (the filter stays at 30 parenthesised groups). **Five runs in one process**, all in `startup_indirect_draw_indexed`: - a record range crossing its own placed buffer (64-byte buffer, record at offset 48) and a record whose wrapper has no desktop object — both **refused** with the switch unset; - the same two shapes with the switch **on** — both **draw**, and the snapshot pool grows by exactly **512 bytes** each, which no other consumer of that slot can cause; - the missing-resource shape with its title page **decommitted** — still **refused** with the switch on, so the readability probe is what gates the copy. **The record-time semantics are pinned the same way as the index fixture:** the 20-byte record is written immediately before `slot<Execute>(61)` and overwritten with `0x4d` after recording and before `Submit`. A draw that still paints therefore executed the copy — a submit-time read would execute `IndexCount = 0x4d4d4d4d`. **Census** names the two codes rather than a key count, in the spirit of your last note: `total 3`, two rows, **2 calls on `missing_argument_resource`** and **1 on `argument_outside_placed_buffer`**, and any other reason fails. A control that starts failing for a different reason still fails the test. **One case deliberately absent, with the reason in the code:** the 64 KiB bound has no control here. `span = (count-1)*stride + bytes` and a translated graphics draw is forced to `count == 1, bytes == 20`, so a 20-byte span cannot reach 64 KiB — the shim refuses `count > 1` as `graphics_multi_command` before it ever reads the bound. The decommitted-page control above occupies that slot instead. **Build verified here** (not just claimed): `cmake --build out/build/clang --target startup_indirect_draw_indexed d3d12_xs_shim -j 8` → both link, `.exe` 684,032 bytes, `d3d12_xs.dll` 16,061,440 bytes; `ctest -N` lists both new registrations. **Still needs Windows:** this host has no working D3D12 device, so no case has actually run. The least-certain construction is the retired-title texture that produces the "no desktop resource" wrapper — buffers never lose their desktop object, so a slot-133 texture released under `X2W_D3D12_RELEASE_RETIRED` is the only reachable shape, and the fixture fails loudly if the retire drain does not claim it. The first `ctest --preset pr -R '^startup_indirect_translated_argument_snapshot_warp$' -V` on Windows is the real check.
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 14:48 UTC · original

Your review is on ce9541ad; the fixture landed ten minutes later as f57e73d3 (new head). Point by point against what you asked for:

"a known readable argument range with no proven desktop backing at a nonzero argument offset" — the drawing case is a 64-byte placed buffer with the record written at offset 48, so the record range crosses the buffer's own width and the placement index rejects it while its title bytes stay readable (ArgumentSnapshot outside_argument{..., 48}).

"refuses with the switch unset" — two refused controls: that outside-placement shape, and a second shape whose wrapper has no desktop object. Both assert the pool delta is 0, so nothing was copied on the refusal path either.

"draws from the recorded bytes after the guest record changes before Submit" — the 20-byte record is written into title memory immediately before slot<Execute>(61), and after recording and before Close/Submit it is overwritten with 0x4d. A draw that still paints therefore executed the recorded copy: a submit-time read would run IndexCount = 0x4d4d4d4d.

"still refuses an invalid or unreadable record" — the missing-desktop-resource shape's title page is MEM_DECOMMITed and the same draw is attempted with the switch on; it must still be refused (pool delta 0), which pins the readable_window gate as the thing that stops a copy faulting inside the recording.

Your sharpest point — "the existing index snapshot test cannot prove that the argument upload resource and snapshot offset reach the desktop call". Agreed, and this is what the offset-48 case exists for. The runtime passes snapshot_resource ? snapshot_offset : offset (d3d12_xs_device.cpp:5129), so if the desktop call received the original offset against the snapshot resource it would read past the copied 20 bytes into zeros and draw nothing. Painting from that shape is the proof that both the copy resource and the snapshot offset reached the call; the pool delta (+512) separately proves the reservation.

One case I did not add, with the reason in the code: a 64 KiB bound control is unconstructible here. span = (count-1)*stride + bytes, and a translated graphics draw is forced to count == 1, bytes == 20, so a 20-byte span cannot reach the bound — the shim refuses count > 1 earlier as graphics_multi_command.

Still unrun: no D3D12 device on my host, so the Windows job is the first execution. The construction I would look at first if it fails is the retired slot-133 texture that produces the "no desktop resource" wrapper — buffers never lose their desktop object, so that path is the only reachable one, and the fixture fails loudly (retired argument texture kept its desktop object) rather than passing quietly if the retire drain does not claim it.

**@⁠triggered02** on GitHub · 2026-12-03 14:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7382074966) Your review is on `ce9541ad`; the fixture landed ten minutes later as `f57e73d3` (new head). Point by point against what you asked for: **"a known readable argument range with no proven desktop backing at a nonzero argument offset"** — the drawing case is a 64-byte placed buffer with the record written at **offset 48**, so the record range crosses the buffer's own width and the placement index rejects it while its title bytes stay readable (`ArgumentSnapshot outside_argument{..., 48}`). **"refuses with the switch unset"** — two refused controls: that outside-placement shape, and a second shape whose wrapper has no desktop object. Both assert the pool delta is 0, so nothing was copied on the refusal path either. **"draws from the recorded bytes after the guest record changes before Submit"** — the 20-byte record is written into title memory immediately before `slot<Execute>(61)`, and after recording and before `Close`/`Submit` it is overwritten with `0x4d`. A draw that still paints therefore executed the recorded copy: a submit-time read would run `IndexCount = 0x4d4d4d4d`. **"still refuses an invalid or unreadable record"** — the missing-desktop-resource shape's title page is `MEM_DECOMMIT`ed and the same draw is attempted with the switch **on**; it must still be refused (pool delta 0), which pins the `readable_window` gate as the thing that stops a copy faulting inside the recording. **Your sharpest point — "the existing index snapshot test cannot prove that the argument upload resource and snapshot offset reach the desktop call".** Agreed, and this is what the offset-48 case exists for. The runtime passes `snapshot_resource ? snapshot_offset : offset` (`d3d12_xs_device.cpp:5129`), so if the desktop call received the *original* offset against the snapshot resource it would read past the copied 20 bytes into zeros and draw nothing. Painting from that shape is the proof that both the copy resource and the snapshot offset reached the call; the pool delta (+512) separately proves the reservation. **One case I did not add, with the reason in the code:** a 64 KiB bound control is unconstructible here. `span = (count-1)*stride + bytes`, and a translated graphics draw is forced to `count == 1, bytes == 20`, so a 20-byte span cannot reach the bound — the shim refuses `count > 1` earlier as `graphics_multi_command`. **Still unrun:** no D3D12 device on my host, so the Windows job is the first execution. The construction I would look at first if it fails is the retired slot-133 texture that produces the "no desktop resource" wrapper — buffers never lose their desktop object, so that path is the only reachable one, and the fixture fails loudly (`retired argument texture kept its desktop object`) rather than passing quietly if the retire drain does not claim it.
The first Windows run of startup_indirect_translated_argument_snapshot_warp got
the numbers right and my grouping wrong:

  got      'total 3; distinct keys 2, distinct pairs 3' (3 rows, 2 missing-resource, 1 outside-placement)
  expected 'total 3': two missing_argument_resource calls and one argument_outside_placed_buffer call

Same lesson as the index fixture: the pair count is the fixture's own plumbing. What
matters is that the three controls are the only refusals, on the two argument reasons,
in those proportions. Assert that, and leave the row count alone.

Everything else in that run passed: both opt-in shapes drew (4/8 non-clear pixels
each), including the nonzero-offset outside-placement case, both default-off controls
stayed clear with a pool delta of 0, the decommitted-page control kept the record
refused with the switch on, and the retired-title construction did not need its
failure path.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 15:01 UTC · original · requested changes

Re-tested f57e73d3 with MSVC Debug, Windows 11 build 26300, D3D12 debug layer enabled. Both argument positives painted 4/8 pixels on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. The three refusal controls stayed clear, argument guards remained intact, and the previous index snapshot cases passed (2/2).

Both new argument fixtures failed their last census assertion: total 3, two distinct pipeline keys, three distinct reason/key pairs. There were two missing_argument_resource calls and one argument_outside_placed_buffer call, all recognized. The fixture currently requires rows == 2. Please match the intended three reason/key pairs, keeping both reason totals exact as in the current check.

**@⁠R0Y00** on GitHub · 2026-12-03 15:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#pullrequestreview-6172361565) · **requested changes** Re-tested f57e73d3 with MSVC Debug, Windows 11 build 26300, D3D12 debug layer enabled. Both argument positives painted 4/8 pixels on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. The three refusal controls stayed clear, argument guards remained intact, and the previous index snapshot cases passed (2/2). Both new argument fixtures failed their last census assertion: total 3, two distinct pipeline keys, three distinct reason/key pairs. There were two missing_argument_resource calls and one argument_outside_placed_buffer call, all recognized. The fixture currently requires rows == 2. Please match the intended three reason/key pairs, keeping both reason totals exact as in the current check.
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 15:05 UTC · original

First Windows run of the fixture: the runtime change is confirmed, and my assertion was the only failure.

argument outside a unique placed buffer draws from its record-time snapshot: 4/8 non-clear pixels
argument with no desktop resource draws from its record-time snapshot: 4/8 non-clear pixels
unproven argument placement is refused while the snapshot opt-in is unset: 0/8 non-clear pixels
argument with no desktop resource is refused while the snapshot opt-in is unset: 0/8 non-clear pixels
unreadable argument title memory is refused: 0/8 non-clear pixels
x2w-render indirect argument snapshot refused: 20 bytes at 0x1fe66f20000 (title memory not readable)

That covers the substance of your review on hardware:

  • the nonzero-offset shape (record at offset 48 inside a 64-byte placed buffer) draws through the copy, which is the offset-propagation proof you asked about — the original offset against the snapshot resource would have read zeros;
  • both positives paint after the record is overwritten with 0x4d before Submit;
  • the switch-off controls and the decommitted-page control all stay clear with a pool delta of 0;
  • the retired slot-133 texture construction worked — no retired argument texture kept its desktop object.

What failed was my census grouping:

got      'total 3; distinct keys 2, distinct pairs 3' (3 rows, 2 missing-resource, 1 outside-placement)
expected 'total 3': two missing_argument_resource calls and one argument_outside_placed_buffer call

The totals and the reason proportions were exactly right; only the row count differed, because the three controls span two pipeline keys and one of them splits into a separate pair. That is the fixture's plumbing, not the behaviour — the same correction you made on #3937, and I should have applied it here the first time. Fixed in c706e565: assert total 3 with 2 missing_argument_resource and 1 argument_outside_placed_buffer, and any unknown reason still fails.

Rebuilt after the fix (startup_indirect_draw_indexed links); the re-run is the check.

**@⁠triggered02** on GitHub · 2026-12-03 15:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7382541708) First Windows run of the fixture: **the runtime change is confirmed, and my assertion was the only failure.** ``` argument outside a unique placed buffer draws from its record-time snapshot: 4/8 non-clear pixels argument with no desktop resource draws from its record-time snapshot: 4/8 non-clear pixels unproven argument placement is refused while the snapshot opt-in is unset: 0/8 non-clear pixels argument with no desktop resource is refused while the snapshot opt-in is unset: 0/8 non-clear pixels unreadable argument title memory is refused: 0/8 non-clear pixels x2w-render indirect argument snapshot refused: 20 bytes at 0x1fe66f20000 (title memory not readable) ``` That covers the substance of your review on hardware: - the **nonzero-offset** shape (record at offset 48 inside a 64-byte placed buffer) **draws through the copy**, which is the offset-propagation proof you asked about — the original offset against the snapshot resource would have read zeros; - both positives paint **after** the record is overwritten with `0x4d` before `Submit`; - the switch-off controls and the decommitted-page control all stay clear with a pool delta of 0; - the retired slot-133 texture construction worked — no `retired argument texture kept its desktop object`. **What failed** was my census grouping: ``` got 'total 3; distinct keys 2, distinct pairs 3' (3 rows, 2 missing-resource, 1 outside-placement) expected 'total 3': two missing_argument_resource calls and one argument_outside_placed_buffer call ``` The totals and the reason proportions were exactly right; only the row count differed, because the three controls span two pipeline keys and one of them splits into a separate pair. That is the fixture's plumbing, not the behaviour — the same correction you made on #3937, and I should have applied it here the first time. Fixed in `c706e565`: assert `total 3` with 2 `missing_argument_resource` and 1 `argument_outside_placed_buffer`, and any unknown reason still fails. Rebuilt after the fix (`startup_indirect_draw_indexed` links); the re-run is the check.
# Conflicts:
#	CMakePresets.json
The previous merge left the filter unbalanced (30 opening and 29 closing
parentheses): I appended a case to a file whose conflict markers had already
changed the shape, and pushed it without compiling it. CTest would refuse the
whole filter with 'Too many parentheses' and report no tests, which is the exact
failure the runbook documents and the one this branch's first Windows run would
have hit for a reason unrelated to the fixture.

Rebuilt from main's working filter (30/30, which runs green in CI) and verified
the result compiles and matches both snapshot cases before pushing this time.
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 15:18 UTC · original

A correction on this PR between the two commits I just pushed: my merge resolution left the pr test filter unbalanced (30 opening, 29 closing parentheses) and I pushed it without compiling it, which would have failed the Windows job with RegularExpression::compile(): Too many parentheses and "No tests were found" — the exact failure documented for this filter, and for a reason unrelated to the fixture.

Rebuilt from main's working copy in 99e32792 and this time verified the result compiles and matches both snapshot cases before pushing.

The fix for the census assertion (c706e565) is unchanged and unaffected.

**@⁠triggered02** on GitHub · 2026-12-03 15:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7382930392) A correction on this PR between the two commits I just pushed: my merge resolution left the `pr` test filter **unbalanced** (30 opening, 29 closing parentheses) and I pushed it without compiling it, which would have failed the Windows job with `RegularExpression::compile(): Too many parentheses` and "No tests were found" — the exact failure documented for this filter, and for a reason unrelated to the fixture. Rebuilt from `main`'s working copy in `99e32792` and this time verified the result compiles and matches both snapshot cases before pushing. The fix for the census assertion (`c706e565`) is unchanged and unaffected.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 15:27 UTC · original

99e32792 passed the argument and index snapshot fixtures on WARP and RTX (4/4). The revised argument census now accepts the three reason/key pairs while keeping the two missing-resource calls and one outside-placement call exact. The PR preset retains both snapshot tests and the draw report.

Main moved to cdf80d52 after #3805. The remaining conflict is in startup_indirect_draw_indexed.cpp: keep both the cached_root_srv/direct DispatchMesh fixture path and the argument_snapshot parameter, dispatch offset and pool check. Please rerun both snapshot classes and startup_mesh86_psless_warp on the combined head.

**@⁠R0Y00** on GitHub · 2026-12-03 15:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7383172175) 99e32792 passed the argument and index snapshot fixtures on WARP and RTX (4/4). The revised argument census now accepts the three reason/key pairs while keeping the two missing-resource calls and one outside-placement call exact. The PR preset retains both snapshot tests and the draw report. Main moved to cdf80d52 after #3805. The remaining conflict is in startup_indirect_draw_indexed.cpp: keep both the cached_root_srv/direct DispatchMesh fixture path and the argument_snapshot parameter, dispatch offset and pool check. Please rerun both snapshot classes and startup_mesh86_psless_warp on the combined head.
# Conflicts:
#	CMakePresets.json
#	tests/startup_indirect_draw_indexed.cpp
Sample the indirect-other census after each argument snapshot control and
require exactly one new row on the reason that shape names, keeping the
end-of-process totals. Add the non-indexed translated Draw case, which
copies a 16-byte D3D12_DRAW_ARGUMENTS record and re-executes the title's
DRAW signature against the copy. Read the argument snapshot switch inside
the refusal branch so ExecuteIndirect's common path pays no environment
read, and correct the experiment note: buffers never lose their desktop
object, the 64 KiB bound is unreachable for this switch, and the covering
command is listed with the remaining hypothesis.
He re-tested f57e73d3 on WARP 10.0.26100.9818 and an RTX 4060 Laptop with the
debug layer on: both argument positives painted 4/8, all three refusal controls
stayed clear, the index cases passed, and the only failure was the census
assertion asking for two rows where the run records three (key, reason) pairs
over two pipeline keys - 2 missing_argument_resource, 1
argument_outside_placed_buffer, all recognised.

The end-of-process check now requires exactly three pairs and keeps both reason
totals exact, which is stricter than the 'at least two rows' I put there: a
control that drifts onto another key, or a reason that swaps shape, still fails.

Refs #3899
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 15:38 UTC · original

All four review findings addressed in 553acb10 (on top of a merge with current main in 8c54bd2b).

1. Census attribution (the one that mattered). The check summed per-reason calls once at the end, so the outside-placement and missing-resource controls could have swapped reasons and still passed. Each of the three refusal runs now samples x2w_d3d12_census_report immediately after, and requires exactly one new row on that shape's reason; the end-of-process totals assertion is kept, so an unexpected extra refusal still fails.

2. Non-indexed translated draw — now covered. It was reachable and untested: a DRAW command also satisfies translated, so the switch copies a 16-byte D3D12_DRAW_ARGUMENTS and draw_translated_indirect takes its non-indexed route. Added as a real case using the existing non-indexed translated pipeline and a real D3D12_INDIRECT_ARGUMENT_TYPE_DRAW signature: the 52+16-byte record crosses a 64-byte placed buffer, the copy is taken, the title bytes are corrupted before Submit, and the draw still paints with the pool growing by 512 bytes.

3. Hot path. The switch was read on every ExecuteIndirect; it is now read inside the refusal branch only. static const would have broken the fixture (which flips the variable between runs in one process — env_on reads the environment per call), so it is a per-call read in the rare path instead, with a comment saying why.

4. Docs. The reachable "no desktop object" wrapper is now named correctly (a slot-133 title-memory texture under X2W_D3D12_RELEASE_RETIRED; buffers never lose theirs), the 64 KiB bound is stated as unreachable by construction for a 16–20-byte record, and the paragraph now carries the covering ctest command plus the sentence that no run with the switches on is reported yet.

Merged main (d5271c96) — the conflict in startup_indirect_draw_indexed.cpp was real (main's slot-57/PS-less work landed in the same function) and is resolved keeping both sides; the pr filter was rebuilt from main's file and verified: compiles, 31/31 parens, selects 55 of 1279 tests, adds only the argument-snapshot case and loses none.

Build passes (startup_indirect_draw_indexed and d3d12_xs_shim). Still unrun — no D3D12 on this host, so the Windows job is the first execution, including the new non-indexed case.

**@⁠triggered02** on GitHub · 2026-12-03 15:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7383476966) All four review findings addressed in `553acb10` (on top of a merge with current `main` in `8c54bd2b`). **1. Census attribution (the one that mattered).** The check summed per-reason calls once at the end, so the outside-placement and missing-resource controls could have swapped reasons and still passed. Each of the three refusal runs now samples `x2w_d3d12_census_report` immediately after, and requires exactly one new row on **that shape's** reason; the end-of-process totals assertion is kept, so an unexpected extra refusal still fails. **2. Non-indexed translated draw — now covered.** It was reachable and untested: a `DRAW` command also satisfies `translated`, so the switch copies a 16-byte `D3D12_DRAW_ARGUMENTS` and `draw_translated_indirect` takes its non-indexed route. Added as a real case using the existing non-indexed translated pipeline and a real `D3D12_INDIRECT_ARGUMENT_TYPE_DRAW` signature: the 52+16-byte record crosses a 64-byte placed buffer, the copy is taken, the title bytes are corrupted before `Submit`, and the draw still paints with the pool growing by 512 bytes. **3. Hot path.** The switch was read on every `ExecuteIndirect`; it is now read inside the refusal branch only. `static const` would have broken the fixture (which flips the variable between runs in one process — `env_on` reads the environment per call), so it is a per-call read in the rare path instead, with a comment saying why. **4. Docs.** The reachable "no desktop object" wrapper is now named correctly (a slot-133 title-memory texture under `X2W_D3D12_RELEASE_RETIRED`; buffers never lose theirs), the 64 KiB bound is stated as unreachable by construction for a 16–20-byte record, and the paragraph now carries the covering `ctest` command plus the sentence that no run with the switches on is reported yet. Merged `main` (`d5271c96`) — the conflict in `startup_indirect_draw_indexed.cpp` was real (main's slot-57/PS-less work landed in the same function) and is resolved keeping both sides; the `pr` filter was rebuilt from main's file and verified: compiles, 31/31 parens, selects 55 of 1279 tests, adds only the argument-snapshot case and loses none. Build passes (`startup_indirect_draw_indexed` and `d3d12_xs_shim`). Still unrun — no D3D12 on this host, so the Windows job is the first execution, including the new non-indexed case.
Author
Owner

@⁠triggered02 on GitHub · 2026-12-03 15:39 UTC · original

Done in fc40e854 — and thank you for re-testing, that report answered something I could not have worked out from here.

Your measurement is now the assertion: exactly three (key, reason) pairs over the run, with both reason totals kept exact —

const bool shape_ok = census.rows == 3 && census.missing_calls == 2 && census.outside_calls == 1;

That is stricter than the rows >= 2 I had put there after the first Windows failure, and stricter in the way you asked: a control that drifts onto another pipeline key, or two controls swapping reasons, now fails rather than passing on the totals alone.

Worth noting what else the same commit carries, since it landed after your review head (f57e73d3):

  • per-run attribution — each of the three refusal controls now samples the census immediately after its run and must add exactly one row on that shape's reason. The totals can no longer be satisfied by two controls that swapped;
  • the non-indexed translated Draw route is covered now (a 16-byte D3D12_DRAW_ARGUMENTS, copy taken, title bytes corrupted before Submit, draw still paints);
  • the switch read moved off the unconditional ExecuteIndirect path;
  • three doc corrections, including that the reachable "no desktop object" wrapper is a released slot-133 title-memory texture, and that the 64 KiB bound is unreachable for a 16–20-byte record.

Your two runs now cover what I could not: WARP and an RTX 4060 Laptop, both positives painting 4/8, index cases 2/2. The remaining unverified piece is only the new non-indexed case, which no run has exercised yet.

**@⁠triggered02** on GitHub · 2026-12-03 15:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#issuecomment-7383511219) Done in `fc40e854` — and thank you for re-testing, that report answered something I could not have worked out from here. Your measurement is now the assertion: **exactly three (key, reason) pairs** over the run, with both reason totals kept exact — ```cpp const bool shape_ok = census.rows == 3 && census.missing_calls == 2 && census.outside_calls == 1; ``` That is stricter than the `rows >= 2` I had put there after the first Windows failure, and stricter in the way you asked: a control that drifts onto another pipeline key, or two controls swapping reasons, now fails rather than passing on the totals alone. Worth noting what else the same commit carries, since it landed after your review head (`f57e73d3`): - **per-run attribution** — each of the three refusal controls now samples the census immediately after its run and must add exactly one row on **that shape's** reason. The totals can no longer be satisfied by two controls that swapped; - the **non-indexed translated `Draw`** route is covered now (a 16-byte `D3D12_DRAW_ARGUMENTS`, copy taken, title bytes corrupted before `Submit`, draw still paints); - the switch read moved off the unconditional `ExecuteIndirect` path; - three doc corrections, including that the reachable "no desktop object" wrapper is a released slot-133 title-memory texture, and that the 64 KiB bound is unreachable for a 16–20-byte record. Your two runs now cover what I could not: WARP **and** an RTX 4060 Laptop, both positives painting 4/8, index cases 2/2. The remaining unverified piece is only the new non-indexed case, which no run has exercised yet.
github-bot changed target branch from main to gh-pr/3937/base 2026-12-03 16:09:25 +00:00
github manually merged commit fc40e85400 into gh-pr/3937/base 2026-12-03 16:09:40 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 16:01 UTC · original · approved these changes

Re-reviewed fc40e854 against main. This now covers the previously missing opt-in path and retains the Mesh86 direct path in the merged fixture. On Windows 11 build 26300, I rebuilt startup_indirect_draw_indexed with MSVC Debug and ran ctest --preset dev --no-tests=error -j 1 -V -R '^startup_indirect_translated_(argument|indexed)snapshot(warp|hardware)$' (4/4, no skips). WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 both ran with the debug layer enabled. The two indexed argument positives paint 4/8, the non-indexed positive paints 8/8, and the default-off and unreadable controls stay at 0/8 with guards intact. Each refusal checks its own reason delta and the final census asserts the three distinct reason/key pairs. Both prior index snapshot tests still pass. The required Windows check is green and the current main merge tree is clean.

**@⁠R0Y00** on GitHub · 2026-12-03 16:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3937#pullrequestreview-6173437783) · **approved these changes** Re-reviewed fc40e854 against main. This now covers the previously missing opt-in path and retains the Mesh86 direct path in the merged fixture. On Windows 11 build 26300, I rebuilt startup_indirect_draw_indexed with MSVC Debug and ran ctest --preset dev --no-tests=error -j 1 -V -R '^startup_indirect_translated_(argument|indexed)_snapshot_(warp|hardware)$' (4/4, no skips). WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 both ran with the debug layer enabled. The two indexed argument positives paint 4/8, the non-indexed positive paints 8/8, and the default-off and unreadable controls stay at 0/8 with guards intact. Each refusal checks its own reason delta and the final census asserts the three distinct reason/key pairs. Both prior index snapshot tests still pass. The required Windows check is green and the current main merge tree is clean.
This discussion has been locked. Commenting is limited to contributors.
No description provided.