D3D12.X: an ExecuteIndirect reads the arguments written before it #1791
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1791
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1791/head"
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?
@wondercrash on GitHub · 2026-11-24 20:47 UTC · original
wondercrash:pr/ei-arg-order→main· +196 −3 · 2 files · 1 commits · merged 2026-11-24 21:17 UTCOn NVIDIA (RTX 5090) a title's ExecuteIndirect runs the arguments the memory held before the command list, not the ones a dispatch just wrote before it in the same list. The console orders that dispatch before the ExecuteIndirect with a barrier that reaches the PC as a UAV barrier (
list_x::resource_barrier_x), and the driver fetches indirect arguments without waiting for it. A transition to INDIRECT_ARGUMENT does make it wait (of any buffer, as measured), so each ExecuteIndirect is now recorded between two transitions of a 256-byte buffer of XCL's own. The title's argument buffer cannot take the transition: it is in the title's state.Found on a retail title: in our runs 9 to 24 the GPU sat at 100 % until the queues stopped, with an ExecuteIndirect of
18567a5f0145bde9at a queue's head in every stop (run 24:#93665 ExecuteIndirect max 1 (dispatches; ...) (shader 18567a5f0145bde9, running), right after the two dispatches that write its arguments and a UAV barrier). The program has no loop. Skipping it (XCL_SKIP_SHADERS, run 25) removed the hang. With this change and nothing skipped (run 26, on our integration branch):CS 18567a5f0145bde9 ExecuteIndirect (dispatches) ...: 17 call(s), longest 0.1 ms, no hang, no device removal, 150 s and 1269 frames untilXCL_RUN_SECONDSended it.Related: #505 (@maephisto666, RTX 5090: the four async-compute queues stopped at an ExecuteIndirect of
18567a5f; the GPU read its arguments as[6636, 1, 1]while the CPU view of the same words read[0, 0, 0], which fits a stale read like the one here) and #1452 (@Ariorh1337, RTX 5090: GPU at 100 % from the first#101until0x887a0005). Neither is confirmed fixed by this: not tested on those setups.#1764 (open, conflicting with
main) also changesexecute_indirect's PC-pipeline path. The two do not conflict with each other: merging #1764's headbc01e87into this branch gives the same single conflict it already has withmain(its root-signature block againstmain's console-compute skip), and this PR's lines merge cleanly. Neither uses the other's list-type lookup: #1764 addsbind::list_type(the list'sGetTypethrough its original vtable) to pick the root-signature setter; this PR addslist_x::tracked_list_type(XCL's own state, no call to the list) to leave bundles and lists XCL did not make alone. On #1764's fake list (neveron_created) this PR does nothing.What is in it
crates/xcl/src/hle/d3d12x/bind.rs:fresh_indirect_argumentswraps both PCExecuteIndirectcalls ofexecute_indirect(PC pipeline and translated) in COMMON -> INDIRECT_ARGUMENT -> COMMON of the device'sARGUMENT_ORDERbuffer (argument_order_buffer, made on first use; if it cannot be made, a warning and the call as before). Only on lists XCL made, not bundles (no barriers in a bundle). Cost: two transition barriers per ExecuteIndirect.crates/xcl/src/hle/d3d12x/list_x.rs:tracked_list_type(a list's type fromon_create's state, None for a list XCL does not track);transitionispub(super).bind::tests::execute_indirect_reads_the_arguments_written_before_it(GPU): a dispatch writes(x, 1, 1)through a placed buffer aliasing the argument buffer (as translated shaders write through the memory windows), a UAV barrier, then the ExecuteIndirect through an adopted list; 40 tries, each writing a count the memory does not hold yet.Tested
cargo test -p xcl --lib -- bind::tests::execute_indirect_reads_the_arguments_written_before_it:40 of 40 ExecuteIndirects ran another group count than the one written before them (try, groups): [(0, 0), (1, 4096), (2, 0), ...];1 passed.cargo build --workspace && cargo test --workspace -- --test-threads=4:9486494onmain4178e88): 892 passed, 0 failed, 42 ignored (the new test among them; no build warnings);main4178e88: 891 passed, 0 failed, 42 ignored.gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).main+ other PRs, incl. diagnostics not in this PR) with the same change: run 26 above.Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input (both runs stay on the start screen, so the cutscene's ExecuteIndirect is not reached),mainfirst, same machine:Not tested
main+ this PR alone in a title run: the title runs were on our integration branch.AI use
main, ran the suites and wrote this description. The title runs are ours, on the hardware above.@Krashgamer on GitHub · 2026-11-24 21:14 UTC · original
Test report for
9486494on an RTX 3080 10 GB (32-lane waves, driver 610.88), the retail title 1.0.2.1, Series X: with this PR, none of the bridged GPU waits timed out in the first 240 s, in 2 runs out of 2. Without it, 26 to 47 did, in 4 runs out of 4. This is the #1452 setup that this PR lists under Not tested: compute queues waiting on the direct queue, released on the CPU after 5 s.Tested
XCL_DIRECT_DXIL=1 XCL_PSO_WAIT_MS=50 XCL_PAGE_BUDGET_MB=4096 XCL_NETWORK=0, A pressed every 10 s byXCL_PRESS_AT.main4178e88+ #640 + #742 + #800 + #1055 + #1102 + #1765 + #1580 + a local log line (not a cleanmainA/B). "With" adds this PR.9486494(2 runs)What the waits were (#1580's graph, without this PR): every compute queue waited on a signal of direct queue q3. q3 itself had no tracked wait pending ahead of those signals; it had not even completed XCL's per-submission fence signals queued before them (
#4244 signal fence …still outstanding). The sparse upload fence and the page-mapping fence were both complete at each timeout, so XCL's own queues were not holding q3. That fits a q3 that is still executing, as this PR describes.Not fixed by this on this machine: the picture still stops presenting during the world load. With this PR the gaps are the title not submitting at all (0 submits for several seconds), while 4 to 7 huge compute pipelines were built on demand. I have not traced what the title waits on there.
Not tested:
main+ this PR alone; more than 2 runs with it; AMD.AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs and wrote this.
@maephisto666 on GitHub · 2026-11-24 21:16 UTC · original
Test report: retail 1.0.2.1 on an RTX 5090, #1791 at
9486494on a local tree. The GPU no longer stays pinned at 100 %, and the async-compute queues no longer stall at18567a5f. Not amain+ #1791 run.Tested
maincbea872+ #433, #1321, #789 (both rebased ontocbea872), #751, a DirectStorage fix of mine (not a PR yet) and local diagnostics. #1791's diff (9486494) applies on it without changes.cargo test -p xcl --lib hle::d3d12x -- --test-threads=4, debug, with #1791 and my dispatch diagnostic: 136 passed, 0 failed, 1 ignored. That includesexecute_indirect_reads_the_arguments_written_before_it. I did not run the whole suite on this tree.XCL_PSO_WAIT_MS=50. GPU load is sampled once a second withnvidia-smi, outside the game.meshlet_cullinglist, with the ExecuteIndirect of18567a5f0145bde9started and not done18567a5fnever showed as running+0x23cf683at 213.4 / 231.4 / 233.4 / 278.4 / 280.4 s+0x540abf5(read of0xb1) at 239.1 sXCL_PSO_WAIT_MS=50. So on this setup, #1791 removes the runaway GPU, and what is left is a different wall.18567a5f's arguments with aCopyBufferRegionplaced after a UAV barrier:[6636, 1, 1]in one run and[0, 1, 1]in another. A copy waits for the barrier, so those were the values the ExecuteIndirect should have used, not the ones it fetched.Not tested
main+ #1791 alone, so noxcl-smokepair from me.+0x540abf5comes from skipped work: not examined.AI use: Claude Code (Claude Opus 5.5) rebased the patches, ran the builds, tests and runs, read the logs and wrote this report. The numbers come from those runs.
@PracticalStudios on GitHub · 2026-11-24 21:19 UTC · original
Test report for
9486494on Ampere: the same stale read, and the fix works.cargo test -p xcl --lib -- hle::d3d12x::bind::tests::execute_indirect_reads_the_arguments_written_before_itfresh_indirect_argumentsreturningop()straight away (local change only): failed 3 of 3,40 of 40 ExecuteIndirects ran another group count than the one written before them, the same 0 / 4096 pattern as on your 5090.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment.
@DavidM1911 on GitHub · 2026-11-24 23:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.Thanks!