D3D12.X: fix SetPredicationBufferX resource state lifecycle and KickoffX restore #207
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!207
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/207/head"
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?
@RandomGithub12309 on GitHub · 2026-11-23 20:57 UTC · original
RandomGithub12309:fix/set-predication-buffer-state→main· +915 −19 · 3 files · 1 commits · merged 2026-11-23 21:08 UTCAddresses #104 item 3 with a live GPU reproducer, fix, and unit/E2E coverage for
SetPredicationBufferX.Problems reproduced & fixed
KickoffXdropped active predication (reproduced live on GPU):KickoffXcloses, submits, and resets the PC command list mid-recording without saving or restoring active predication. Before this fix,predication_e2eCase 2 failed on an NVIDIA GeForce RTX 5050 Laptop GPU (dst[4]was overwritten with0xEEEE_0004instead of remaining0x5555_5555underEQUAL_ZERO(0)).SetPredicationBufferXtransitioned the shared UMA window bufferCOMMON -> PREDICATION, boundSetPredication, and immediately transitioned it backPREDICATION -> COMMON. On PC D3D12, a bound predication buffer must remain inD3D12_RESOURCE_STATE_PREDICATIONacross subsequent predicated commands—while keeping the shared UMA window inPREDICATIONwould conflict with other UMA operations (Write32/64BitValue*,CopyMemoryToMemoryX,FillMemoryWith*, timestamps) targeting that same window.CopyBufferRegionis predicated in D3D12, switching directly from an active failing predicate to another buffer without callingSetPredicationBufferX(NULL)first requires disarming the active predicate before copying the new 8-byte value.ClearStateunbinds predication on the list without altering the buffer's GPU resource state.Close/Resetmust cleanly returnpred_buftoCOMMON/ reset tracked per-recording state.BUNDLEandCOPYcommand lists, unreadable descriptors, unknown ops (> 1), unaligned addresses, and non-UMA addresses must be rejected without disturbing an already-active predicate.Summary of changes
crates/xcl/src/hle/d3d12x/list_x.rs:D3D12_HEAP_TYPE_DEFAULTpredication buffer (pred_buf, created inCOMMONstate) and trackpred_in_stateandpredicationonListState, guarded by an atomicPREDICATION_USEDfast path so command lists that never use predication incur noClose/Resetoverhead.SetPredicationBufferX: validateDIRECT/COMPUTElist type, descriptor readability,op <= 1, and 8-byte-aligned UMA window resolution; disarm any active predicate before copying; copy 8 bytes from the UMA window (COMMON -> COPY_SOURCE -> COMMON) intopred_buf((COMMON|PREDICATION) -> COPY_DEST -> PREDICATION); and bindSetPredication(pb, 0, op).pred_bufstate andSetPredicationacrosskickoff_x, preservepred_in_stateacrosson_clear_state, transitionpred_bufback toCOMMONonNULLorbefore_close, clear state inon_pc_resetandreset_x, and drop removedListStateCOM resources outside theLISTSlock.set_predication_buffer_state_transitions_and_lifecycle) asserting exact orderedResourceBarrier,CopyBufferRegion, andSetPredicationcalls, lifecycle transitions, rejection paths, and COM resource cleanup.crates/xcl/src/hle/d3d12x/real.rs:list_x::before_closeincl_closeandlist_x::on_pc_reseton successfulcl_reset.crates/xcl/tests/predication_e2e.rs:Write32BitValueBottomOfPipeX->SetPredicationBufferX), interleaved UMA writes, direct buffer switches withoutNULL,KickoffXpreservation,ClearState,Closewhile active, andreset_xreuse.Verification
cargo test -p xcl --test predication_e2efailed Case 2 on NVIDIA GeForce RTX 5050 Laptop GPU (KickoffXlost activeEQUAL_ZERO(0)predication).cargo test -p xcl --test predication_e2e -- --nocapture):1 passed; 0 failedon NVIDIA GeForce RTX 5050 Laptop GPU. (Note: Windows Graphics Tools /D3D12SDKLayers.dllwas unavailable on the test machine with0x887A002D, soID3D12InfoQueuechecks were inactive locally;predication_e2ehooks and checksID3D12InfoQueue/ID3D12InfoQueue1automatically when Graphics Tools is installed.)cargo test -p xcl --lib list_x::tests -- --nocapture):15 passed; 0 failed.cargo clippy --workspace --all-targets: exited0with0warnings inpredication_e2e.rsand0new warnings inlist_x.rs/real.rs..\scripts\test.ps1on rebasedmain2abc562): exited0(lib548 passed; 0 failed; 19 ignored, plus all integration targets passing with sample-env tests ignored when unset and2 (no wave64)GPU skips on this adapter).AI-assisted contribution (code, tests, and verification reviewed).
@ivall on GitHub · 2026-11-23 21:09 UTC · original
Merged (main
6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on maineaa36b6:cargo build --workspace && cargo test --workspace -- --test-threads=4- 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal). The merge conflicted with #135'stitle_textures::list_resetcalls inlist_x::on_create/on_release; both are kept (the reset after the list state is replaced).