Skip to content

D3D12.X: clean up indirect_guard state on ExecuteIndirect skip paths - #3401

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/execute-indirect-guard-cleanup
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/execute-indirect-guard-cleanup

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

What changed

  • In crates/xcl/src/hle/d3d12x/bind.rs (execute_indirect_snapshot):
    • Resolve compute whole-program fallbacks (real::pso_dispatch_remap_exact -> remap_fallback::whole_exact and dispatch_chain::whole_ready) before running indirect_guard::check and bind_abi_resolved, so late (Whole::Late) or failed whole-program builds skip the indirect dispatch without dispatching the guard, leaving indirect_guard's shared output buffer in UNORDERED_ACCESS, or mutating the command list's root signature and pipeline state.
    • On bind_abi_resolved error when indirect_guard::check ran (checked.is_some()), transition indirect_guard's shared output buffer back to COMMON via c.read(this) and restore the command list's resolved native pipeline via real::bind_pipeline_exact(this, raw_pso, pso) instead of leaving indirect_guard's internal compute PSO bound.
  • Added unit and GPU regression tests in crates/xcl/src/hle/d3d12x/bind.rs:
    • execute_indirect_remap_fallback_error_skips_before_guard_and_abi (CPU test): verifies whole-program fallback error skips before bind_abi_resolved and records no dispatch/pipeline/indirect calls.
    • gpu_execute_indirect_guard_cleanup_on_abi_error_and_whole_skip (capability-guarded D3D12 GPU test): verifies on a real adopted compute command list that (1) a whole-program fallback skip preserves the title's bound root signature and PSO for a subsequent dispatch, and (2) an ABI-bind error after indirect_guard::check restores both the title's PSO and indirect_guard's shared output buffer state (COMMON) so subsequent commands and checked indirect dispatches on a second list in the same submit execute cleanly.

Why

Previously, execute_indirect_snapshot ran indirect_guard::check (which promotes indirect_guard's shared out buffer to UNORDERED_ACCESS, binds its own compute root signature and PSO, and dispatches the guard) and bind_abi_resolved before checking whether a split or dispatch-remapped compute pipeline's whole form was ready or buildable, and returned early on Whole::Late or whole-build / ABI-bind failure without calling c.read(this) or restoring the command list's pipeline state. That left indirect_guard's shared buffer stuck in UNORDERED_ACCESS (violating its COMMON-between-uses invariant across later lists in the same submit) and left indirect_guard's internal compute PSO bound on the command list after an ABI-bind skip.

Tested

Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), rustc 1.99.0, DXC 1.9.2609.5 (XCL_DXC_DIR).

  • cargo check --workspace --all-targets: passed (0 errors, 0 new warnings).
  • cargo test -p xcl --lib -- execute_indirect_remap_fallback_error_skips_before_guard_and_abi gpu_execute_indirect_guard_cleanup_on_abi_error_and_whole_skip hle::d3d12x::indirect_guard::tests:: --test-threads=1: 6 passed, 0 failed, 0 ignored.
  • cargo build --workspace and cargo test --workspace -- --test-threads=4: all workspace unit, e2e (D3D12 debug layer + DRED), and tiling tests passed (exit 0).
  • 150 s real-title smoke at PR head (f59aa43937d0669c23fa33b34312d4986d8cfeb4):
xcl-smoke v1
commit: f59aa43937d0669c23fa33b34312d4986d8cfeb4
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33926 MB
  • Ancestor main baseline (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):
xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB

Not tested

  • AMD or Intel GPUs (tested on NVIDIA RTX 5070 Ti only).
  • Bundles (which bypass indirect_guard::check because tracked_list_type is not DIRECT or COMPUTE).

AI use

Written and verified with an AI coding assistant (Antigravity); all code, tests, workspace runs, and smoke results were directly reviewed and executed on local hardware.

@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 29, 2026
@saintwolf

Copy link
Copy Markdown
Contributor

Reviewed and tested at f59aa439.

Code review findings

  • Moving remap_fallback::whole_exact and dispatch_chain::whole_ready ahead of indirect_guard::check and bind_abi_resolved is a clean improvement.
  • Compute root signature left clobbered on bind_abi_resolved error (crates/xcl/src/hle/d3d12x/bind.rs): indirect_guard::check binds both its own internal compute root signature and its own compute pipeline. In the Err(e) cleanup block, c.read(this) returns g.out to COMMON and bind_pipeline_exact(this, raw_pso, pso) restores the pipeline, but the list's compute root signature is never restored (note that step 2 of the new GPU test had to manually re-call list2.SetComputeRootSignature(&rs) before dispatching). Any subsequent compute Dispatch on the same command list relying on its previously bound compute root signature will execute with indirect_guard's root signature still bound.

Tested locally

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0.
  • cargo test -p xcl --lib hle::d3d12x::bind::tests::execute_indirect_remap_fallback_error_skips_before_guard_and_abi -- --test-threads=1: 1 passed, 0 failed.
  • cargo test -p xcl --lib hle::d3d12x::bind::tests::gpu_execute_indirect_guard_cleanup_on_abi_error_and_whole_skip -- --test-threads=1: 1 passed, 0 failed.

AI use

  • Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: f59aa43
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 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, +317/-42, mostly tests). When the ExecuteIndirect runs, the GPU commands are the same as on main; only the skip paths change. A whole program still being built or refused no longer sends the guard's barrier and dispatch or the XCL bind, and a failed bind now adds a barrier and a SetPipelineState. Findings: (1) the tests fail on main through the LAST_ABI_PSO ordering check, not through GPU state. Part 3 of the GPU test (~10313-10322) passes whether or not the guard's buffer goes back to COMMON (without the debug layer the next transition from UNORDERED_ACCESS is accepted either way), and the CPU test can't reach the guard (signature 1 isn't registered). So the buffer-state half of the claim is untested; running that part with the debug layer, or reading the tracked state, would cover it. (2) After a failed bind (~3881-3882) the pipeline is put back but the guard's compute root signature and root views stay bound, so the title's pipeline sits with the guard's root signature. Harmless while every later bind sets its root signature again. (3) It conflicts with #3536 (lucsoft), which moves the same indirect_guard::check call ahead of the split-chain path, so one of them needs reworking after the other. (4) AI use names the tool but not the model; the full-suite run has no counts. Fine: the whole-program pipeline is still bound after the clamp rebind, the UNORDERED_ACCESS -> COMMON barrier after the guard dispatch is valid, bind_pipeline_exact uses the original vtable entry, no new shared state, and the GPU test uses skip_test.
performance: 60 s smoke of a retail title, main d0832e6 vs this merge (4113798c): 1516 -> 1688 frames shown (111 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 16973 MB, 0 device removals, 0 crashes.
verdict: safe to merge (coordinate with #3536, which moves the same indirect_guard::check call; a test of the buffer state would make finding 1 stick)
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.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@brainhay5

Copy link
Copy Markdown

merge-check claim
head: f59aa43

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) needs:amd-test Needs a test report or merge-check on an AMD GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants