Skip to content

D3D12.X: an ExecuteIndirect reads the arguments written before it - #1791

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
wondercrash:pr/ei-arg-order
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
wondercrash:pr/ei-arg-order

Conversation

@wondercrash

Copy link
Copy Markdown
Contributor

On 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 18567a5f0145bde9 at 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 until XCL_RUN_SECONDS ended 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 #101 until 0x887a0005). Neither is confirmed fixed by this: not tested on those setups.

#1764 (open, conflicting with main) also changes execute_indirect's PC-pipeline path. The two do not conflict with each other: merging #1764's head bc01e87 into this branch gives the same single conflict it already has with main (its root-signature block against main's console-compute skip), and this PR's lines merge cleanly. Neither uses the other's list-type lookup: #1764 adds bind::list_type (the list's GetType through its original vtable) to pick the root-signature setter; this PR adds list_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 (never on_created) this PR does nothing.

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs: fresh_indirect_arguments wraps both PC ExecuteIndirect calls of execute_indirect (PC pipeline and translated) in COMMON -> INDIRECT_ARGUMENT -> COMMON of the device's ARGUMENT_ORDER buffer (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 from on_create's state, None for a list XCL does not track); transition is pub(super).
  • Test 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

  • NVIDIA GeForce RTX 5090 (driver 621.14, 32-lane waves), AMD Ryzen 7 9800X3D, Windows 11 10.0.22631, Rust 1.96.0 MSVC, debug; DXC 1.8.2502 (Windows SDK 10.0.26100).
  • The new test, cargo test -p xcl --lib -- bind::tests::execute_indirect_reads_the_arguments_written_before_it:
    • without the transitions (fix disabled, test kept): 40 of 40 ExecuteIndirects ran another group count than the one written before them (try, groups): [(0, 0), (1, 4096), (2, 0), ...];
    • with them: 1 passed.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4:
    • this PR (9486494 on main 4178e88): 892 passed, 0 failed, 42 ignored (the new test among them; no build warnings);
    • main 4178e88: 891 passed, 0 failed, 42 ignored.
    • SKIPPED on both: 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).
  • Retail title on our integration branch (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), main first, same machine:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 5090
title: retail
seconds: 60
exit: 0x0
frames shown: 1650 (PresentX 1650)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16826 MB
xcl-smoke v1
commit: 9486494d0b00bfd97431a915144cb24bc3e3d48f
gpu: NVIDIA GeForce RTX 5090
title: retail
seconds: 60
exit: 0x0
frames shown: 1655 (PresentX 1655)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16743 MB

Not tested

AI use

  • omp with Claude Opus 5.5 found the cause, wrote the change and the test, ported it onto main, ran the suites and wrote this description. The title runs are ours, on the hardware above.

The console orders a dispatch that writes indirect arguments before the
ExecuteIndirect that reads them with a barrier that reaches the PC as a
UAV barrier. NVIDIA's driver (RTX 5090) fetches the arguments without
waiting for it: the ExecuteIndirect ran the count the memory held before
the list, also when the dispatch wrote it through another resource over
the same memory, as translated shaders do through the memory windows.
A transition to INDIRECT_ARGUMENT makes the driver wait - of any buffer,
as measured - so each ExecuteIndirect is now recorded between two
transitions of a buffer of XCL's own (the title's buffer is in the
title's state).

Only lists XCL made (list_x::on_create) get the transitions, and not
bundles; the type comes from list_x's state (list_x::tracked_list_type),
not a call to the list, so a list XCL does not track gets no calls.

Test: execute_indirect_reads_the_arguments_written_before_it (GPU):
40 of 40 tries ran the old count without the transitions, 0 with them.

Assisted-by: omp (Claude Opus 5.5)
@Krashgamer

Copy link
Copy Markdown

Test report for 9486494 on 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

without (4 runs) with 9486494 (2 runs)
GPU waits released on CPU before 240 s 44, 47, 29, 26 0, 0
device removal none none

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

Copy link
Copy Markdown

Test report: retail 1.0.2.1 on an RTX 5090, #1791 at 9486494 on a local tree. The GPU no longer stays pinned at 100 %, and the async-compute queues no longer stall at 18567a5f. Not a main + #1791 run.

Tested

the same tree without #1791 (5 runs) with #1791 (2 runs)
GPU after world entry 100 % without a break from ~155–185 s until the process ended, 186–267 W 57–93 % at ≤ ~121 W from ~150 s, then idle (1–3 %) before the end
async-compute queues (4 runs with my dispatch diagnostic before, 1 with it after) each held a submission that never finished: the meshlet_culling list, with the ExecuteIndirect of 18567a5f0145bde9 started and not done submissions slower than 3 s still occur, but they finish (13 of 14 seen finishing); 18567a5f never showed as running
end watchdog +0x23cf683 at 213.4 / 231.4 / 233.4 / 278.4 / 280.4 s watchdog at 319.8 s; title crash +0x540abf5 (read of 0xb1) at 239.1 s

Not tested

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.

@raylitebull
raylitebull merged commit 4e3515e into xcl-dev:main Nov 24, 2026
3 checks passed
@wondercrash
wondercrash deleted the pr/ei-arg-order branch November 24, 2026 21:18
@PracticalStudios

Copy link
Copy Markdown

Test report for 9486494 on Ampere: the same stale read, and the fix works.

  • RTX 3090 24 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 26200, Rust 1.89.0, debug.
  • cargo test -p xcl --lib -- hle::d3d12x::bind::tests::execute_indirect_reads_the_arguments_written_before_it
    • as pushed: 1 passed (3 of 3 runs);
    • with fresh_indirect_arguments returning op() 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.
  • Not tested: the retail title with this PR.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment.

anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
…v#1791, xcl-dev#605, xcl-dev#1806, xcl-dev#1745)

Merges 60 upstream commits through c4d37be, incorporating:
- PR xcl-dev#1747 (raylitebull): eliminate multi-heap UpdateTileMappings and per-texture Signal stalls in vram::Pages via contiguous TilePool
- PR xcl-dev#1791 (wondercrash): D3D12.X an ExecuteIndirect reads arguments written before it
- PR xcl-dev#605 (0x6461726B): promote R9G9B9E5_SHAREDEXP render/UAV targets to R11G11B10_FLOAT
- PR xcl-dev#1806 (bmjask): Direct DXIL image_get_lod accepts static samplers
- PR xcl-dev#1745 (gefydev): direct per-lane DXIL recompiler lowering backend

Assisted-by: Antigravity
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
Conflicts:
- build.rs: upstream's per-lane source hash kept; integ's second copy of the
  /HIGHENTROPYVA:NO link argument dropped (upstream's xcl-dev#631 copy at the top of
  main() stays).
- gpu/recomp/mod.rs: integ's loop budget kept next to upstream's xcl-dev#1321
  fallback, then xcl-dev#1321 left out: integ's one skip variable (c70c9f0)
  removes the quadratic guards it bounds. With it, no retail program comes
  near 128 B per byte (95cc13288a27a96e: 18.9 MB structured), and the bound
  would only move memory-dense programs (S_BUFFER_LOAD / BUFFER_LOAD runs at
  4 windows: 250-300 B per byte, structured no larger than the pc form) to
  the pc form. Its test is left out with it; c70c9f0's
  crossing_forward_jumps_keep_the_guards_short covers that layout.
- hle/d3d12x/bind.rs: xcl-dev#1791 is upstream's copy of d2d8c93 / 923c3f8:
  integ's call sites (gpu_profile, breadcrumbs, XCL_SKIP_SHADERS) kept
  around upstream's identical fresh_indirect_arguments; the test that both
  sides added is kept once, at upstream's place.
- hle/d3d12x/vram.rs: xcl-dev#1747 as ported on try-1747 (11a9069): the PR's side
  of place_on_pages, with integ's pages() at its two PAGES.lock() sites so
  releases deferred while PAGES was held still run.

Assisted-by: omp (Claude Opus 5.5)
mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
Brings xcl-dev#1747, xcl-dev#1791, xcl-dev#605, xcl-dev#1679, xcl-dev#1806, xcl-dev#1745, xcl-dev#1307, xcl-dev#1321 among others.

Resolutions:
- dxil/kernel.rs: upstream's Lw::new / Lw::finish; the safe s_barrier state
  and policy and xcl-dev#1741's single-wave bounded exchange move into Lw::new, with
  a safe_barrier flag (false for the per-lane lowering).
- dxil/lower.rs: VAR_BAR_DEAD moves to VAR_BUDGET + 6 (+5 is VAR_F32_MODE).
- TRANSLATOR_VERSION 9.
- d3d12x/bind.rs: the bounded ExecuteIndirect call runs inside
  fresh_indirect_arguments.
- d3d12x/list_x.rs: tracked_list_type, and transition (pub(super)) over the
  batched transitions.
- recomp/mod.rs: compact backend and per-lane modules both kept; the
  oversized-structured-code fallback applies to translate after prepare.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants