Skip to content

D3D12.X: two-pass indirect commands with groups D3D12 forbids run nothing - #3056

Open
Kalmarv wants to merge 1 commit into
xcl-dev:nvidia-devfrom
Kalmarv:hulk/nvd-mesh-limits
Open

Kalmarv wants to merge 1 commit into
xcl-dev:nvidia-devfrom
Kalmarv:hulk/nvd-mesh-limits

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Under two-pass mesh deferral (XCL_TWO_PASS_BATCH=2), the pass that rewrites an ExecuteIndirect's arguments (SCALE_ARGS_HLSL) clamped every command's groups to the record cap. So a command whose groups D3D12 does not allow for DispatchMesh (a dimension over 65,535, or over 2^22 in all) still ran cap groups of the compute pass and cap × split mesh groups, over records nothing wrote. Such words are not a count the title can mean; those commands now run no groups in either pass. Legal counts run exactly as before.

This changes one internal shader, not the translated-program cache, so it stands alone. It does not claim to be the cause of any hang: counts D3D12 forbids are simply not run.

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs: SCALE_ARGS_HLSL gives a command 0 groups when x, y or z > 65,535 or x·y·z > 2^22 (x·y fits 32 bits after the per-dimension test; z is tested against 2^22 / (x·y), so no product overflows).
  • New GPU test gpu_indirect_two_pass_counts_d3d12_forbids_are_not_run: 11 commands (cap 1000, split 2), each over-limit form runs 0 groups in both passes, the limits themselves (65,535 × 64, 2^22 exactly) and small counts run in full.
  • gpu_indirect_two_pass_groups_go_in_x: its case of 70,000 per dimension is now a legal 60,000 × 60 × 1 (same expectations), since 70,000 is now rejected.

Tested

  • NVIDIA GeForce RTX 5070 Ti, driver 610.74, Windows 11 Pro 26200, rustc 1.99.0, debug build for the suite, release build for the smoke.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 9cb1927: 1825 passed, 8 failed, 48 ignored, 26 SKIPPED lines (mostly "no wave64" on this adapter). The 8 failures are 6 tests (two fail twice), all of which also fail on nvidia-dev a5e2d85 on this machine (it has two test-title failures more), none in the code changed here: async_compute_pso_registers_real_pso_and_not_standin, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, gpu_parts_of_a_texture_go_up_and_the_rest_stays, pieces_hold_the_texels_of_their_levels, split_compute_prefers_the_offline_whole_pipeline, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.
  • cargo test -p xcl --lib gpu_indirect_two_pass: 4 passed, 0 failed (the new test and the three that were there).

Regression run
150 s each, same title, same environment (XCL_DIRECT_DXIL=all, heap windows, DRED on), on a copy of the same warmed translated-program cache. The head run ran beside a cargo test of the workspace, and its startup took about 28 s longer, so it had fewer of the fast menu frames than a run of nvidia-dev a5e2d85 alone in the same setup (2,464 frames). It reaches the changed pass: its log counts more than 8,192 two-pass ExecuteIndirects (#8192 at 198 s; the log names them at powers of two).

main (b49be18):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1917 (PresentX 1917)
presents per 2 s (last 3): 0 0 2
device removals: 0
crashes: 0
peak commit: 33080 MB

This PR's head (9cb1927):

xcl-smoke v1
commit: 9cb19274369e86c1dffa01e2f75f5a4a8a9d2ee6
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1943 (PresentX 1943)
presents per 2 s (last 3): 1 0 1
device removals: 0
crashes: 0
peak commit: 38108 MB

Not tested

  • Whether the title hands this pass a count D3D12 forbids in these runs: nothing counts the rejected commands. This PR does not claim to fix any hang.
  • AMD; XCL_TWO_PASS_BATCH=2 in a long world run (the smoke uses the default mode); the suite on d1be810 itself (the base run named above is the older nvidia-dev commit a5e2d85).

AI use

  • Claude Code, Claude Opus 5.5: wrote the change, the test and this description, ran the tests and the smoke.

🤖 Generated with Claude Code

…hing

The pass that rewrites a two-pass ExecuteIndirect's arguments clamped each
command's groups to the record cap, so a command whose groups D3D12 does
not allow for DispatchMesh (a dimension over 65,535, or over 2^22 in all)
still ran cap groups of the compute pass and cap x split mesh groups, over
records nothing wrote. Such words are not a count the title can mean.
Those commands now get no groups in either pass; legal counts are
unchanged.

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

Copy link
Copy Markdown

AMD run (listed as untested), with an RTX 3060 in the same PC: the new GPU test passes on both.

Tested: pass, head 9cb1927 applied on its base nvidia-dev d1be810, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, card picked with XCL_ADAPTER (Radeon / 3060; the existing pooled-scratch test logs POOLED_SCRATCH_ADAPTER= with the right card each time, but I didn't check which device helper the new test uses).
cargo test -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4 --nocapture, 3 runs each:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: 62 passed, 0 failed, 3 of 3 runs; nvidia-dev alone 61 passed.
  • NVIDIA RTX 3060, driver 32.0.16.1088: the same, 3 of 3.

The only result change on both cards is gpu_indirect_two_pass_counts_d3d12_forbids_are_not_run, ok. SKIPPED is the same with and without the PR: two_pass_binds_set_the_shared_view_heap (no heap windows).

Not tested: a world run with XCL_TWO_PASS_BATCH=2, Intel, release.

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

Kalmarv added a commit to Kalmarv/xcl that referenced this pull request Nov 27, 2026
xcl-dev#2630, xcl-dev#1663, xcl-dev#2549, xcl-dev#2759, xcl-dev#3056 guard, uma_driver test lock)

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

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 9cb1927

@akimfomin

Copy link
Copy Markdown

PortBridge confirmed the 9cb1927 conflict with current nvidia-dev ba9d1f9 in crates/xcl/src/hle/d3d12x/bind.rs. The 25,000-input CPU model comparison of the dimension/product guard matched a wide-integer reference. Continued #2523 suggests one different control for the rebased GPU fixture: put a rejected dispatch between two live ones and verify both live commands keep their identities, and the rejected one neither runs nor advances the next live slot. That complements the existing zero-group checks.

Exact comparisons and controls. If this workflow is useful, your team or agent can send the next public PR URL, target SHA, and behavior to preserve via PortBridge #98. No install is needed.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: f8de0bf (nvidia-dev at the time of the run; the branch has moved to ba9d1f9 since and GitHub now shows this PR as conflicting)
head: 9cb1927
merge: clean on f8de0bf; conflicts on the current branch head
build: cargo build --workspace -> ok (on f8de0bf)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1834 passed, 8 failed, 48 ignored (27 SKIPPED lines); the 8 failures are the base's own on this GPU, the same six names with and without the PR
review: the arithmetic is right (the product cannot overflow after the per-dimension check) and the new test's expectations check out; it fails without the change. Two things to fix or decide: (1) the description says the change applies with XCL_TWO_PASS_BATCH=2 only, but the scaling shader it changes runs for every indirect two-pass ExecuteIndirect (make_scaled_args_buffer); (2) behaviour: before, a command with a group count D3D12 forbids was clamped to the cap in both passes; now it draws nothing. For a garbage count that removes stray work; for a count the console would honour it removes geometry that used to be drawn in part. I could not check the console's limits.
performance: a few ALU operations per command; the internal shader compiles once more (reasoned).
verdict: not yet: rebase on the current nvidia-dev (conflict) and correct the description; then I will rerun.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants