startup: opt-in split of a batched indirect Dispatch (Refs #2626) #2675
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2683"
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 ColorMeBoom on 2026-11-26T01:54:05Z.
What / Why
On an AMD Radeon RX 5700 XT (RDNA 1), desktop
ExecuteIndirectwith a Dispatch signature runs only its first command, and a single-command call ignores its count buffer (#2626). As agreed on the issue, this adds an opt-in workaround for slot 61. The native call stays the default on every adapter.With
X2W_SPLIT_INDIRECT_DISPATCH=1, a batched or counted Dispatch with a rootless signature and a desktop compute pipeline and root is split:rect_indirect_args.h.ias itself whilei < min(count, MaxCommandCount)and as(0,0,0)otherwise.restore_compute_rootsets the compute root with its views.MaxCommandCountsingle-command calls without a count buffer read the rewritten records.The translated compute path (#2470), graphics and mesh signatures, and rooted Dispatch signatures are unchanged.
Change
src/startup_stubs/split_indirect_dispatch.h(new): the scratch layout and the rewrite pass.d3d12_xs_device.cpp:list_execute_indirect, behindX2W_SPLIT_INDIRECT_DISPATCH=1.bind_compute_root_viewandrestore_compute_root. Slot 43 now records its root SRVs throughbind_compute_root_view. The split and the indexed-draw validation pass (d3d12_draw.inl) restore throughrestore_compute_root, which before this lived inline in the validation pass. The rectangle-list refusal checks the same recorded views.x2w_d3d12_fixture_compute_root_uavbinds a desktop root UAV throughbind_compute_root_view. Slot 45 is not forwarded, so no guest slot can bind the fixture's output.x2w_d3d12_recording_scratchesreports how many scratch buffers the recording's desktop allocator holds.scratches, so it is released only when the allocator is reset after its submits' fences have passed.tests/startup_indirect_dispatch.cpp:Dispatch(1, 1, 2)on the desktop list after slot 61, adding 102 only if the consumer pipeline, compute root and result UAV are still bound.CMakeLists.txt:startup_indirect_count_split_(warp|hardware)run count mode withX2W_SPLIT_INDIRECT_DISPATCH=1.startup_indirect_count_split_warpis added to theprtest preset.docs/experiments.md: section "Batched indirect Dispatch on RDNA 1".startup_indirect_count_(warp|hardware)keep the native call and stay strict.Tests
Commit under test:
7ed5e7f9onf4c6998a. Windows 11 Home build 26200.9974, VS 2022 Build Tools (MSVC 19.44.35230), Windows SDK 10.0.26100.0, DXC 1.9.2602.17. Debug layer unavailable (Graphics Tools not installed). Hardware: AMD Radeon RX 5700 XT (device731f), driver 32.0.21045.29003. WARP 10.0.26100.9818.startup_indirect_dispatch_*,startup_indirect_root_constants_*startup_indirect_count_*(native, strict)result=0x31415929, expected0x31415935startup_indirect_count_split_*(opt-in)Split runs, both adapters, whole readback compared:
0x314159350x31415a640x31415926(result untouched)0x314159290x31415a640x3141599bS_OK, the recording still held 1 scratch, and the result was0x314159350x314159260x31415a640x31415926Negative controls (local edits, not committed). Each made both split tests fail:
restore_compute_rootafter the pass: first caseresult=0x31415926, expected0x31415935;recording holds 0 split scratch buffers after Close, expected 1.ctest --preset pr --no-tests=error: 39/39 passed.Full
ctest --preset dev --no-tests=error -j 8 --timeout 600on the RX 5700 XT: 2,154/2,166 passed, and 12 failed:-j 8passed when rerun serially:compute_store_aot_hardware,compute_store_aot_lds_qword_hardware,compute_store_aot_lds_arithmetic_hardware,compute_store_aot_lds_private_hardwareandpixel_aot_cvt_f64_f32_hardware.startup_indirect_count_hardwarefails as reported (native call, kept strict).gpu_alias_window_hardware,gpu_alias_lookup_writes_hardwareandcompute_store_aot_mac_f32_hardwareare the RX 5700 XT results already listed on #2626.startup_gfx2hlsl_f32_med3_hardware,startup_gfx2hlsl_fma_mix_dispatch_hardwareandpixel_aot_sdwa_int_extra_hardwarewere added on main since that report. They run throughoffscreen_check, which does not linkd3d12_xsand has no source changed here. Their failures: the branchless-lowering control is not detected on hardware; twofma_mixhardware checks fail (negated inline-0 addend, and the control without the high-half shift); andsdwa_int_extra_co_ci_2has channel 10x00000000against0x0000ffff. I can report them separately.python -B tests/docs_links_check.py,python -B tests/bidi_controls_check.pyandgit diff --check: clean.Not verified
Refs #2626.
AI-assisted with Claude Code (Claude Opus 5.5).
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T02:59:58Z.
Independent AMD RDNA 4 result on
7ed5e7f9: the split opt-in produces every expected readback here, then the process exit faults with0xC0000409in the DLL detach, from the new function-local static.Measurements and one attribution experiment on this head; nothing pushed.
The short version
X2W_SPLIT_INDIRECT_DISPATCH=1on an RX 9070 XT (RDNA 4),startup_indirect_count_split_hardwareprints every check, reports no mismatch, and then dies with0xC0000409— 3 of 3 runs, and ctest recordsExit code 0xc0000409 ***Exception: 3.24 sec.warpit exits 0.d3d12_xs.dll, throughstatic SplitIndirectDispatch splitter;atsrc/startup_stubs/split_indirect_dispatch.h:165. The same cache as a never-destroyed instance exits 0, 3 of 3.amdxc64. What is fixable is destroying the pipeline state during CRT detach.Environment
Windows 11 25H2, build
10.0.26200.9974. AMD Radeon RX 9070 XT (PCI\VEN_1002&DEV_7550, gfx1201), driver32.0.32029.2010. MSVC19.44.35230.0(BuildTools14.44.35207), CMake4.4.4, Ninja, presetdev(Debug). D3D12 debug layer not installed.Commands
Observed
ctest selected 8 entries: 7 pass, and
Exit codes, from a batch that writes
!errorlevel!to a file, with the build stamp each run reported:-1073740791is0xC0000409as a signed exit code.Before dying, the count chain printed all 15 of its result lines with no
word N: got ...line. The lines the split adds:and the rest (counts 2, 9, 0, omitted writer, no count buffer, five refusals) are identical to what the native mode prints here. 15 lines is what the 14
verifycalls attests/startup_indirect_dispatch.cpp:479-492produce, because the retire case at:485prints two; the chain is&&, so one mismatch would have cut it short.The dump
0xC0000409, subcode0x7FAST_FAIL_FATAL_APP_EXIT: a deliberate__fastfail, not a stack-buffer overrun — the "Security check failure or stack buffer overrun" text in the dump header is the generic wording for the code.!analyze -vreportsSYMBOL_NAME: amdxc64+553b9,IMAGE_NAME: amdxc64.dll, bucketFAIL_FAST_FATAL_APP_EXIT_c0000409_amdxc64.dll!Unknown, andIMAGE_VERSION: 32.0.32029.2010— the same driver version the passing runs report.17 of the 57 frames, in the order cdb prints them (the fault is at the top). Template argument lists are abbreviated; the rest is verbatim.
Read it from the bottom up as execution order:
DllMainreceives the process-detach, the CRT runs itsatexittable, which destroys the function-local staticsplitter, which destroys itsvector<unique_ptr<Entry>>, which runs~Entry, which releasesComPtr<ID3D12PipelineState>, which reachesCPipelineState::FinalReleaseand then the driver — and the driver fast-fails. Above this selection sit the fast-fail frame and two moreamdxc64frames, then the threentdllexception-dispatch frames; below it sit 13 process-exit frames (ntdll!LdrShutdownProcess,ucrtbased!exit, themainreturn). The 7D3D12/D3D12Corerefcount frames betweenInternalReleaseandFinalReleaseare the ones hidden by the selection.The
d3d12_xsnames are real symbols: they carry the privatex2w_startupnamespace,lambda_…names and an anonymous-namespace static'sdynamic atexit destructor, with short offsets (+0x12, +0x14, +0x1b, +0x43). None of that can come from an export table. Theamdxc64names are the opposite: nearest-public-symbol artifacts of a stripped vendor module (+0x8db4, +0x20518, +0x553b9), so read them as offsets. The instruction that faults is in the vendor module.Site and the two experiments
split_indirect_dispatch.h:165is destroyed from_execute_onexit_tableduringdllmain_crt_process_detach. It ownsstd::vector<std::unique_ptr<Entry>> entries_(:160), and eachEntryownsComPtr<ID3D12RootSignature> rootandComPtr<ID3D12PipelineState> pipeline(:110-111).Entry::device(:109) is a raw pointer and is not released here.static SplitIndirectDispatch* splitter = new SplitIndirectDispatch();→ 3 of 3 exit 0 with the same 15 readback lines. The source was checked for that line before the build,git diff --statshows one file +4/-2, and the run log stampsbuild=7ed5e7f9-dirty.ComPtr<ID3D12PipelineState>release and it reachesCPipelineState::FinalRelease, so the pipeline state is the reference that gets to the driver; I did not run a variant that keeps only the root signature.This is a class the repository already closed
#2572 ("The five indirect tests fault at process exit: static pipeline states are destroyed during teardown") is the same shape, closed 25/11 by #2590 and #2631. At
b2564017, the base this PR was opened against, the placed-page cache detaches instead of releasing whenx2w_startup::d3d12_process_terminatingis true (d3d12_xs_device.cpp:4622,teardown_reportat:4633); the same code sits at:4631/:4642at0c8f5dab. This head is7ed5e7f9, which the PR body records as tested onf4c6998a, and at that treed3d12_xs_device.cppcontains neitherd3d12_process_terminatingnorteardown_report— the branch predates those changes. So a rebase puts this static next to the guarded caches rather than making the fault disappear: #2631's boundary covers the placed page aliases and the draw dumps, not this new cache.Limits
32.0.32029.2010; I have no RDNA 1 card and no older package for this card, so I cannot say whether the RX 5700 XT would fault too. On this machine the same binary detaches cleanly on the native path and on WARP, so it is the split path that aborts, not the teardown in general.AI-assisted; runs executed on the machine above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:21:38Z.
Review: COMMENTED
Review of head
7ed5e7f9(code and fixture tests only; I have no RDNA 1 or other AMD hardware, so I did not run any adapter-specific result).Blocking finding:
src/startup_stubs/split_indirect_dispatch.h:165holdsstatic SplitIndirectDispatch splitter;insidesplit_indirect_dispatch(). Its destructor runs during DLL detach and releases a pipeline state there. The independent RDNA 4 report above (3 of 3 runs, exit0xC0000409after all readbacks pass, ctestExit code 0xc0000409) points exactly at this destructor, and the same cache held as a never-destroyed instance exited 0. That makesstartup_indirect_count_split_hardwarefail on a GPU where the native path is fine, even though the opt-in is off by default. Suggested fix: keep the cache in a leaked heap instance (static auto* splitter = new SplitIndirectDispatch;) or release it from the device teardown while the device is alive, and add the exit code to the hardware test's expectations.Otherwise the design matches R0Y00's scope on #2626: opt-in only, native call stays the default,
startup_indirect_count_*stays strict and unsplit, counts 0, 1, 2, 3 and above max are covered, and count 0 leaves the output untouched.Not merging: this is a main-executable shim change with an open exit fault, and the verification that matters (a second RDNA 1 adapter) is on hardware we do not have. The merge stays with MasterDomino or @R0Y00.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T03:27:09Z.
Review: APPROVED
Integrated main and ran 12/12 Windows Release CTests on WARP and RTX 4060 Laptop with no skips. The native and opt-in dispatch tests passed, including counts 0 through 3, the clamped count, the subsequent dispatch with restored bindings, and the fenced allocator reset. The translated target and pixel UAV alias controls also passed in this combined tree. RDNA 1 behavior remains the contributor report in #2626.