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:mainfrom
Kalmarv:hulk/nvd-mesh-limits
Open

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

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

For every indirect two-pass ExecuteIndirect (make_scaled_args_buffer), 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, and reported an uncapped raw_n to GPU feedback. Such words are not a count the title can mean; those commands now run no groups in either pass (raw_n = 0, n = 0). 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 (and raw_n = 0) 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 (including a rejected command between live commands 7 and 9 preserving their identities).
  • 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

  • Rebased head 3edfb048 on main 227d2cb3 (NVIDIA GeForce RTX 5070 Ti, driver 610.74, Windows 11 Pro 26200, DXC 1.9.2609.5, debug):
    • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 2,596 passed, 0 failed, 49 ignored across all 41 test binaries, 26 SKIPPED:
      • 21 no wave64 (RTX 5070 Ti is wave32 hardware: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, 4 recomp::lower wave64 tests, 14 recomp::lower_dxil wave64 tests, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware)
      • 3 per-lane wave32 refusals for #1426 semantics (f16_programs_on_the_gpu arithmetic/packed, f32_programs_on_the_gpu conversions)
      • 2 no heap windows (opt-in: XCL_HEAP_WINDOWS=1) (two_pass_binds_set_the_shared_view_heap, heap_window_out_of_memory_falls_back_to_the_switch_form)
    • Targeted GPU tests (gpu_indirect_two_pass: 4/4 passed, 0 skipped; gpu_scale_args_reports_uncapped_group_count_feedback: 1/1 passed, 0 skipped) also passed under Windows SDK DXC 1.7.2308.
  • Earlier head 9cb19274 (pre-rebase on nvidia-dev): DarkPanda69 ran 9cb19274 on AMD RX 9070 XT and NVIDIA RTX 3060 (62/62 passed, 3 of 3 runs each).

Regression run
Paired 150 s retail smoke runs on RTX 5070 Ti (warm PC-SBM cache, XCL_UMA_WINDOWS=16, XCL_HEAP_WINDOWS=1, XCL_DRED=1, XCL_DIRECT_DXIL=all, XCL_DIRECT_SPLIT_INSTRUCTIONS=0, DXC 1.9.2609.5, XCL_PSO_JOURNAL=0). main exited 0x0 with a 0 B minidump (crashes: 1); head 3edfb048 exited 0x0 with 0 crashes and 0 device removals.

main (227d2cb3):

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 2914 (PresentX 2914)
presents per 2 s (last 3): 44 40 12
device removals: 0
crashes: 1
peak commit: 32755 MB

PR head (3edfb048):

xcl-smoke v1
commit: 3edfb048d811e3e00d3fc864114e835723f399d8
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 3550 (PresentX 3550)
presents per 2 s (last 3): 49 15 0
device removals: 0
crashes: 0
peak commit: 33626 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.
  • Native wave64 hardware (AMD) on rebased head 3edfb048; Intel; Wine; opt-in XCL_HEAP_WINDOWS=1 unit tests.

AI use

  • Claude Code (Claude Opus 5.5): wrote the original change, test, and pre-rebase runs (9cb19274).
  • Antigravity (Gemini 4 Neon): rebased onto main (227d2cb3 -> 3edfb048), kept illegal counts at raw_n = 0 for the GPU feedback path, ran the full workspace test suite and paired 150 s retail smoke on 3edfb048, and updated this description.

@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
Contributor

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

…hing

The pass that rewrites a two-pass ExecuteIndirect's arguments (SCALE_ARGS_HLSL) 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, and reported raw_n to GPU feedback. Such words are not a count the title can mean. Those commands now get no groups in either pass (and raw_n = 0); legal counts are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Antigravity (Gemini 4 Neon)
@Kalmarv
Kalmarv force-pushed the hulk/nvd-mesh-limits branch from 9cb1927 to 3edfb04 Compare November 28, 2026 23:28
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@Kalmarv

Kalmarv commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (227d2cb3 -> 3edfb048) after the #3203 merge and updated the description per @throny's review (applies to every indirect two-pass ExecuteIndirect through make_scaled_args_buffer, not just XCL_TWO_PASS_BATCH=2). On main's GPU feedback path (9ae803e3), illegal counts also stay at raw_n = 0 so they do not report bogus uncapped counts.

Targeted GPU tests on 3edfb048 (RTX 5070 Ti, debug, Windows SDK DXC 1.7.2308):

  • gpu_indirect_two_pass: 4 passed, 0 failed, 0 ignored, 0 skipped
  • gpu_scale_args_reports_uncapped_group_count_feedback: 1 passed, 0 failed, 0 ignored, 0 skipped

Not run yet on 3edfb048: full workspace suite and refreshed exact-head smoke pair.

AI use: Antigravity (Gemini 4 Neon) rebased the branch, ran the targeted GPU tests, updated the PR body, and posted this comment.

