Skip to content

D3D12.X: dispatches of more than 65 535 groups in X are folded into Y - #1428

Open
lukastaro wants to merge 3 commits into
xcl-dev:mainfrom
lukastaro:d3d12x-fold-large-dispatches
Open

lukastaro wants to merge 3 commits into
xcl-dev:mainfrom
lukastaro:d3d12x-fold-large-dispatches

Conversation

@lukastaro

@lukastaro lukastaro commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of #505 (the world load): the GPU hang (0x887a0006) about 100 s into the world load on an RTX 5060 Ti.

The console runs up to 2^32 − 1 thread groups a dimension; D3D12 takes 65 535, and past that a dispatch is undefined. On an NVIDIA RTX 5060 Ti a retail game's world loading hung the GPU (DXGI_ERROR_DEVICE_HUNG, 0x887A0006) about 100 s in, every run. The dispatch markers of #1323 showed one unfinished dispatch each time: an ExecuteIndirect of one loop-free compute program, whose arguments (written by an earlier dispatch) were 72 512 × 1 × 1 and 75 072 × 1 × 1 groups. Clamping them to 65 535 removed the hang but left the last groups' work undone (the game crashed later, reading what they should have written); folding runs all of them.

A dispatch of more than 65 535 groups in X with 1 in Y now runs as 65 535 × ⌈n / 65 535⌉ groups. The console's count goes into a new io word, IO_GROUP_LIMIT (in the trap-temp range like IO_UMA_BASE_HI; 0 when not folded), and every translated compute program – the HLSL path and both direct translators (gpu::dxil and its per-lane form in recomp::lower) – takes gid.x + gid.y · 65 535 as its group in X when the word is set, 0 as its Y, and returns at once in the groups at or past the count. A dispatch that cannot be folded (two dimensions past the limit) is clamped and logged.

What is in it

  • Dispatch and console-recorded dispatches, whose counts the CPU knows: bind::fold (bind.rs, also used in console_list.rs).
  • ExecuteIndirect of one dispatch, whose counts only the GPU knows: a one-thread pass (clamp.rs) reads them, writes the counts to dispatch into a slot of XCL's buffer and the console's count into the dispatch's io; the dispatch then reads its arguments from the slot. bind_abi now returns what it bound (Bound), so rebind sets it again after the pass.
  • The program side: the compute prelude in recomp/emit.rs; the direct translator's compute entry (gpu/dxil/kernel.rs, compute_init, with a gate before the program for the groups past the count) and its per-lane form's (recomp/lower.rs, the groups past the count take its skip block); IO_GROUP_LIMIT / FOLD_X in recomp/mod.rs.
  • Tests: a folded dispatch runs each console group once and none past its count (GPU, recomp/tests.rs: the HLSL path, the direct translator in wave32, wave64 and split wave64, and the per-lane form; fails without the change from group 65 535 on), the indirect pass folds / clamps / leaves counts as they are (GPU, clamp.rs), the folding rule (unit, bind.rs). runner::device() gives tests the runner's device: a test that made its own device first left the Agility SDK unappliable for the process (0x887E0003), and the GPU tests after it skipped.

The translated compute HLSL and the direct translators' compute DXIL change (a few lines in the prelude / entry), so cached translations and DXIL of compute programs are made again once.

Tested

  • NVIDIA GeForce RTX 5060 Ti (driver 617.42, Agility SDK 1.620.2), Intel Core i7-14700K, Windows 10 22H2 (19045), Rust 1.100.0; tests in debug, smoke and game runs in release.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 on cf6cc59: 754 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware – no wave64 on this GPU). One run before that had vram::tests::d32s8_targets_take_their_own_size_of_video_memory fail with E_FAIL creating a resource; it passed 3 of 3 times alone, on this head and on main.
  • The new GPU test fails without the change (72512 groups folded into 65535 x 2, group 65535).
  • cf6cc59 (after @nnonno91's and @gut0to's reports): the indirect pass computes the row count without the addition that wrapped near 2^32 and folds only when it stays within 65 535, as bind::fold does. Its test covers 65 535², 65 535² + 1 and u32::MAX against bind::fold and fails on the previous shader.
  • Rebased onto main 9e3831e (conflict in bind_abi with the descriptor-heap binding of fe7d70b; both kept), head e29892e: cargo test --workspace -- --test-threads=4 779 passed, 0 failed, 41 ignored.
  • Rebased onto main 1d027e5 (conflict in execute_indirect with D3D12.X: an ExecuteIndirect reads the arguments written before it #1791's fresh_indirect_arguments; both kept: the fold pass first, then the ExecuteIndirect between D3D12.X: an ExecuteIndirect reads the arguments written before it #1791's transitions), head 280164a: cargo test --workspace --no-fail-fast -- --test-threads=4 962 passed, 0 failed, 43 ignored. In a first run vram::tests::d32s8_targets_take_their_own_size_of_video_memory failed once while the precompile held most of the video memory; it passed 3 of 3 times alone.
  • 7dbd80c (after @ivall's report that only the HLSL path undid the fold): the direct translators unfold too. main 1a0bbe3 merged in (no conflicts), head 7dbd80c, driver 621.40, DXC 1.9.2609.5: cargo test --workspace --no-fail-fast -- --test-threads=4 1248 passed, 5 failed, 46 ignored (SKIPPED GPU tests: the wave64 ones – no wave64 on this GPU – and two f16 per-lane cases the per-lane form refuses). The failures are fuzz_validate_and_gpu_0–_3 (0x8007000E creating the pipeline, the same seeds without this change) and vram::tests::d32s8_targets_take_their_own_size_of_video_memory (passed 3 of 3 times alone). With XCL_DIRECT_DXIL=all, cargo test -p xcl --lib gpu::: 628 passed, the same 4 fuzz tests failed, 22 ignored. The extended GPU test fails on the direct path without 7dbd80c.
  • The retail game: the GPU hang is gone in three runs (one with an earlier version that only clamped the counts, two with folding; they went on to 224, 166 and 157 s). They then stop at other places that this PR does not address; about a third of their dispatches were skipped while pipelines were still being built.

Regression run

main:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: NVIDIA GeForce RTX 5060 Ti
title: eccf25ce
seconds: 60
exit: 0x0
frames shown: 1542 (PresentX 1543)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17581 MB

PR:

xcl-smoke v1
commit: 7dbd80c275e4f1b03f5d0105e34e9e374e7b90a7
gpu: NVIDIA GeForce RTX 5060 Ti
title: eccf25ce
seconds: 60
exit: 0x0
frames shown: 1617 (PresentX 1617)
presents per 2 s (last 3): 34 60 60
device removals: 0
crashes: 0
peak commit: 17258 MB

The 60 s stay in the game's menus and loading screen, before the folded dispatches. The PR's first run after the build had 1136 frames and a peak commit of 26285 MB (its shader caches were made new for the changed translator sources); the block above is the run right after it, with no change in between.

Not tested

  • AMD GPUs (RDNA2 / RDNA4) and Intel GPUs: only the NVIDIA RTX 5060 Ti above.
  • The native wave64 forms of the direct translator and of the per-lane form on a GPU: this one runs no wave64, so the test leaves them out here.
  • Recompiler: split large direct compute pipelines at CFG edges #2080 (direct compute pipelines split at CFG edges, still open): it conflicts with this in kernel.rs and bind.rs, and its dispatch_chain would need to fold too; whichever lands second takes care of it.
  • Indirect dispatches with a count buffer or more than one dispatch (max > 1): they are left as they were.
  • Whether the folded dispatches compute what the console does in the game itself: the game stops for other reasons before that can be seen.
  • Other titles: no other title at hand dispatches more than 65 535 groups.

AI use

🤖 Generated with Claude Code

@lukastaro
lukastaro marked this pull request as ready for review November 24, 2026 15:55
@Aniseto

Aniseto commented Nov 24, 2026 •

Copy link
Copy Markdown

Ran the two new tests at e29892e (re-run after the head moved again; earlier runs were a902d3e and cf6cc59): Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_compute_folded_dispatch 1 passed; 0 failed; 0 ignored (exit 0) XCL_ADAPTER=nvidia cargo test -p xcl --lib indirect_group_counts_are_folded 1 passed; 0 failed; 0 ignored (exit 0) Both still pass on the new head: gpu_compute_folded_dispatch_runs_each_console_group_once runs a real folded dispatch on the GPU here and each console group runs exactly once, and indirect_group_counts_are_folded_or_clamped_on_the_gpu passes too. Not tested: a title that actually issues more than 65 535 groups in X (no unpacked title here), RDNA2/RDNA4 and Intel GPUs, Wine, release profile, native wave64. AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - built the PR's head commit from a clean tree and ran the tests on this machine; no local changes were made.
Update (25/11, after the head moved to 7dbd80c): re-ran the same two tests at the new head, which also unfolds a folded dispatch in the direct translators.

Environment unchanged: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_compute_folded_dispatch
1 passed; 0 failed; 0 ignored      (exit 0)

XCL_ADAPTER=nvidia cargo test -p xcl --lib indirect_group_counts_are_folded
1 passed; 0 failed; 0 ignored      (exit 0)

Both still pass on 7dbd80c. The PR is currently in conflict against main 1a0bbe3; this run is on the exact head commit in a detached worktree, not on a rebased tree.

Not tested (same gaps as above): a title that actually issues more than 65 535 groups in X, RDNA2/RDNA4 and Intel GPUs, Wine, release profile, native wave64.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the new head in a detached worktree, rebuilt, ran the tests, and updated this report; the worktree was not modified; no game data was used.

@DarkPanda69

DarkPanda69 commented Nov 24, 2026 •

Copy link
Copy Markdown

Update for head 7dbd80c: same result. Applied on main 1a0bbe3, gpu_compute_folded_dispatch_runs_each_console_group_once passes on the RX 9070 XT (native wave64) and the RTX 3060. Whole gpu:: filter: RX 9070 XT 630 passed, 2 failed (the #2115 fuzz seeds, same on main); RTX 3060 632 passed, 0 failed.


AMD run, which this PR lists as not tested. Updated for head 280164a (earlier runs on a902d3e, cf6cc59 and e29892e, same result).

Tested: pass, head 280164a applied on main 689f2db, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 262 passed, 0 failed, 18 ignored. gpu_compute_folded_dispatch_runs_each_console_group_once ok. The 6 SKIPPED lines (per-lane form refused for some f16/f32 programs) are the same on main.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 262 passed, 0 failed, 18 ignored. Same test ok; the SKIPPED lines are the same as on main.

On a902d3e, cargo test -p xcl --lib -- d3d12x --test-threads=4 also passed on both (145 passed, 0 failed, 1 ignored); not rerun since.

Not tested: RDNA2; the upper-boundary case from the review above beyond the PR's own tests; the whole workspace suite; a title.

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

@nnonno91

Copy link
Copy Markdown

Indirect dispatch fold disagrees with the CPU at the upper boundary

On a902d3e3e02e497d8d30b37cdccd89ba9585feb1, the existing fold tests pass on my RTX 5090, including the 72,512-group case. I extended indirect_group_counts_are_folded_or_clamped_on_the_gpu to compare the GPU setup pass’s readback with bind::fold for three additional X counts, with Y and Z both set to 1. The test reads the generated counts without submitting them as a dispatch.

Requested X CPU output (X, Y, Z) GPU output (X, Y, Z)
4,294,836,225 (65,535²) (65535, 65535, 1) (65535, 65535, 1)
4,294,836,226 (65535, 1, 1) (65535, 65536, 1)
4,294,967,295 (u32::MAX) (65535, 1, 1) (65535, 0, 1)

The shader in clamp.rs can produce a row count above the D3D12 limit, and the addition in its ceiling division wraps for u32::MAX. In a temporary local test I computed the ceiling using division and remainder, and kept the existing clamp path when the row count exceeded 65,535. The extended test then passed, including agreement on the stored fold limit.

Tested

  • RTX 5090 (driver 617.42), Ryzen 7 9800X3D, Windows 11 25H2 (26200.9974), Rust 1.100.0 MSVC, DXC 1.8.2502.11.
  • cargo test --locked -p xcl --lib indirect_group_counts_are_folded_or_clamped_on_the_gpu -- --nocapture --test-threads=1 on the temporary fixture. The PR shader failed the two out-of-range comparisons. The local correction passed all six cases.

Not tested

  • Retail-title behavior with the local correction.

AI use

  • OpenAI Codex (GPT-6, exact model variant unavailable) ran the tests and drafted this report.

@oz-stanislav-zhukov

oz-stanislav-zhukov commented Nov 24, 2026 •

Copy link
Copy Markdown

Test report from the retail game, GTA VI 1.0.2.1. With this PR applied, the world-loading GPU hang did not show up in one run; before it, the hang happened in both runs I had on the same machine. Correction (edited): the PR's per-dispatch report lines never appeared in that run, so I can't attribute the missing hang to it. See below.

Tested at a902d3e, cherry-picked onto main b7aa9f3 together with other open PRs (local branch, commit 5ab018c): #751, #688, #1123, #488, #789 (ported by hand onto the current sparse.rs), #1195, #1323, and two local xg CopyFromSubresource fixes. The only conflict was with #1323 in bind.rs / mod.rs, where I kept both: fold first, then the culprit markers around the dispatch.

Hardware: NVIDIA GeForce RTX 5060 Ti 16 GB, driver 621.24, Agility SDK 1.620.2. CPU i7-14700KF, 64 GB RAM, Windows 10 22H2 (19045). Rust 1.88.0, release build with line tables. Game runs used XCL_DRED=1 XCL_PSO_WAIT_MS=50 XCL_ACTIVITY=1; the run with this PR also had XCL_GPU_CULPRIT=1.

Before (main 930e8b4 + parts of the same stack, without #1195/#1428/#1323; two runs):

  • DXGI_ERROR_DEVICE_HUNG (0x887A0006) at 112 s and 183 s.
  • The D3D12.X: the GPU-wait watchdog says where a chain of waits ends #1123 wait chain ended at a queue that was executing (q4 end=signal in the first run, q2 end=signal in the second).
  • DRED breadcrumbs: one list was partly done (13 of 22 operations), its current operation an ExecuteIndirect between dispatches and barriers. All other lists had 0 operations done. The page fault was at VA 0x0.

With this PR (one run):

  • indirect dispatches past 65535 groups a dimension are folded or clamped on the GPU logged at 96 s. That line only says the pass was set up.
  • Neither … indirect dispatches folded so far nor … had group counts clamped so far was ever logged. As far as clamp::report saw, no dispatch was folded or clamped in this run.
  • No device removal and no GPU wait chain line for the whole run.
  • The run then ended in the game's own code, not on the GPU:
    • 0x80000003 at game_scarlett_master.exe+0x4da6315 (called from +0x9dff91) at 132 s;
    • then 0xc0000005 reading 0xffffffffffffffff at +0x50705fc at 147 s.
  • Since nothing was folded or clamped, these crashes are probably not caused by this PR. The missing hang may be run-to-run variation or a result of the other changes. One run is not enough to say.

Update, a second run with this PR (same build, no DRED; XCL_GPU_CULPRIT=1 XCL_PSO_WAIT_MS=50):

  • 1 indirect dispatches folded so far (the latest of 72604 groups in X) at 142 s. That is the same size as the counts in the description (72 512 / 75 072).
  • No device removal and no GPU wait chain line afterwards.
  • The run ended at 157 s, again in the game's 0x80000003 at +0x4da6315.
    • That check translates a resource's virtual pointer (the 0x50000000/0x60000000 bases) through the resource's map. The pointer it got was 0xae99cec5ab88357b, which is garbage, so the resource's contents were not what the game expected.
    • In these runs 8–14 thousand dispatches and ~30 thousand draws were skipped while pipelines were rebuilt: this PR changes the compute prelude, so the whole compute translation cache is made again. Before the change, the count was 861. Missing work is a likely cause, but I haven't shown it.
  • So: the fold did happen on the GPU at the point where the hang used to be, and the hang was not seen. The later crash is not shown to be caused by this PR.

Unit tests: cargo test --release -p xcl --lib -- sparse late_release bind culprit clamp --test-threads=4: 41 passed, 0 failed, 1 ignored. Three GPU tests printed SKIPPED with "no GPU" / "no GPU or DXC" in this run, including clamp::tests::indirect_group_counts_are_folded_or_clamped_on_the_gpu, so that test was not covered here.

Not tested:

AI use: run, log analysis and this report by Claude Code (Claude Opus 5.5); posted at the request of the person running the tests.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…in-place vtables

Integrates 16 upstream PRs (ivall#1380, ivall#1383, ivall#1384, ivall#1395, ivall#1398, ivall#1400,
ivall#1404, ivall#1405, ivall#1419, ivall#1420, ivall#1421, ivall#1423, ivall#1424, ivall#1427, ivall#1428, ivall#1429)
on top of the Linux/Proton fork, plus three Proton/vkd3d-proton fixes
caught during verification:
- Recompiler (ivall#1428): flatten IO_GROUP_LIMIT early-return in compute
  shaders so vkd3d-proton v3.1 dxil-spirv accepts the emitted CFG.
- D3D12.X (ivall#1395 + ivall#867): skip UnadoptGuard on in-place-patched vtables
  and restore native vtables in runner::submit_list when a prior test
  adopted the singleton ID3D12Device.
- Tests: match Wine centered default in window_position_modes.

Verified under GE-Proton11-14 (RX 9060 XT / RADV):
- gpu_sparse_vram_descriptors_buffers_and_xmem + gpu_valu_float_and_int
  + window_position_modes: 3 passed, 0 failed
- Broad sweep (present, real, sparse, clamp, dstorage, gpu_valu,
  gpu_typed_buffer): 82 passed, 0 failed, 1 ignored, 0 skipped
- 2.5 min retail title run (XCL_MEM_LIMIT=12G): 3,000+ frames at 30.0
  fps, 6.0-6.1 GB flat committed RAM, 6.4 GB local VRAM, 0 DS failures.
gut0to

This comment was marked as duplicate.

@lukastaro
lukastaro force-pushed the d3d12x-fold-large-dispatches branch from a902d3e to cf6cc59 Compare November 24, 2026 16:54
@lukastaro

Copy link
Copy Markdown
Author

Thanks @nnonno91 and @gut0to, fixed in cf6cc59 (folded into the one commit): the GPU pass now computes the row count without the addition that wrapped, and folds only when it stays within 65 535, as bind::fold does on the CPU; otherwise it clamps. The test covers 65 535², 65 535² + 1 and u32::MAX and checks each case against bind::fold; it fails on the previous shader.

Thanks also @Aniseto and @DarkPanda69 for the NVIDIA / AMD test runs, and @oz-stanislav-zhukov for the run on the title. Smoke run and the whole suite are redone on the new head (numbers in the description).

AI use: Claude Code (Claude Opus 5.5) wrote this.

@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, ~21 ignored.

Thanks!

@lukastaro
lukastaro force-pushed the d3d12x-fold-large-dispatches branch from cf6cc59 to e29892e Compare November 24, 2026 17:32
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…direct DXIL)

Brings in upstream xcl-dev#680 (descriptor-heap memory windows without per-access
switches, with switch fallback) and xcl-dev#1426 (direct RDNA2 -> DXIL backend
behind XCL_DIRECT_DXIL=1 / XCL_DIRECT_DXIL=all, bypassing HLSL and DXC).
Retains xcl-dev#1398 no-GVN retry, xcl-dev#1410 wave64 logging, and xcl-dev#1428 folded X
dispatch group limit alongside xcl-dev#680 and xcl-dev#1426.
@lukastaro

Copy link
Copy Markdown
Author

Added "Part of #505" to the description, since this PR is about a stop at the world load (#1833) and has no goal:world-load label yet. On #675, @qcdaark found that the hang there is a different one (the fold path runs on that card, the hang stays), so this PR does not name #675 as fixed.

AI use: Claude Code (Claude Opus 5.5) wrote this.

The console runs up to 2^32 - 1 thread groups a dimension; D3D12 takes
65 535, and past that a dispatch is undefined. On an NVIDIA RTX 5060 Ti a
retail game's world loading hung the GPU (DXGI_ERROR_DEVICE_HUNG,
0x887A0006) about 100 s in, every run: the only unfinished work was an
ExecuteIndirect of one loop-free compute program (found with the dispatch
markers of xcl-dev#1323), and its arguments, written by an earlier dispatch, were
72 512 x 1 x 1 and 75 072 x 1 x 1 groups.

A dispatch of more than 65 535 groups in X with 1 in Y now runs as
65 535 x ceil(n / 65 535) groups. The console's count goes into a new io
word (IO_GROUP_LIMIT, in the trap-temp range like IO_UMA_BASE_HI; 0 when
not folded), and every translated compute program takes
gid.x + gid.y * 65 535 as its group in X when the word is set, its Y as 0,
and returns at once in the groups at or past the count. A dispatch that
cannot be folded (two dimensions past the limit) is clamped and logged.

- Dispatch and console-recorded dispatches: the counts are known on the CPU
  (bind::fold, also in console_list).
- ExecuteIndirect of one dispatch: the counts are only on the GPU. A
  one-thread pass (clamp.rs) reads them, writes the counts to dispatch into
  a slot of XCL's buffer and the console's count into the dispatch's io
  (folding only when the rows stay within 65 535, as bind::fold does),
  then the dispatch reads its arguments from the slot. bind_abi now returns
  what it bound so the binding can be set again after the pass.

The translated compute HLSL changes (a few lines in the prelude), so
cached translations and DXIL of compute programs are made again once.

New tests: a folded dispatch runs each console group once and none past
its count (GPU; fails without the change from group 65 535 on), the
indirect pass folds / clamps / leaves counts as they are (GPU), and the
folding rule (unit). runner::device() gives tests the runner's device: a
test making its own device first left the Agility SDK unappliable and the
GPU tests after it skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

A gap I found while merging this for a test on AMD RDNA4: the fold is only undone on the HLSL path. IO_GROUP_LIMIT is read in gpu/recomp/emit.rs and nowhere under gpu/dxil (head 280164a); the direct translator takes the group id as the hardware gives it (gpu/dxil/kernel.rs, group_id). bind.rs and clamp.rs fold for every translated compute pipeline, so with XCL_DIRECT_DXIL=1 (and for the programs #2120 sends to the direct translator by default) a folded dispatch would run with the group ids of the folded grid instead of the console's. Before this change such a dispatch was clamped: groups were missing, but the ones that ran had the right ids.

What is needed: the same unfolding in the direct translator's group and thread ids, with a GPU test like gpu_compute_folded_dispatch on that path, or no fold for a pipeline built by it. This is from reading the code; I did not run a folded dispatch on the direct path.

It also conflicts in bind.rs with #2080 (two hunks, both easy).

Tested: 9633138 + #2245's test fix + #2180 + #2029 + #1782 + this, AMD RDNA4, Windows, DXC 1.8.2502.11, debug, cargo test --workspace --no-fail-fast -- --test-threads=4: 1250 passed, 3 failed, 46 ignored, 7 SKIPPED. The 3 failures are on main there too (fuzz_validate_and_gpu_1 and _3, #2115; gpu_image_get_resinfo_past_last_level). With XCL_DIRECT_DXIL=all, cargo test -p xcl --lib gpu::: 629 passed, the same 3 failed, 22 ignored.

AI use: Claude Code (Claude Opus 5.5) read the code, ran the tests and wrote this on the maintainer's behalf.

lukastaro and others added 2 commits November 25, 2026 13:34
`bind` and `clamp` fold a dispatch of more than 65 535 groups in X into Y for
every translated compute pipeline, but only the HLSL path took its group in X
back from both ids (`IO_GROUP_LIMIT`). The direct translator (`gpu::dxil`,
`compute_init`) and its per-lane form (`recomp::lower`) now do the same: the
group in X from both ids, Y 0, and the groups past the console's count leave
at once (a gate before the program; the per-lane form's skip block).

The folded-dispatch GPU test runs all three: HLSL, direct (wave32, wave64,
split wave64) and per-lane; the native wave64 forms only on a GPU that runs
wave64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukastaro

lukastaro commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

@ivall Thanks, you were right: the fold was only undone on the HLSL path. 7dbd80c adds the same unfolding to both direct translators: gpu::dxil (compute_init) and the per-lane form in recomp::lower. The groups past the console's count leave at once in both. The folded-dispatch GPU test now covers HLSL, direct (wave32, wave64, split wave64) and per-lane, and fails on the direct path without the fix. Current main is merged in. The #2080 overlap and the test numbers are in the description.

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

@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

The direct path's unfold is written and tested; it goes in with this PR. On main 1a0bbe3 merged with 280164a, plus a commit that adds the unfold to the direct translator (both the compact form and the per-lane form, kernel.rs unfold_groups / start):

Not merged yet: it changes the DXIL of every compute program, and I want a title run of the tree first.

AI use: Claude Code (Claude Opus 5.5) wrote the commit, ran the tests and wrote this on the maintainer's behalf.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

For comparison, two other designs of this fix, in case cases are worth borrowing:

Cases that might be worth a test here: x > 65,535 with y > 1 (clamped now), the same pipeline used by a direct and then an indirect dispatch, and a side-effect-only program whose padding groups must not write. Read from the PR texts and this diff only.

AI-assisted (Claude Code).

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants