You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
D3D12.X: clean up indirect_guard state on ExecuteIndirect skip paths - #3401
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 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):
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area:d3d12D3D12.X runtime, command lists, resources, sparse memorygpu:bothCode affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)needs:amd-testNeeds a test report or merge-check on an AMD GPUneeds-2nd-checkHas 1 safe merge-check; needs second independent check (#3041)
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
execute_indirect_snapshot):real::pso_dispatch_remap_exact->remap_fallback::whole_exactanddispatch_chain::whole_ready) before runningindirect_guard::checkandbind_abi_resolved, so late (Whole::Late) or failed whole-program builds skip the indirect dispatch without dispatching the guard, leavingindirect_guard's shared output buffer inUNORDERED_ACCESS, or mutating the command list's root signature and pipeline state.bind_abi_resolvederror whenindirect_guard::checkran (checked.is_some()), transitionindirect_guard's shared output buffer back toCOMMONviac.read(this)and restore the command list's resolved native pipeline viareal::bind_pipeline_exact(this, raw_pso, pso)instead of leavingindirect_guard's internal compute PSO bound.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 beforebind_abi_resolvedand 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 afterindirect_guard::checkrestores both the title's PSO andindirect_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_snapshotranindirect_guard::check(which promotesindirect_guard's sharedoutbuffer toUNORDERED_ACCESS, binds its own compute root signature and PSO, and dispatches the guard) andbind_abi_resolvedbefore checking whether a split or dispatch-remapped compute pipeline's whole form was ready or buildable, and returned early onWhole::Lateor whole-build / ABI-bind failure without callingc.read(this)or restoring the command list's pipeline state. That leftindirect_guard's shared buffer stuck inUNORDERED_ACCESS(violating itsCOMMON-between-uses invariant across later lists in the same submit) and leftindirect_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 --workspaceandcargo test --workspace -- --test-threads=4: all workspace unit, e2e (D3D12 debug layer + DRED), and tiling tests passed (exit 0).f59aa43937d0669c23fa33b34312d4986d8cfeb4):mainbaseline (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):Not tested
indirect_guard::checkbecausetracked_list_typeis notDIRECTorCOMPUTE).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.