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

Open
github-bot wants to merge 3 commits from github-bot/gh-1428 into main AGit
Owner

@⁠lukastaro on GitHub · 2026-11-24 15:51 UTC · original
lukastaro:d3d12x-fold-large-dispatches → main · +540 −32 · 10 files · 3 commits · open

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 #1791's fresh_indirect_arguments; both kept: the fold pass first, then the ExecuteIndirect between #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.
  • #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

  • Claude Code (Claude Opus 5.5): found the hang with the dispatch markers of #1323 and the logs, wrote the change, the tests and this description; the runs above were made on the hardware named.

🤖 Generated with Claude Code

**@⁠lukastaro** on GitHub · 2026-11-24 15:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428) `lukastaro:d3d12x-fold-large-dispatches` → `main` · +540 −32 · 10 files · 3 commits · open 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 #1791's `fresh_indirect_arguments`; both kept: the fold pass first, then the ExecuteIndirect between #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. - #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** - Claude Code (Claude Opus 5.5): found the hang with the dispatch markers of #1323 and the logs, wrote the change, the tests and this description; the runs above were made on the hardware named. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 #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 <[email protected]>
`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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:33 +00:00
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-24 16:05 UTC · original

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.
**@⁠nnonno91** on GitHub · 2026-11-24 16:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7137091954) ### 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.
Author
Owner

@⁠oz-stanislav-zhukov on GitHub · 2026-11-24 16:12 UTC · original · edited 2026-11-24 16:47 UTC

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 #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:

  • the full workspace suite;
  • scripts/smoke.ps1;
  • whether this PR alone, without the rest of the stack, removes the hang;
  • other GPUs.
    The before and after runs differ in more than this PR: main moved from 930e8b4 to b7aa9f3, and #1195/#1323 were added. #1195's skip message never appeared either.

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.

**@⁠oz-stanislav-zhukov** on GitHub · 2026-11-24 16:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7137292222) · edited 2026-11-24 16:47 UTC 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 #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:** - the full workspace suite; - `scripts/smoke.ps1`; - whether this PR alone, without the rest of the stack, removes the hang; - other GPUs. The before and after runs differ in more than this PR: `main` moved from 930e8b4 to b7aa9f3, and #1195/#1323 were added. #1195's skip message never appeared either. **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.
Author
Owner

@⁠lukastaro on GitHub · 2026-11-24 16:54 UTC · original

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.

**@⁠lukastaro** on GitHub · 2026-11-24 16:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7138391134) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 17:21 UTC · original

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

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

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 17:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7139072341) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Author
Owner

@⁠lukastaro on GitHub · 2026-11-24 22:00 UTC · original

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.

**@⁠lukastaro** on GitHub · 2026-11-24 22:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7145678916) 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.
Author
Owner

@⁠ivall on GitHub · 2026-11-25 11:35 UTC · original

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.

**@⁠ivall** on GitHub · 2026-11-25 11:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7161245739) 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.
Author
Owner

@⁠lukastaro on GitHub · 2026-11-25 12:54 UTC · original · edited 2026-11-25 12:55 UTC

@⁠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.

**@⁠lukastaro** on GitHub · 2026-11-25 12:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7163014633) · edited 2026-11-25 12:55 UTC @⁠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.
Author
Owner

@⁠ivall on GitHub · 2026-11-25 13:05 UTC · original

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):

  • gpu_compute_folded_dispatch_runs_each_console_group_once now runs the HLSL and the direct program, 65 536 and 72 512 groups, wave32 and wave64: pass on AMD RDNA4.
  • Whole suite with #2080 / #2107 / #2126 merged on top: 1260 passed, 2 failed (#2115, as on main), 46 ignored.
  • With a split program (#2080) the group past the count returns in the first piece and writes tag 0, so later pieces skip its lanes.

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.

**@⁠ivall** on GitHub · 2026-11-25 13:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7163271839) **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`): - `gpu_compute_folded_dispatch_runs_each_console_group_once` now runs the HLSL and the direct program, 65 536 and 72 512 groups, wave32 and wave64: pass on AMD RDNA4. - Whole suite with #2080 / #2107 / #2126 merged on top: 1260 passed, 2 failed (#2115, as on `main`), 46 ignored. - With a split program (#2080) the group past the count returns in the first piece and writes tag 0, so later pieces skip its lanes. 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.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-24 16:02 UTC · original · edited 2026-11-25 13:27 UTC

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.

**@⁠DarkPanda69** on GitHub · 2026-11-24 16:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7137024329) · edited 2026-11-25 13:27 UTC **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.
Author
Owner

@⁠Aniseto on GitHub · 2026-11-24 16:00 UTC · original · edited 2026-11-25 14:11 UTC

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.

**@⁠Aniseto** on GitHub · 2026-11-24 16:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7136971707) · edited 2026-11-25 14:11 UTC 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.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 15:02 UTC · original

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

  • Marvisak/VIctory#2312 (Xvania7) spreads x > 65,535 into Z when z == 1, for direct Dispatch and ExecuteIndirect. That covers x > 65,535 with y > 1, which this PR clamps (bind.rs, "any other count past 65 535 is clamped (logged once)"). The shader returns before its body when eff_x >= asked_x, so padding groups do nothing even in side-effect-only programs. Its indirect test checks records such as 115,200 × 1 × 1 → [57600, 115200, 57600, 1, 2].
  • shadps4-emu/shadPS4#5479 reshapes indirect dispatches on the GPU in a prologue, up to UINT32_MAX groups. It skips the padding groups and keys the pipeline cache so the direct and indirect variants stay apart. That PR reports a cost of about 4 µs per indirect dispatch on an RTX 4060.

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).

**@⁠upipibi** on GitHub · 2026-11-25 15:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7166209161) For comparison, two other designs of this fix, in case cases are worth borrowing: - **Marvisak/VIctory#2312** (Xvania7) spreads x > 65,535 into **Z** when z == 1, for direct `Dispatch` and `ExecuteIndirect`. That covers x > 65,535 with y > 1, which this PR clamps (`bind.rs`, "any other count past 65 535 is clamped (logged once)"). The shader returns before its body when `eff_x >= asked_x`, so padding groups do nothing even in side-effect-only programs. Its indirect test checks records such as 115,200 × 1 × 1 → [57600, 115200, 57600, 1, 2]. - **shadps4-emu/shadPS4#5479** reshapes indirect dispatches on the GPU in a prologue, up to UINT32_MAX groups. It skips the padding groups and keys the pipeline cache so the direct and indirect variants stay apart. That PR reports a cost of about 4 µs per indirect dispatch on an RTX 4060. 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).
Author
Owner

@⁠lucsoft on GitHub · 2026-11-25 19:27 UTC · original

Test report: Linux / RADV, RX 7800 XT (RDNA3). Head 7dbd80c, in a stack, not alone. Folding is required on this card for the title to get past world loading.

  • Setup: Mesa 26.3.1 RADV, kernel 7.3.5, Wine 11.21 Staging, vkd3d-proton 3.1. XCL main 50a9fde plus about 20 other PRs. The full list is in #505. #2205's culprit markers sit around the folded dispatch.
  • What this PR did:
    D3D12.X: indirect dispatches past 65535 groups a dimension are folded or clamped on the GPU
    D3D12.X: 829 indirect dispatches folded so far (the latest of 115200 groups in X)
    
    All 829 were folds of 115 200 groups in X, over a 2500 s run.
  • Before / after, same card, earlier stack on 568e7db: without this PR every run hung at about 131 000 dispatches. With it, runs went to 262 000–301 000 dispatches before an unrelated hang. With the current stack, runs pass 2 000 000 dispatches and reach gameplay, with no GPU-wait timeouts.
  • Not tested: without the rest of the stack, or the unit tests (I only build the Windows exe).

AI use: Claude Code (Claude Opus 5.5) ran the analysis and drafted this. The runs were real, on the hardware above.

**@⁠lucsoft** on GitHub · 2026-11-25 19:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7172334635) **Test report: Linux / RADV, RX 7800 XT (RDNA3). Head `7dbd80c`, in a stack, not alone.** Folding is required on this card for the title to get past world loading. - **Setup:** Mesa 26.3.1 RADV, kernel 7.3.5, Wine 11.21 Staging, vkd3d-proton 3.1. XCL `main` `50a9fde` plus about 20 other PRs. The full list is in https://git.gtahub.st/github/xcl-dev--xcl/issues/505. #2205's culprit markers sit around the folded dispatch. - **What this PR did:** ``` D3D12.X: indirect dispatches past 65535 groups a dimension are folded or clamped on the GPU D3D12.X: 829 indirect dispatches folded so far (the latest of 115200 groups in X) ``` All 829 were folds of 115 200 groups in X, over a 2500 s run. - **Before / after, same card, earlier stack on `568e7db`:** without this PR every run hung at about 131 000 dispatches. With it, runs went to 262 000–301 000 dispatches before an unrelated hang. With the current stack, runs pass 2 000 000 dispatches and reach gameplay, with no GPU-wait timeouts. - **Not tested:** without the rest of the stack, or the unit tests (I only build the Windows exe). AI use: Claude Code (Claude Opus 5.5) ran the analysis and drafted this. The runs were real, on the hardware above.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 05:13 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#issuecomment-7183289339) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
Author
Owner

@⁠gut0to on GitHub · 2026-11-24 16:22 UTC · original · reviewed

At g.x == UINT_MAX, g.x + 65534u wraps to 65533, so the quotient becomes 0 and the folded indirect dispatch runs no groups in Y. Please use overflow-safe ceiling division and add a UINT_MAX case to the GPU clamp test. AI-assisted review; I checked the arithmetic against the limit documented in this PR.

**@⁠gut0to** on GitHub · 2026-11-24 16:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1428#pullrequestreview-6043158058) · **reviewed** At g.x == UINT_MAX, g.x + 65534u wraps to 65533, so the quotient becomes 0 and the folded indirect dispatch runs no groups in Y. Please use overflow-safe ceiling division and add a UINT_MAX case to the GPU clamp test. AI-assisted review; I checked the arithmetic against the limit documented in this PR.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/dxil/kernel.rs
  • crates/xcl/src/hle/d3d12x/bind.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1428/head:github-bot/gh-1428'
git switch 'github-bot/gh-1428'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1428'
git switch 'github-bot/gh-1428'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1428'
git switch 'github-bot/gh-1428'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1428'
git switch 'main'
git merge --squash 'github-bot/gh-1428'
git switch 'main'
git merge --ff-only 'github-bot/gh-1428'
git switch 'main'
git merge 'github-bot/gh-1428'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.