Repository navigation
startup: defer heap-indexed root signatures and refuse real draws under them - #1732
Merged
Merged
Conversation
…er them
Device slot 16 records whether a title root signature indexes the
CBV/SRV/UAV heap (0x400) or the sampler heap (0x800) directly. Command-list
slot 34 keeps tracking the title's parameters for every root signature but
no longer sets a flagged one on the desktop list, where the title's heaps
are never bound (debug layer message ID 1419). Unflagged roots keep the
immediate bind. Root SRVs (slot 44) are not forwarded under a deferred root.
A real draw under a deferred root is decided by heap_indexed_root.h: it
binds only when the list mirrors every indexed heap at the indices the draw
reads and all root state can be restored. The stand-in has neither, so the
draw is refused with a specific reason, counted and logged.
Tests: startup_heap_indexed_root (device-free decision matrix, two mutated
controls) and startup_root_heap_{warp,hardware} (root CBV draw with the
debug layer on, each flag alone, both and none, with a plain-list
fail-first control that must report 1419).
Refs R0Y00#870
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
@tedin7 this is the single implementation from #870 that replaces #1685; your message-callback counter and plain-list control are in AI-assisted. |
tedin7
reviewed
Nov 24, 2026
tedin7
left a comment
Collaborator
There was a problem hiding this comment.
Review of PR #1732 (0ceece32c0db5aa961bcdb1727ad39b470a0376c).
Findings
No blocking issues found.
- Note (environment / coverage): On the Windows Server 2025 WARP VM,
startup_root_heap_warpcapability-skipped (exit 77, debug layer unavailable), so the live debug-layer ID-1419 suppression check instartup_root_heap_{warp,hardware}was not exercised on that node. All other targeted tests—includingstartup_heap_indexed_root, bothWILL_FAILnegative controls,startup_root_cbv_warp,startup_stream_*, andstartup_stubs—passed in both Debug and Release/O2.
What looks good
- Heap-indexed root deferral (
src/startup_stubs/d3d12_xs_device.cpp):- Device slot 16 (
device_create_root_signature) extractsD3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED(0x400) andSAMPLER_HEAP_DIRECTLY_INDEXED(0x800) intoroot_heap_flag_map(). - Command-list slot 34 (
list_graphics_root) keeps trackingpass.rootandpass.root_addressfor all root signatures, binds unflagged ones immediately on the desktop list, and defers flagged ones (pass.root_heap_flags,pass.deferred_root, logged first 3, counted inheap_roots_deferred), clearingpass.root_heap_flags/pass.deferred_rootwhen a null or non-root-signature is passed. - Slot 44 (
list_root_srv) avoids forwarding root SRVs to the desktop list under a deferred root while still recordingpass.root_address.
- Device slot 16 (
- Safe refusal of real draws (
src/startup_stubs/heap_indexed_root.h,list_draw):- Translated draws (
!pass.pipeline_real) run before the deferred-root check and continue using their own unflagged root signature.list_draw_indexedinsrc/startup_stubs/d3d12_draw.inlonly dispatchesdraw_translatedand has no real-draw branch. - Real draws in
list_drawunderpass.root_heap_flagsconsultx2w_startup::decide_real_rootwith absent mirrored heaps andstate_restorable = false, returning safely without drawing or touching uninitialized handles, while updatingheap_root_refusals[decision],render_draws_skipped, andx2w-render totals. heap_coversanddecide_real_rootcheckheap.boundand(heap.whole || (highest != unknown_heap_index && highest < heap.entries)), keep view and sampler heap requirements independent, and checkstate_restorableafter heap coverage.
- Translated draws (
- Coverage separation & title-neutrality:
- Real-draw decision coverage (
startup_heap_indexed_root+ twoWILL_FAILcontrols) and translated GPU readback (startup_root_heap_{warp,hardware}) are reported separately, with the unreachedlist_drawreal-draw branch explicitly noted under "Not covered". - Diff and docs are 100% title-neutral.
- Real-draw decision coverage (
Checks & verification
python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py prep-verify 1732 --dir /tmp/rev-x2w-83/1732 --json:git_diff_check,docs_links_check,bidi_controls_check,py_compile(1 file) all passed.- Win2025 (
x2w_pipe.py win2025 1732 --targets cpu_shim_startup,cpu_shim_startup_guest,cpu_shim_startup_lifted,d3d12_xs_shim,startup_heap_indexed_root_check,startup_stream_consumer,startup_stream_depth,startup_stub_consumer --regex '^(startup_heap_indexed_root|startup_heap_indexed_root_bind-unrestorable_control|startup_heap_indexed_root_sampler-alone_control|startup_root_heap_warp|startup_root_cbv_warp|startup_stream_draw_warp|startup_stream_depth_warp|startup_stream_request_warp|startup_stream_viewport_warp|startup_stubs)$'):- Debug (
--preset dev): build21.77s, 9/10 passed (4.72s),startup_root_heap_warpskipped (exit 77). - Release
/O2(--preset release): build38.85s, 9/10 passed (4.88s),startup_root_heap_warpskipped (exit 77).
- Debug (
- Win2025
--patchmutation (heap_coversinsrc/startup_stubs/heap_indexed_root.hmutated toreturn heap.bound;):x2w_pipe.py win2025 1732 --patch ... --skip-release --targets startup_heap_indexed_root_check --regex '^(startup_heap_indexed_root|startup_heap_indexed_root_bind-unrestorable_control|startup_heap_indexed_root_sampler-alone_control)$':startup_heap_indexed_rootfailed as expected (2332 of 3222 heap-indexed root decisions as expected, exit code 1).
AI-assisted; commands listed were executed locally.
This was referenced Nov 24, 2026
rasptum
added a commit
to rasptum/Xbox2Windows
that referenced
this pull request
Nov 24, 2026
After merging main with R0Y00#1732, device slot 16 records each root signature's heap-indexing flags for command-list slot 34, which defers a flagged root instead of setting it on the desktop list. It reads those flags from the blob passed to CreateRootSignature through the desktop deserializer. note_root_blob restores the bits only in its separate translation copy. So after a Windows 10 retry, slot 34 sees 0 and sets the root directly, while translation (the .root request, its key, and the manifest that create_translated_root consumes) keeps the restored bits. That is the right split on a runtime that refuses 0xC00: the desktop root signature really has no indexed heaps, so the debug-layer rejection R0Y00#1732 avoids cannot happen, and real draws under it are not heap-indexed. No code change was needed to reconcile the two. Test: d3d12_xs_shim_heap_indexing's provenance control now also checks, for baseline, 0x400-only, 0x800-only and 0xC00 in both orders and for a byte copy, that the flags slot 34 acts on are 0. The fixture export x2w_d3d12_root_translation_blob reports them alongside the translation copy. Mutant: OR-ing the restored bits into slot 34's flags fails 6 of the 8 provenance cases (all flagged inputs). Review nits (tedin7, c31afac): - RetriedBlob::wrap allocates with nothrow and registers inside try/catch; if either fails the caller gets the desktop blob unwrapped (no bits), so nothing leaks and no exception crosses the export. - x2w_stripped_root_flags logs once when a blob misses the pointer lookup but has the bytes of a live retried blob: either a copy (bits not restored) or a call without the bits; the bytes cannot say which, so the answer stays 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R0Y00
added a commit
that referenced
this pull request
Nov 25, 2026
…Windows 10 (#1277) * startup: keep the title's heap-indexing root flags for shader translation on Windows 10 The executable's root signatures set CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED and SAMPLER_HEAP_DIRECTLY_INDEXED (0xC00). The in-box Windows 10 D3D12 runtime predates shader model 6.6 and answers E_INVALIDARG. The executable does not check the result, so its pipeline object stays null and a startup run stops at about 75 s on a read through it (#1160). With X2W_D3D12_PERMISSIVE=1, d3d12_xs_SerializeVersionedRootSignature now repeats a refused serialization without those two bits and remembers, by blob content, which bits it removed (exported as x2w_stripped_root_flags). The recording device restores them in the copy of the blob it keeps for shader translation. The title's shaders take the heap pointers in the user SGPRs those flags add; without them gfx2hlsl lays the registers out one short ("s_load through s10 holding None") and the UI glyph pipelines are never translated. The desktop root signature itself still lacks the bits, so a shader that really indexes the heaps still needs shader model 6.6. Test: d3d12_xs_shim_heap_indexing. - Switch off: the shim answers E_INVALIDARG like the desktop runtime (negative control). - Switch on: the retried blob is byte-identical to the desktop serialization without the bits, alone and with the console bits 0x03000000, and the caller's descriptor is unchanged. - x2w_stripped_root_flags reports 0xC00 for that blob and 0 for a blob with other content and for null. - Unobserved invalid bits next to 0xC00 stay refused. - A runtime that accepts the flags makes the retry unreachable: the test then checks pass-through and returns 77 (skip). Mutants: no retry, and retry without recording, each fail it. Measured on Windows 10 19045, RTX 3060: the startup run continues past the 75 s stop, and the four glyph pipelines translate once 0x800 is restored. Fixes #1160 (the Windows 10 cause). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * startup: tie stripped heap-indexing root flags to the blob the retry returned Review of #1277: the bytes of a blob serialized without the heap-indexing bits do not identify the input. The legal baseline without them, an input with only 0x400, one with only 0x800 and one with both serialize to the same bytes, so the content-keyed lookup gave a baseline blob the bits of another call and could not tell the two single-flag inputs apart. Design: of the two options in the review, this keeps an explicitly identifiable representation, because the recording device only ever sees (pointer, size) at CreateRootSignature and cannot be handed the original descriptor. After a retry, d3d12_xs_SerializeVersionedRootSignature returns its own ID3DBlob around the desktop blob. That object registers its buffer with the removed bits while it lives and unregisters it in its destructor, before releasing the desktop blob, so the address cannot be reused while a record for it exists. x2w_stripped_root_flags answers only for that exact buffer and size. A blob from any other call, or a copy of the bytes in other memory, reports 0: the translation copy then keeps the desktop flags instead of guessing. Nothing changes with X2W_D3D12_PERMISSIVE unset or on a runtime that accepts the flags (no retry, no wrapper). The recording device declares x2w_stripped_root_flags with a linker fallback that returns 0, so offscreen_check, which compiles d3d12_xs_device.cpp without the shim, links again on current main. A fixture export, x2w_d3d12_root_translation_blob, returns the copy the recording device keeps for translation (the .root request and the translation key). Test: d3d12_xs_shim_heap_indexing gains a provenance control. With the switch on, the baseline, 0x400-only, 0x800-only and 0xC00 inputs are serialized and held alive together, in both call orders (baseline first, both first). Each blob is byte-identical to the others, goes through the recording device's CreateRootSignature (slot 16) on WARP, and the RTS0 flags of the translation copy, parsed by the test, must be the base flags plus exactly that call's bits; the lookup must agree. A copy of the 0xC00 blob in test memory must give the base flags only. Existing controls are unchanged: switch off refuses, retried bytes equal the desktop serialization, unrelated blob and null record nothing, unobserved invalid bits stay refused, and a runtime with shader model 6.6 skips (77). Mutant: the previous content-keyed shim fails the provenance control. Merged origin/main (d90dd76) first; it merged without conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * startup: pin stripped root flags against the deferred heap-indexed roots After merging main with #1732, device slot 16 records each root signature's heap-indexing flags for command-list slot 34, which defers a flagged root instead of setting it on the desktop list. It reads those flags from the blob passed to CreateRootSignature through the desktop deserializer. note_root_blob restores the bits only in its separate translation copy. So after a Windows 10 retry, slot 34 sees 0 and sets the root directly, while translation (the .root request, its key, and the manifest that create_translated_root consumes) keeps the restored bits. That is the right split on a runtime that refuses 0xC00: the desktop root signature really has no indexed heaps, so the debug-layer rejection #1732 avoids cannot happen, and real draws under it are not heap-indexed. No code change was needed to reconcile the two. Test: d3d12_xs_shim_heap_indexing's provenance control now also checks, for baseline, 0x400-only, 0x800-only and 0xC00 in both orders and for a byte copy, that the flags slot 34 acts on are 0. The fixture export x2w_d3d12_root_translation_blob reports them alongside the translation copy. Mutant: OR-ing the restored bits into slot 34's flags fails 6 of the 8 provenance cases (all flagged inputs). Review nits (tedin7, c31afac): - RetriedBlob::wrap allocates with nothrow and registers inside try/catch; if either fails the caller gets the desktop blob unwrapped (no bits), so nothing leaks and no exception crosses the export. - x2w_stripped_root_flags logs once when a blob misses the pointer lookup but has the bytes of a live retried blob: either a copy (bits not restored) or a call without the bits; the bytes cannot say which, so the answer stays 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * startup: stop the copied-blob scan once its line is logged; say when the retry runs x2w_stripped_root_flags compared every registered blob's bytes on a miss only to print a once-only line; the comparison now stops after a match and is skipped once the line has been logged. docs/startup-runtime.md says the retry runs only on runtimes that refuse the heap-indexing flags and that d3d12_xs_shim_heap_indexing reports 77 elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * startup: fail the root signature retry if provenance cannot be kept --------- Co-authored-by: rasptum <348594691+rasptum@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Royoo <3230853833@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Refs #870. Follows R0Y00's direction on #870 (17:12Z and 17:21Z): defer the native root bind until a real draw has the indexed heaps it needs, keep the translated path on its own root signature, refuse a real draw that lacks a heap or cannot restore the signature's state, and keep the unflagged path and the existing root-CBV controls. Supersedes the approach of the closed draft #1685 (a one-entry default sampler heap bound before the root signature); the debug-layer message callback with a plain-list control comes from that draft, hence the co-author trailer.
Command-list slot 34 forwarded every title root signature to the desktop list. Title root signatures carry
D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDand/orSAMPLER_HEAP_DIRECTLY_INDEXED(0x400,0x800), but slot 32 only tracks the title's heaps and never forwards them, so the debug layer reports message ID 1419 for each flag. In a local startup run (RX 9070 XT, driver 32.0.31044.16,X2W_D3D12_DEBUG=1, 75 s) unmodified main gave 394 ID-1419 messages out of 400 debug messages; a prototype of this change gave 0 of 6, with translated draws unchanged (14,419 vs 14,080, 0 not drawn). Translated draws bind their own root signature (create_translated_root, no flags) and are not a source of the message.Change
CreateRootSignaturelog line now prints them).src/startup_stubs/heap_indexed_root.h:decide_real_roottakes the flags, the mirrored view and sampler heaps on the list (bound, entries, whole), the highest index the draw reads (or unknown), and whether every root constant, descriptor table and root descriptor can be set again. It returnsbindor a specific refusal: view heap missing, sampler heap missing, both heaps missing, root state not restorable. A heap covers a draw only at indices it holds, so a one-entry sampler heap covers index 0 only and never stands in for the view heap.real draw refused: root signature heap flags 0x..., <reason>, first three per reason, then every 1000th). Thex2w-render totalsline addsheap-indexed roots deferred N (real draws refused: view heap, sampler heap, both heaps, state). The deferred bind after abinddecision is one line and is not reachable with the stand-in's facts.docs/startup-runtime.md(Heap-indexed root signatures) anddocs/experiments.md.Tests
Branch
startup/root-heap-indexedat0ceece32, based one4ac2c78. Windows 11 build 26300, MSVC 19.44.35221, Debug (--preset dev). WARP: Microsoft Basic Render Driver 10.0.26100.9818. Hardware: AMD Radeon RX 9070 XT, driver 32.0.31044.16. The draw fixtures enable the D3D12 debug layer in-process (X2W_TEST_DEBUG_LAYER=1); GPU-based validation off.Real-draw decision coverage (device-free)
startup_heap_indexed_root: passed, 3222 of 3222 decisions as expected. 22 named cases (each flag alone, both, none; one-entry sampler heap at index 0, index 1 and unknown; sampler heap alone under both flags, with one entry and whole; view heap alone; neither; state lost with heaps present; other root flags; the stand-in's own request for each flag set) plus a 3200-case matrix: flags {0, 0x400, 0x800, 0xC00} x view heap {absent, one entry, four entries, whole} x highest view index {0, 1, 3, 4, unknown} x the same for samplers x restorable {no, yes}, compared with expectations written separately in the test.startup_heap_indexed_root_sampler-alone_controlandstartup_heap_indexed_root_bind-unrestorable_control(WILL_FAIL): passed, i.e. the check failed with 2192/3200 and 2759/3200 matching under the mutated expectations.This covers the decision only. No source-built fixture reaches the stand-in's real-draw branch (see Not covered).
Translated GPU readback and debug layer (source-built)
startup_root_heap_{warp,hardware}: the root CBV fixture (a translated pixel shader reading four floats through root parameter 0) with the title root signature created with each flag alone, both, and neither. For every flagged case the same root signature blob is first set on a plain desktop list with no heaps (fail-first control); it must report exactly one ID 1419 per flag, otherwise the run exits 77. Through the stand-in, every case must report 0 messages with ID 1419, draw the exact 32 pixels, and log one deferral line per slot-34 call (none for the unflagged case).bound, flags 0x0 (unflagged, immediate bind)bound, 0x400bound, 0x800bound, 0xC00null, 0xC00switch_root, 0xC00Result:
startup_root_heap_warppassed (3.5 s),startup_root_heap_hardwarepassed (4.7 s). The hardware draw runs on the RX 9070 XT; the pipeline-preparation step of each case uses WARP as in the other stream fixtures.The existing
startup_root_cbv_{warp,hardware}(bound, unbound, null, same_root, switch_root, wrong_type; no debug layer, unflagged root signatures serialized as version 1.0 exactly as before) passed unchanged on both backends.All startup tests
ctest --preset dev --no-tests=error -R '^startup_' -j 4: 198 tests, 194 passed, 0 failed, 4 skipped. The skips are capability skips unrelated to this change:startup_view_heap_{warp,hardware}andstartup_logical_view_{warp,hardware}("adapter accepts 1245184 descriptors directly"). Docs checks:tests/docs_links_check.py(17 files, 365 links) andtests/bidi_controls_check.pypassed.Negative controls
if (true)in place ofif (!pass.root_heap_flags)):startup_root_heap_warpandstartup_root_heap_hardwarefailed withAssertionError: bound 0x400: stand-in list: 1 messages with a control id or id 1419, 0 other errors. Run case by case under the same mutant, the stand-in reported 0 (0x0), 1 (0x400), 1 (0x800), 2 (0xC00), 2 (null0xC00) and 6 (switch_root0xC00) ID-1419 messages on both WARP and the RX 9070 XT, so each flag fails independently.startup_root_cbv_{warp,hardware}still passed under that mutant (no debug layer, no flags). Reverted.startup_heap_indexed_root(exit 1), then reverted (3222/3222 again):FAIL both flags, one-entry sampler heap alone: ... -> bind, expected view heap missing(2559/3222);FAIL both flags, both heaps, state lost: ... -> bind, expected root state not restorable(2778/3222);FAIL sampler flag, one-entry heap, index 1: ... -> bind, expected sampler heap missing(2332/3222).Not covered
pipeline_realis set only bybuild_stream_pipeline, which needscompile_translation; that has returned no shader since e658fe2, so no source-built test can reach the real branch oflist_draw. The refusal and its counters are checked only through the device-free decision matrix, not through a draw. As asked on P0: main executable startup progress #870, no alternate pipeline-build path was added for this slice. Because the stand-in cannot restore root constants and descriptor tables under a deferred root, the real path for flagged roots stays explicitly refused until a real end-to-end fixture exists.🤖 Generated with Claude Code