@Kalmarv

Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Updated PR description with full workspace test suite and paired exact-head 150 s retail smoke on 3edfb048 (RTX 5070 Ti, DXC 1.9.2609.5):

  • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 2,596 passed, 0 failed, 49 ignored, 26 SKIPPED (21 no wave64, 3 #1426 per-lane refusals, 2 no heap windows).
  • 150 s smoke (ea3b5e4d): main 227d2cb3 = 2,914 frames / 32,755 MB peak commit vs head 3edfb048 = 3,550 frames / 33,626 MB peak commit, 0 crashes, 0 device removals.
  • Local scripts/pr_check.py --local: description ok.

AI use: Antigravity (Gemini 4 Neon) ran the workspace test suite and paired smoke, updated the PR body, and posted this comment.

@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 3edfb04

Re-check of the head rebased onto main.

@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: fa20459
head: 3edfb04
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2609 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at fa20459: 2608 passed, 0 failed, 49 ignored.
review: re-check of the rebased head. Both points of my earlier check are answered: the description now names every indirect two-pass ExecuteIndirect through the scaling pass, and the conflict is gone. The code sits on main's feedback shader now: counts that are not legal give a raw count of 0, otherwise the product, which cannot overflow after the per-dimension check; such a command reports the value the existing code already treats as culled. One decision stays with the maintainers and is not a defect: forbidden group counts used to be clamped and now draw nothing, on the argument that such words cannot be a count; nobody has checked the console's limits.
performance: none. No translator source.
verdict: safe to merge
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).

@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run of head 3edfb048, on its own base 227d2cb and merged with current main 53e85fb1, to go with the reports above by throny, since none of them covers AMD. Nothing here fails because of this PR. On the Radeon the lib test binary stops partway on this base and on main alike (#3488), so the AMD runs are partial. The bare-head runs come first.

Tested

Not tested

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@AAsobu

AAsobu commented Nov 30, 2026

Copy link
Copy Markdown

merge-check claim
head: 3edfb04

@AAsobu

AAsobu commented Nov 30, 2026

Copy link
Copy Markdown

merge-check
base: ff0c364
head: 3edfb04
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps); failing: none. In the full run the gpu_compute_e2e binary hung (4 tests "running for over 60 seconds", one thread waiting on a compute pipeline still being built, GPU idle) and I killed it after ~5 min; rerun alone on the same tree it passed 9/9 twice (5-6 s). Those tests do not use SCALE_ARGS_HLSL, and the same binary passed in my earlier runs of other PRs on this machine, so I count it as an intermittent hang, not this PR's; the counts above use the rerun for that binary.
review: none. Read the whole diff (+33/-7, crates/xcl/src/hle/d3d12x/bind.rs): the legality test cannot overflow (x, y <= 65,535 so xy fits 32 bits; z is compared with 2^22 / (xy), guarded for 0), legal counts give the same raw_n/n as before, and the removed saturating product is no longer needed because a legal product is at most 2^22. The new test's expectations match those limits (40961025 and 204820482 rejected, 65,53564 and 64641024 kept). gpu_indirect_two_pass_counts_d3d12_forbids_are_not_run and the existing gpu_indirect_two_pass_* tests pass here.
performance: by default only a few more integer compares per command in the args pass; nothing measurable expected. Retail title on this machine (one run, release, XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1, warm caches): loading normally (up to 1761 draws / 3756 dispatches per 2 s at 120 s), then a device removal (0x887a0005) at 250 s during a pipeline-build stall, DRED page fault at GPU VA 0x0, allocations [], device state 0, no breadcrumbs; system commit 53.8 of 66.2 GB. The last 24 recorded operations were all plain compute Dispatch, no two-pass work. This is not this PR's: main alone (abec7ce9) was removed the same way at 188 s, and main ff0c364b + #3052 at 816 s and 300 s. On this machine every tree after d52ff48c has had this removal (5 of 5 runs), while d52ff48c ran ~10 min in the world without it (one run only), so #1355 / #1221 (merged in between) may be worth a look for #2920.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), results checked by me

@AAsobu

AAsobu commented Dec 1, 2026 •

Copy link
Copy Markdown

Correction to my report above, about the device removal it mentions (0x887a0005, DRED "page fault at GPU VA 0x0", no breadcrumbs): on this machine it was most likely NVIDIA's 512 MB shader-heap limit (#2403), not a bug of main and not a regression range.

Hardware: NVIDIA GeForce RTX 3090 24 GB (driver 621.24), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300. Tool and model: Claude Code (Claude Opus 5.5), results checked by me.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 7d86c5d
head: 3edfb04
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2897 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (bind.rs). An indirect two-pass DispatchMesh command with a dimension over 65,535 or more than 2^22 groups in all used to run cap groups and now runs none; legal counts behave as before. Findings: (1) rejected commands are never counted or logged: indirect_guard reports the counts it zeroes, but this check (~3141 after the merge) is silent, so missing geometry wouldn't show in any log; and the 2^22 limit is hard-coded instead of indirect_guard::max_groups() (XCL_INDIRECT_MAX_GROUPS). (2) A direct two-pass dispatch_mesh (~3411) still runs the same counts, cut to the record buffer, so direct and indirect calls now disagree. (3) The description says the mesh pass ran "over records nothing wrote", but the compute pass runs the same n groups the mesh pass reads (dst.Store3(d + offset, n)), so those records were written; nothing shows what the console does with such counts. (4) The PR's smoke runs used non-default settings (XCL_HEAP_WINDOWS=1, XCL_DIRECT_DXIL=all, ...). The PR's CI failures (four pipeline_library / warm_library tests, a race since fixed on main) don't appear in the run above. Fine: the check can't overflow (x*y fits in 32 bits; z is compared by division), the new GPU test fails without the fix and skips without a GPU, the deferred path (defer_execute_indirect) uses the same shader, and #3504's split indirect path still uses this rewrite with no code overlap.
performance: 60 s smoke of a retail title, main 7d86c5d vs this merge (4347565e): 1663 -> 1669 frames shown (100 %; last presents per 2 s: 60 60 61), peak commit 17153 -> 17082 MB, 0 device removals, 0 crashes.
verdict: not yet: dropped commands are never counted or logged, direct and indirect dispatch_mesh now disagree on the same counts, and the stated rationale (records nothing wrote) doesn't match the code
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants