Repository navigation
D3D12.X: an ExecuteIndirect reads the arguments written before it - #1791
Conversation
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)
|
Test report for Tested
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 ( 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: AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs and wrote this. |
|
Test report: retail 1.0.2.1 on an RTX 5090, #1791 at Tested
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. |
|
Test report for
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. |
…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
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)
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>
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
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
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.