startup: opt-in snapshot of an untracked indirect argument record #3937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3937"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T13:49:44Z.
Draft — a follow-up to #3935, not for review until that one settles. Both touch
list_execute_indirect, and reviewing them side by side is easier than interleaved.Part of #3899. An
ExecuteIndirectwhose argument record has no proven desktop resource is refused today withargument has no desktop resourceorargument record is outside a unique placed buffer— the two argument refusals of the indirect census. A survey of all 37indirect_othercodes 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 likeX2W_INDIRECT_INDEX_SNAPSHOT: when the record range(count-1)*indirect_bytes + bytescannot be proven, it is copied from title memory into the title-input snapshot pool while the draw is recorded and the desktopExecuteIndirectsubmits 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
translatedand 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_buffercase still expects its refusal.Record-time semantics, documented: a title that rewrites the record before
Submitexecutes 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_shimbuilds with clang-cl + xwin frommain4567a71a(exit 0,[22/22] Linking CXX shared library d3d12_xs.dll), andtests/docs_links_check.py/tests/bidi_controls_check.pypass.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 bufferrefusal covers bothfound.reject(range crossing placed buffers) andfound.owner != buffer, so both now attempt the snapshot.index_view_overlapwas 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.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T14:30:31Z.
Un-drafting: #3935 merged, so this now sits on top of it rather than beside it.
main(adfc0d94, which carries #3935, #3938 and #3936) into this branch with no conflicts — the two changes touch different parts oflist_execute_indirect, as intended.d3d12_xs_shimlinks ([12/12] Linking CXX shared library d3d12_xs.dll), no warnings on the changed lines.mainis now only this change:docs/experiments.md+12,src/startup_stubs/d3d12_xs_device.cpp+64/−13.What still differs from #3935 in evidence quality: #3935 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 #3935, 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T14:30:46Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ce9541aℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T14:36:19Z.
Code review location:
src/startup_stubs/d3d12_xs_device.cpp; line 4996When
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 existingargument_outside_placed_bufferassertion 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 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T14:36:19Z.
Review: COMMENTED
💡 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
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".
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T14:36:48Z.
Review: CHANGES_REQUESTED
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.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T14:47:11Z.
Fixture added: this PR now has the same evidence structure as #3935 (which you measured on hardware) instead of a compile-only claim.
New mode
translated-argument-snapshot, registered throughtests/cmake/startup_indirect_argument_snapshot.cmakeforwarpandhardware, selected in theprpreset as a flat alternative (the filter stays at 30 parenthesised groups).Five runs in one process, all in
startup_indirect_draw_indexed: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 with0x4dafter recording and beforeSubmit. A draw that still paints therefore executed the copy — a submit-time read would executeIndexCount = 0x4d4d4d4d.Census names the two codes rather than a key count, in the spirit of your last note:
total 3, two rows, 2 calls onmissing_argument_resourceand 1 onargument_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 + bytesand a translated graphics draw is forced tocount == 1, bytes == 20, so a 20-byte span cannot reach 64 KiB — the shim refusescount > 1asgraphics_multi_commandbefore 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,.exe684,032 bytes,d3d12_xs.dll16,061,440 bytes;ctest -Nlists 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_RETIREDis the only reachable shape, and the fixture fails loudly if the retire drain does not claim it. The firstctest --preset pr -R '^startup_indirect_translated_argument_snapshot_warp$' -Von Windows is the real check.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T14:48:47Z.
Your review is on
ce9541ad; the fixture landed ten minutes later asf57e73d3(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 beforeClose/Submitit is overwritten with0x4d. A draw that still paints therefore executed the recorded copy: a submit-time read would runIndexCount = 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 thereadable_windowgate 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 tocount == 1, bytes == 20, so a 20-byte span cannot reach the bound — the shim refusescount > 1earlier asgraphics_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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T15:01:51Z.
Review: CHANGES_REQUESTED
Re-tested
f57e73d3with 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.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T15:05:20Z.
First Windows run of the fixture: the runtime change is confirmed, and my assertion was the only failure.
That covers the substance of your review on hardware:
0x4dbeforeSubmit;retired argument texture kept its desktop object.What failed was my census grouping:
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 #3935, and I should have applied it here the first time. Fixed in
c706e565: asserttotal 3with 2missing_argument_resourceand 1argument_outside_placed_buffer, and any unknown reason still fails.Rebuilt after the fix (
startup_indirect_draw_indexedlinks); the re-run is the check.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T15:18:53Z.
A correction on this PR between the two commits I just pushed: my merge resolution left the
prtest filter unbalanced (30 opening, 29 closing parentheses) and I pushed it without compiling it, which would have failed the Windows job withRegularExpression::compile(): Too many parenthesesand "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 in99e32792and this time verified the result compiles and matches both snapshot cases before pushing.The fix for the census assertion (
c706e565) is unchanged and unaffected.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T15:27:24Z.
99e32792passed 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
cdf80d52after #3803. 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.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T15:38:09Z.
All four review findings addressed in
553acb10(on top of a merge with currentmainin8c54bd2b).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_reportimmediately 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
DRAWcommand also satisfiestranslated, so the switch copies a 16-byteD3D12_DRAW_ARGUMENTSanddraw_translated_indirecttakes its non-indexed route. Added as a real case using the existing non-indexed translated pipeline and a realD3D12_INDIRECT_ARGUMENT_TYPE_DRAWsignature: the 52+16-byte record crosses a 64-byte placed buffer, the copy is taken, the title bytes are corrupted beforeSubmit, 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 constwould have broken the fixture (which flips the variable between runs in one process —env_onreads 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 coveringctestcommand plus the sentence that no run with the switches on is reported yet.Merged
main(d5271c96) — the conflict instartup_indirect_draw_indexed.cppwas real (main's slot-57/PS-less work landed in the same function) and is resolved keeping both sides; theprfilter 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_indexedandd3d12_xs_shim). Still unrun — no D3D12 on this host, so the Windows job is the first execution, including the new non-indexed case.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T15:39:23Z.
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 —
That is stricter than the
rows >= 2I 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):Drawroute is covered now (a 16-byteD3D12_DRAW_ARGUMENTS, copy taken, title bytes corrupted beforeSubmit, draw still paints);ExecuteIndirectpath;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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T16:01:22Z.
Review: APPROVED
Re-reviewed
fc40e854against 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.