D3D12.X: clean up indirect_guard state on ExecuteIndirect skip paths #3401
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3401"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T13:33:24Z.
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.
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-29T14:20:49Z.
Reviewed and tested at
f59aa439.Code review findings
remap_fallback::whole_exactanddispatch_chain::whole_readyahead ofindirect_guard::checkandbind_abi_resolvedis a clean improvement.bind_abi_resolvederror (crates/xcl/src/hle/d3d12x/bind.rs):indirect_guard::checkbinds both its own internal compute root signature and its own compute pipeline. In theErr(e)cleanup block,c.read(this)returnsg.outtoCOMMONandbind_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-calllist2.SetComputeRootSignature(&rs)before dispatching). Any subsequent computeDispatchon the same command list relying on its previously bound compute root signature will execute withindirect_guard's root signature still bound.Tested locally
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
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:27:30Z.
merge-check
base:
d0832e614fhead:
f59aa43937merge: 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_PSOordering 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 sameindirect_guard::checkcall 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_exactuses the original vtable entry, no new shared state, and the GPU test usesskip_test.performance: 60 s smoke of a retail title, main
d0832e61vs 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.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T05:54:27Z.
merge-check claim
head:
f59aa43937Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T03:43:29Z.
Code review location:
crates/xcl/src/hle/d3d12x/bind.rs; line 3882The new
bind_abi_resolvederror cleanup restores only the pipeline. The compute root signature (g.rs) and root arguments (constants, UAVs 1-4 pointing at g.out / g.seen / the title's args) thatindirect_guard::checkbound stay on the list. On a compute ExecuteIndirect where the guard check ran but the ABI bind failed (e.g. no unified memory, no ABI root signature), the title'spsoends up bound against the guard's root signature. Unlike the Ok path, which leaves XCL's ABI root signature, any later work that doesn't rebind (the PC-pipeline dispatch path that goes on without one) runs against an incompatible root signature. That causes debug-layer errors or reads/writes through the guard's UAVs. Restoring the previous root signature too, or running the fallible ABI prepare beforecheck, would fix it.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T03:43:29Z.
Review: COMMENTED
Review of
f59aa439: 1 finding(s). 1 are inline.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:14:36Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.