Repository navigation
startup: opt-in split of a batched indirect Dispatch (Refs #2626) - #2683
Conversation
On an AMD Radeon RX 5700 XT (RDNA 1, device 731f), desktop ExecuteIndirect with a Dispatch signature runs only its first command, and a single-command call ignores its count buffer. With X2W_SPLIT_INDIRECT_DISPATCH=1, slot 61 splits a batched or counted Dispatch with a rootless signature and a desktop compute pipeline and root: the count word and records are copied into a scratch buffer, a one-group pass rewrites record i as itself while i < min(count, MaxCommandCount) and as (0,0,0) otherwise, and MaxCommandCount single-command calls without a count buffer read the result. The native call stays the default on every adapter. The translated compute path, graphics, mesh and rooted Dispatch signatures are unchanged. The pass replaces the compute root and pipeline. The split sets the pipeline again and restore_compute_root sets the root with every view recorded by bind_compute_root_view. Slot 43 records its root SRVs there, the indexed-draw validation pass restores through the same function, and the rectangle-list refusal checks the same views. The fixture-only export x2w_d3d12_fixture_compute_root_uav binds the fixture's desktop result UAV through bind_compute_root_view; x2w_d3d12_recording_scratches reports the scratch the recording's allocator holds until its fences pass. startup_indirect_count_(warp|hardware) keep the native call and stay strict. startup_indirect_count_split_(warp|hardware) run count mode with the split: GPU-written counts 2, 9, 0, 1 and 3, a follow-up Dispatch that needs the restored root, pipeline and UAV, the scratch count after Close, and a guest-queue submission behind a gate whose allocator is reset while pending. AI-assisted.
|
Independent AMD RDNA 4 result on The short version
EnvironmentWindows 11 25H2, build CommandsObservedctest selected 8 entries: 7 pass, and Exit codes, from a batch that writes
Before dying, the count chain printed all 15 of its result lines with no 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 The dump
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: The Site and the two experiments
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 Limits
AI-assisted; runs executed on the machine above. |
tedin7
left a comment
There was a problem hiding this comment.
Review of head 7ed5e7f (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:165 holds static SplitIndirectDispatch splitter; inside split_indirect_dispatch(). Its destructor runs during DLL detach and releases a pipeline state there. The independent RDNA 4 report above (3 of 3 runs, exit 0xC0000409 after all readbacks pass, ctest Exit code 0xc0000409) points exactly at this destructor, and the same cache held as a never-destroyed instance exited 0. That makes startup_indirect_count_split_hardware fail 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.
R0Y00
left a comment
There was a problem hiding this comment.
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.
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 RX 5700 XT (RDNA 1): ExecuteIndirect Dispatch with max count > 1 runs only the first command (startup_indirect_count_hardware) #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).