D3D12.X: a DispatchX with thread dimensions launches whole groups #2610
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!2610
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2610"
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?
@KDenKC on GitHub · 2026-11-26 01:52 UTC · original
KDenKC:dispatchx-thread-dims→main· +116 −15 · 5 files · 1 commits · openPart of a stack: EXEC masking of the last group follows in a second PR.
Related: #1751. The BVH rehydration passes it discusses (
RehydrateRaytracingAccelerationStructureBatched2X) are among the DispatchX calls this fixes. A step on the #1833 roadmap.DispatchX(x, y, z, flags)dropped its flags (list_x::dispatch_x). WithUSE_THREAD_DIMENSIONS(0x20; 0x8020 with the wave32 bit), x, y, z are thread counts: the console launchesceil(count / numthreads)groups and leaves the lanes past the count out of EXEC. XCL launched the counts as groups. That's 32–64× the groups, and past D3D12's 65,535 groups for a large enough count. On the retail title, the BVH builder's rehydration passes have no bounds check of their own, so every extra thread wrote outside the node array.The retail title calls it at world start. This PR's run logged it (127.7 s):
DispatchX with flags 0x20: 45x1x1andflags 0x8020: 1x1x1. Before this change the first launched 45 groups of 64 threads for 45 items.What PR 1 fixes on its own: the 32–64× group overrun and the 65,535-group overflow. Shaders that check their own bounds (the BVH builder's
DecompressHeaderandReloadTriangles) now run correctly.What it doesn't fix yet: the unguarded Box32 / Box16 rehydration still runs the last group whole, so it overruns by up to 63 lanes until the second PR masks them out of EXEC.
What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:dispatch_xforwards its flags; a dispatch put off to the submit (Deferred::Dispatch) keeps them.crates/xcl/src/hle/d3d12x/bind.rs:dispatch_flags+dispatch_groups: with 0x20 the counts become whole groups of the pipeline's consolenumthreads.A pipeline whose group shape isn't known is skipped and counted (launching the counts as groups was the bug).
Each flags value is logged once.
The thread count of an axis that doesn't end on a whole group goes into
io.crates/xcl/src/gpu/recomp/mod.rs:IO_THREAD_LIMIT= io slots 114–116, written now, read by the compute prologue in the second PR. Slot 113 is left for #1428.crates/xcl/src/gpu/recomp/pso.rs,hle/d3d12x/real.rs:compute_interfacegives the console'snumthreadswith the user SGPRs; it's kept per pipeline (pso_threads).Test
dispatch_x_with_thread_dimensions_launches_whole_groups.Tested
RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.99.1; debug tests, release smoke builds. Base
main08db802.The new test fails with
main's behaviour (the counts launched as groups:left: Some(([640, 1, 1], …)),right: Some(([10, 1, 1], …))) and passes with the change.cargo test -p xcl --lib hle::d3d12x -- --test-threads=4: 254 passed, 0 failed, 2 ignored.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4ona3e820d(
XCL_NETWORK=0): 1426 passed, 4 failed, 47 ignored over 37 test binaries. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState0x8007000E, seeds70 / 545 / 1019 / 1507). They fail the same way on
main08db802(pre-existing, #1905).--no-fail-fastbecause otherwise those 4 stop cargo before the integration tests.SKIPPED (26 lines): GPU tests or forms that need wave64 (no wave64 on this card); 3 f16/f32 forms the
per-lane lowering refuses (#1426);
heap_window_out_of_memory_falls_back_to_the_switch_form(no heapwindows);
pso_measurement_compiles_an_exact_synthetic_record(needs Developer Mode).Tested by others (thank you):
a3e820dagainst its parent: whole suite 1429 passed / 1 failed (the same fuzz test on both); plus a GPU check that the groups run every wanted thread exactly once (e.g. 45 threads: 64 lanes, against 2,880 onmain). #2610cargo test -p xcl --liball passed with the branch merged on currentmain.main: the new test passes;gpu_suite 165 passed / 3 failed (the lane's known baseline, not this PR). #2610Regression run
main:This PR (
a3e820d):Both: the retail title,
-Seconds 200,XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, the same scripted input to the world load, each on a copy of the same cache under a never-used exe name. Both stop presenting at the world load (cold whole forms of split compute programs, #2088), shortly after the DispatchX calls above.Not tested
The masking of the last group's lanes (second PR); until then the unguarded rehydration passes still overrun by up to 63 lanes.
Whether rendering with ray tracing improves: the title stops at world start for other reasons (#2088, #2403) before anything is drawn with these acceleration structures.
Indirect
DispatchX(XBOX_ARG_DISPATCH_X, GPU-written counts): still group counts; it needs a GPU pre-pass.The inline console-list record
0x4003_CC00(only withXCL_CONSOLE_LISTS=1): a separate PR.AMD and Intel GPUs, other NVIDIA cards.
AMD test wanted: this has not run on AMD. A run on RDNA2/3/4 would help:
cargo test -p xcl --lib dispatch_x -- --test-threads=4(the new test isdispatch_x_with_thread_dimensions_launches_whole_groups), and if you can,scripts/smoke.ps1on this head againstmain, plus theDispatchX with flagslog lines from a run that reaches the world.AI use
🤖 Generated with Claude Code
@DavidM1911 on GitHub · 2026-11-26 02:31 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
@oni-swr on GitHub · 2026-11-26 03:05 UTC · original
Test report: AMD RX 7800 XT, exact head
a3e820d8e86fcbd8322fee8e519f4b6593b076ce, with exact parent08db8020d323bf478964fcc586152cce54959cfcas control. Both were clean detached checkouts (no uncommitted changes), not merged with currentmain.Hardware / setup
XCL_NETWORK=0,cargo -j 4.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4(37 test binaries):a3e820d: 1429 passed, 1 failed, 47 ignored08db802: 1428 passed, 1 failed, 47 ignoredgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: res[30] = 0x1, CPU 0x7fffffff). It reproduces on its own withcargo test -p xcl --lib gpu::dxil::fuzz_testson both commits, so it is not from this PR.f16_programs_on_the_gpu/f32_programs_on_the_gpu(refused, #1426), andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).cargo test -p xcl --lib dispatch_x -- --test-threads=4: head 1 passed (dispatch_x_with_thread_dimensions_launches_whole_groups); the parent has no such test (0 run).cargo test -p xcl --lib hle::d3d12x -- --test-threads=4: head 254 passed, 0 failed, 2 ignored; parent 253 passed, 0 failed, 2 ignored.Extra synthetic checks (local only, not proposed for the PR)
Three temporary tests were added to
bind.rs's test module on the head checkout (patch below). They were run withcargo test -p xcl --lib verify2610 -- --test-threads=1 --nocaptureandXCL_VERIFY_ADAPTER="AMD Radeon RX 7800 XT", which makes the GPU test fail on any other adapter. Result: 3 passed, 0 failed.verify2610_group_counts_sweep_and_bounds(dispatch_groups):[64,1,1],[32,1,1],[256,1,1],[1024,1,1],[8,8,1],[4,4,4],[16,16,4]), flags0x20/0x8020/0x21, counts 0..=3000 plus 65,535·numthreads−1 and 65,535·numthreads:0x20(0,0x8000,0x1,0x10,0x40), the counts pass through as groups.u32::MAXthreads give 67,108,864 groups without overflow, and a zero in the group shape is taken as 1.verify2610_dispatch_x_forwards_flags:list_x::dispatch_x(…, 100, 1, 1, 0x20 / 0x8020)on a translated pipeline whose group shape is not known reachesdispatch_flagswith the flags and is skipped.DISPATCHES_SKIPPEDgoes up, and no Dispatch, root signature, UAV or PSO call reaches the fake list. The deferred path (Deferred::Dispatch(.., flags)→record_deferred) was not driven at runtime.verify2610_gpu_whole_groups_cover_threads: an HLSLcs_6_6shader with the samenumthreadsis launched throughrunner::dispatchwith the groups thatdispatch_groupsgives. It counts the lanes it runs, and each thread inside the count marks its own slot. The buffer is sized for the counted threads only, and only in-range threads write to it. Adapter printed:AMD Radeon RX 7800 XT.main's launch (counts as groups): lanesThe last column is
main's behaviour (the counts launched as groups), run on the same build for comparison, and only where that is a valid dispatch.Not tested
scripts/smoke.ps1/ any retail title (out of scope for this report), and theDispatchX with flagslog lines from a title.IO_THREAD_LIMITio slots reaching the GPU throughbind_abi(not driven here; it is read only in the second PR), and the deferredDispatchXpath at runtime.DispatchX, and other AMD generations (RDNA2/4).Local test patch (applied on top of
a3e820donly for this run)AI use: Claude Code (Claude Opus 5.5), coordinated by Codex (gpt-6.2-sol), ran these tests, wrote the temporary checks and wrote this report. The results come from the runs above on this machine.
@itsSio on GitHub · 2026-11-26 03:57 UTC · original
Independent dual-PC NVIDIA full-workspace test report on clean head
a3e820d8e86fcbd8322fee8e519f4b6593b076ce.Tested
32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA)cargo build --workspace: exit 0cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1430 passed, 0 failed, 47 ignored (bind::tests::dispatch_x_with_thread_dimensions_launches_whole_groupspassed)SKIPPED: 26 (wave64-only GPU tests,#1426wave32 f16/cvt refusals,heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record)32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA)cargo build --workspace: exit 0cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1430 passed, 0 failed, 47 ignored (bind::tests::dispatch_x_with_thread_dimensions_launches_whole_groupspassed)SKIPPED: 29 (same 26 as Machine 1 plus 3 requiringd3d12SDKLayers.dll)Not tested
scripts/smoke.ps1runs--release)AI use
Ran via Samaritan:
@pickles976 on GitHub · 2026-11-26 05:00 UTC · original
Wine cross-check of the new test — passes; scope is the group arithmetic, not GPU execution. Head
a3e820d8e86fcbd8322fee8e519f4b6593b076ce, RTX 4060 Laptop GPU host, Wine 11.0, NVIDIA 590.48.1,--locked --target x86_64-pc-windows-msvc, one test thread, freshCompiling xcl .../xcl-pr2610/...provenance.dispatch_x_with_thread_dimensions_launches_whole_groups— 1/1 pass (0.00 s). The fixture is the CPU-sidedispatch_groupstable (bind.rs), so the pass cross-checks the math under the Windows target on this host, including the 2-D shape[8,8,1]→[20,16,3]→ 3×2×3 case, the wave32 bit changing nothing, and the unknown-shape skip. No GPU dispatch was executed here — the retail-title relevance of this fix (BVH rehydration overruns at world start) remains the author's Windows observation; I have not run the title.This PR is on the world-entry chain for this machine's goal (the #2140 failfast class: retail title, world start), so I'll watch for the stacked EXEC-masking follow-up it mentions. Log:
.compat-xcl/logs/verify-pr2610-wine-dispatchx-relaxed.log(local). AI-assisted verification and report (OpenAI Codex).@SlopTart on GitHub · 2026-11-26 05:29 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. This PR does not change the mad/mac red on RADV.Targeted run of
dispatch_x_with_thread_dimensions_launches_whole_groups: passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
@DavidM1911 on GitHub · 2026-11-26 08:29 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.