startup: defer heap-indexed root signatures and refuse real draws under them #1725
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1732"
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 MasterDomino on 2026-11-24T17:56:08Z.
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 sincee658fe24, 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 #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
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T17:56:18Z.
@tedin7 this is the single implementation from #870 that replaces #1685; your message-callback counter and plain-list control are in
tests/startup_root_heap.cpp(co-author trailer on the commit). A Windows Debug + Release /O2 run from you would be welcome, since I've only run Debug here.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:06:09Z.
Review: COMMENTED
Review of PR #1732 (
0ceece32c0db5aa961bcdb1727ad39b470a0376c).Findings
No blocking issues found.
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
src/startup_stubs/d3d12_xs_device.cpp):device_create_root_signature) extractsD3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED(0x400) andSAMPLER_HEAP_DIRECTLY_INDEXED(0x800) intoroot_heap_flag_map().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.list_root_srv) avoids forwarding root SRVs to the desktop list under a deferred root while still recordingpass.root_address.src/startup_stubs/heap_indexed_root.h,list_draw):!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.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.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".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.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)$'):--preset dev): build21.77s, 9/10 passed (4.72s),startup_root_heap_warpskipped (exit 77)./O2(--preset release): build38.85s, 9/10 passed (4.88s),startup_root_heap_warpskipped (exit 77).--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.