D3D12.X: use NON_PIXEL_SHADER_RESOURCE state for predication on compute command lists #1017
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!1017
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1017/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?
@Jefter5549 on GitHub · 2026-11-24 10:25 UTC · original
Jefter5549:pr/compute-predication-state→main· +33 −13 · 1 files · 1 commits · closed without mergingAccording to the Direct3D 12 specification (
ID3D12GraphicsCommandList::SetPredication), a predication buffer on direct command lists must be inD3D12_RESOURCE_STATE_PREDICATION, while on compute command lists it must be inD3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE.In
crates/xcl/src/hle/d3d12x/list_x.rs, transitions unconditionally usedD3D12_RESOURCE_STATE_PREDICATION. When a title records predication on a compute command list or splits a compute command list around mid-list Wait (try_split_for_wait), issuing a barrier forD3D12_RESOURCE_STATE_PREDICATIONonD3D12_COMMAND_LIST_TYPE_COMPUTEis an invalid API operation that triggers D3D12 debug errors and driver device removal (0x887a0006).Add
predication_resource_state(ty)to supplyD3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCEon compute lists andD3D12_RESOURCE_STATE_PREDICATIONon direct lists across all predication lifecycle points (try_split_for_wait,apply_predication_copy,before_close,set_predication_buffer_x,kickoff_x, andrestore_state).What is in it
predication_resource_state(ty)helper incrates/xcl/src/hle/d3d12x/list_x.rsreturningNON_PIXEL_SHADER_RESOURCEfor compute command lists andPREDICATIONfor direct command lists.predication_resource_state(ty).Tested
cargo test --workspace -- --test-threads=4: 89 passed, 0 failed, 0 ignored (SKIPPED GPU tests: 0)Regression run
main:
PR:
Not tested
AI use
@Aniseto on GitHub · 2026-11-24 10:30 UTC · original
Ran the predication paths on an NVIDIA Blackwell part at
6550644, with the D3D12 debug layer enabled (the path this PR changes).Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
set_predication_buffer_state_and_kickoffruns with the debug layer enabled and reports no debug-layer error and no device removal on this adapter. This adds a Blackwell / driver 32.0.16.2124 datapoint next to the author's RTX 2060 SUPER run.Not tested: a retail title or
scripts/smoke.ps1(no unpacked title on this machine), RDNA2/RDNA4 and Intel GPUs, Wine, release profile.AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.
@Diskuss on GitHub · 2026-11-24 10:33 UTC · original
Tested on AMD Radeon RX 9070 XT (RDNA4) at
655064496b29aa560b4caa10ab73fa3f4b4baa5eAMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D; 32 GB RAM; Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug build.
Tested:
655064496bis not behind main (origin/main6efdabcis an ancestor), so the local merge with main was a no-op; this is the bare head.cargo build --workspace: OK (1 existing warning in xcl lib).cargo test --workspace --no-fail-fast -- --test-threads=4: 727 passed, 0 failed, 41 ignored.cargo test -p xcl --lib predication -- --test-threads=1: 1 passed (set_predication_buffer_state_transitions_and_lifecycle)cargo test -p xcl --test predication_e2e: 1 passed (set_predication_buffer_state_and_kickoff; debug layer unavailable, so it ran without it)6efdabc(no PR) gave 727 passed, 0 failed, 41 ignored, identical to the PR. (The older9aec53dbaseline of 724/0/41 is 10 commits behind and not comparable.)Not tested: retail title /
scripts/smoke.ps1(no game files), release build.Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.
@DavidM1911 on GitHub · 2026-11-24 11:20 UTC · original
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug.
cargo test -p xcl --lib predication: 1 passed —set_predication_buffer_state_transitions_and_lifecycle.cargo test -p xcl --lib list_x: 24 passed, 0 failed.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@kacper-serewis on GitHub · 2026-11-24 20:17 UTC · original
On a compute list, the D3D12 debug layer rejects the state this PR switches to and accepts the one it replaces (
6550644).Tested on WARP with the debug layer, Windows 11. A compute list transitions a buffer from COMMON to the state, calls
SetPredicationon it, clears predication, transitions back, closes, and executes:PREDICATION(0x200, as onmain)NON_PIXEL_SHADER_RESOURCE(0x40, this PR)predication_e2euses only a direct list, so it does not reach this. The test below calls D3D12 directly, outside XCL. Suggested: keepPREDICATIONon compute lists.Not tested: a hardware adapter; the device removal in the description. If that removal has another cause, this state change would not be the fix for it.
Test (a file in crates/xcl/tests/)
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. I checked the points before posting.
@Jefter5549 on GitHub · 2026-11-24 20:23 UTC · original
Thanks for testing this against the D3D12 debug layer — you're right,
D3D12_RESOURCE_STATE_PREDICATIONis the state expected bySetPredicationon compute command lists, whileNON_PIXEL_SHADER_RESOURCEtriggers debug layer error 538.Our earlier
0x887a0006device removal must have had another root cause, and a clean run on currentmain(c160d86e) no longer reproduces it across compute list splits. Closing this PR.Pull request closed