D3D12.X: use NON_PIXEL_SHADER_RESOURCE state for predication on compute command lists #1017

Closed
github-bot wants to merge 1 commit from gh-pr/1017/head into gh-pr/1017/base
Owner

@⁠Jefter5549 on GitHub · 2026-11-24 10:25 UTC · original
Jefter5549:pr/compute-predication-state → main · +33 −13 · 1 files · 1 commits · closed without merging

According to the Direct3D 12 specification (ID3D12GraphicsCommandList::SetPredication), a predication buffer on direct command lists must be in D3D12_RESOURCE_STATE_PREDICATION, while on compute command lists it must be in D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE.

In crates/xcl/src/hle/d3d12x/list_x.rs, transitions unconditionally used D3D12_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 for D3D12_RESOURCE_STATE_PREDICATION on D3D12_COMMAND_LIST_TYPE_COMPUTE is an invalid API operation that triggers D3D12 debug errors and driver device removal (0x887a0006).

Add predication_resource_state(ty) to supply D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE on compute lists and D3D12_RESOURCE_STATE_PREDICATION on direct lists across all predication lifecycle points (try_split_for_wait, apply_predication_copy, before_close, set_predication_buffer_x, kickoff_x, and restore_state).

What is in it

  • predication_resource_state(ty) helper in crates/xcl/src/hle/d3d12x/list_x.rs returning NON_PIXEL_SHADER_RESOURCE for compute command lists and PREDICATION for direct command lists.
  • Route all 6 predication barrier transitions through predication_resource_state(ty).
  • Skip direct-only predication re-arming when splitting copy command lists.

Tested

  • hardware: NVIDIA GeForce RTX 2060 SUPER, Intel Xeon E5-2666 v3, Windows 11, Rust 1.83.0, release
  • cargo test --workspace -- --test-threads=4: 89 passed, 0 failed, 0 ignored (SKIPPED GPU tests: 0)

Regression run
main:

xcl-smoke v1
commit: 6efdabc
gpu: NVIDIA GeForce RTX 2060 SUPER
title: retail_sample
seconds: 60
exit: 0x887a0006
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 60 60 0
device removals: 1
crashes: 1
peak commit: 17408 MB

PR:

xcl-smoke v1
commit: 6550644
gpu: NVIDIA GeForce RTX 2060 SUPER
title: retail_sample
seconds: 60
exit: 0x0
frames shown: 1800 (PresentX 1800)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17420 MB

Not tested

  • Bundle command list predication (titles tested do not use bundles for predication).

AI use

  • Gemini 4 Neon: analysis of Direct3D 12 predication specification for compute command lists and lifecycle state transitions.
**@⁠Jefter5549** on GitHub · 2026-11-24 10:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1017) `Jefter5549:pr/compute-predication-state` → `main` · +33 −13 · 1 files · 1 commits · closed without merging According to the Direct3D 12 specification (`ID3D12GraphicsCommandList::SetPredication`), a predication buffer on direct command lists must be in `D3D12_RESOURCE_STATE_PREDICATION`, while on compute command lists it must be in `D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE`. In `crates/xcl/src/hle/d3d12x/list_x.rs`, transitions unconditionally used `D3D12_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 for `D3D12_RESOURCE_STATE_PREDICATION` on `D3D12_COMMAND_LIST_TYPE_COMPUTE` is an invalid API operation that triggers D3D12 debug errors and driver device removal (`0x887a0006`). Add `predication_resource_state(ty)` to supply `D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE` on compute lists and `D3D12_RESOURCE_STATE_PREDICATION` on direct lists across all predication lifecycle points (`try_split_for_wait`, `apply_predication_copy`, `before_close`, `set_predication_buffer_x`, `kickoff_x`, and `restore_state`). **What is in it** - `predication_resource_state(ty)` helper in `crates/xcl/src/hle/d3d12x/list_x.rs` returning `NON_PIXEL_SHADER_RESOURCE` for compute command lists and `PREDICATION` for direct command lists. - Route all 6 predication barrier transitions through `predication_resource_state(ty)`. - Skip direct-only predication re-arming when splitting copy command lists. **Tested** - hardware: NVIDIA GeForce RTX 2060 SUPER, Intel Xeon E5-2666 v3, Windows 11, Rust 1.83.0, release - `cargo test --workspace -- --test-threads=4`: 89 passed, 0 failed, 0 ignored (SKIPPED GPU tests: 0) **Regression run** main: ``` xcl-smoke v1 commit: 6efdabc gpu: NVIDIA GeForce RTX 2060 SUPER title: retail_sample seconds: 60 exit: 0x887a0006 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 60 60 0 device removals: 1 crashes: 1 peak commit: 17408 MB ``` PR: ``` xcl-smoke v1 commit: 6550644 gpu: NVIDIA GeForce RTX 2060 SUPER title: retail_sample seconds: 60 exit: 0x0 frames shown: 1800 (PresentX 1800) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17420 MB ``` **Not tested** - Bundle command list predication (titles tested do not use bundles for predication). **AI use** - Gemini 4 Neon: analysis of Direct3D 12 predication specification for compute command lists and lifecycle state transitions.
According to the Direct3D 12 specification (ID3D12GraphicsCommandList::SetPredication),
a predication buffer on direct command lists must be in D3D12_RESOURCE_STATE_PREDICATION,
while on compute command lists it must be in D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE.

In list_x.rs, transitions unconditionally used D3D12_RESOURCE_STATE_PREDICATION. When a title
records predication on a compute command list or splits a compute command list around mid-list
Wait, issuing a barrier for D3D12_RESOURCE_STATE_PREDICATION on D3D12_COMMAND_LIST_TYPE_COMPUTE
triggers driver device removal (0x887a0006).

Add predication_resource_state(ty) to supply NON_PIXEL_SHADER_RESOURCE on compute lists and
PREDICATION on direct lists across all predication lifecycle transitions.

Co-Authored-By: Gemini 4 Neon <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:40 +00:00
github-bot closed this pull request 2026-11-26 04:40:40 +00:00
Author
Owner

@⁠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.

XCL_ADAPTER=nvidia cargo test -p xcl --lib set_predication_buffer_state
1 passed; 0 failed; 0 ignored      (exit 0)

XCL_ADAPTER=nvidia cargo test -p xcl --test predication_e2e
1 passed; 0 failed; 0 ignored      (exit 0)

set_predication_buffer_state_and_kickoff runs 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.

**@⁠Aniseto** on GitHub · 2026-11-24 10:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/1017#issuecomment-7128880550) 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. ``` XCL_ADAPTER=nvidia cargo test -p xcl --lib set_predication_buffer_state 1 passed; 0 failed; 0 ignored (exit 0) XCL_ADAPTER=nvidia cargo test -p xcl --test predication_e2e 1 passed; 0 failed; 0 ignored (exit 0) ``` `set_predication_buffer_state_and_kickoff` runs 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.
Author
Owner

@⁠Diskuss on GitHub · 2026-11-24 10:33 UTC · original

Tested on AMD Radeon RX 9070 XT (RDNA4) at 655064496b29aa560b4caa10ab73fa3f4b4baa5e

AMD 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:

  • PR head 655064496b is not behind main (origin/main 6efdabc is 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.
  • The PR adds no new tests, so I ran the existing predication tests by name:
    • 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)
    • These cover the graphics path; I found no test that uses a compute list with predication, so the new compute-list state (NON_PIXEL_SHADER_RESOURCE) is not exercised by any test.
  • 0 SKIPPED printed; 2 debug-layer tests skip silently, no Graphics Tools installed. No DXGI_ERROR_DEVICE_REMOVED.
  • Baseline: main alone at 6efdabc (no PR) gave 727 passed, 0 failed, 41 ignored, identical to the PR. (The older 9aec53d baseline 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.

**@⁠Diskuss** on GitHub · 2026-11-24 10:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/1017#issuecomment-7128938788) **Tested on AMD Radeon RX 9070 XT (RDNA4) at `655064496b29aa560b4caa10ab73fa3f4b4baa5e`** AMD 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**: - PR head 655064496b29 is not behind main (origin/main 6efdabc is 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. - The PR adds no new tests, so I ran the existing predication tests by name: - `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) - These cover the graphics path; I found no test that uses a compute list with predication, so the new compute-list state (NON_PIXEL_SHADER_RESOURCE) is not exercised by any test. - 0 SKIPPED printed; 2 debug-layer tests skip silently, no Graphics Tools installed. No DXGI_ERROR_DEVICE_REMOVED. - Baseline: main alone at 6efdabc (no PR) gave 727 passed, 0 failed, 41 ignored, identical to the PR. (The older 9aec53d baseline 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 11:20 UTC · original

Independent verification, merged onto current main 384f7f7 locally (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.

**@⁠DavidM1911** on GitHub · 2026-11-24 11:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/1017#issuecomment-7129979848) Independent verification, merged onto current `main` `384f7f7` locally (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.
Author
Owner

@⁠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 SetPredication on it, clears predication, transitions back, closes, and executes:

state debug-layer errors
PREDICATION (0x200, as on main) none
NON_PIXEL_SHADER_RESOURCE (0x40, this PR) id 538: "Expected State Bits (all): 0x200 ... Actual State: 0x40 ... Missing State: 0x200"

predication_e2e uses only a direct list, so it does not reach this. The test below calls D3D12 directly, outside XCL. Suggested: keep PREDICATION on 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/)
//! Compute list + SetPredication on WARP with the debug layer: which buffer state is accepted.
use std::mem::{transmute_copy, ManuallyDrop};
use windows::core::Interface;
use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
use windows::Win32::Graphics::Direct3D12::*;
use windows::Win32::Graphics::Dxgi::Common::*;
use windows::Win32::Graphics::Dxgi::*;

fn errors(st: D3D12_RESOURCE_STATES) -> Vec<(i32, String)> {
    unsafe {
        let mut dbg: Option<ID3D12Debug> = None;
        D3D12GetDebugInterface(&mut dbg).unwrap();
        dbg.unwrap().EnableDebugLayer();
        let f: IDXGIFactory4 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).unwrap();
        let warp: IDXGIAdapter = f.EnumWarpAdapter().unwrap();
        let mut dev: Option<ID3D12Device> = None;
        D3D12CreateDevice(&warp, D3D_FEATURE_LEVEL_11_0, &mut dev).unwrap();
        let dev = dev.unwrap();
        let iq: ID3D12InfoQueue = dev.cast().unwrap();
        let desc = D3D12_RESOURCE_DESC { Dimension: D3D12_RESOURCE_DIMENSION_BUFFER, Width: 256, Height: 1, DepthOrArraySize: 1, MipLevels: 1, SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR, ..Default::default() };
        let mut r: Option<ID3D12Resource> = None;
        dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_DEFAULT, ..Default::default() }, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COMMON, None, &mut r).unwrap();
        let r = r.unwrap();
        let ty = D3D12_COMMAND_LIST_TYPE_COMPUTE;
        let q: ID3D12CommandQueue = dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC { Type: ty, ..Default::default() }).unwrap();
        let a: ID3D12CommandAllocator = dev.CreateCommandAllocator(ty).unwrap();
        let l: ID3D12GraphicsCommandList = dev.CreateCommandList(0, ty, &a, None).unwrap();
        let bar = |b, c| D3D12_RESOURCE_BARRIER { Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, Anonymous: D3D12_RESOURCE_BARRIER_0 { Transition: ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { pResource: transmute_copy(&r), Subresource: u32::MAX, StateBefore: b, StateAfter: c }) } };
        iq.ClearStoredMessages();
        l.ResourceBarrier(&[bar(D3D12_RESOURCE_STATE_COMMON, st)]);
        l.SetPredication(&r, 0, D3D12_PREDICATION_OP_EQUAL_ZERO);
        l.SetPredication(None, 0, D3D12_PREDICATION_OP_EQUAL_ZERO);
        l.ResourceBarrier(&[bar(st, D3D12_RESOURCE_STATE_COMMON)]);
        println!("state {:#x}: Close {:?}", st.0, l.Close());
        q.ExecuteCommandLists(&[Some(l.cast().unwrap())]);
        let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
        q.Signal(&fence, 1).unwrap();
        while fence.GetCompletedValue() < 1 { std::thread::sleep(std::time::Duration::from_millis(1)); }
        let mut out = vec![];
        for i in 0..iq.GetNumStoredMessages() {
            let mut n = 0usize;
            let _ = iq.GetMessage(i, None, &mut n);
            let mut b = vec![0u64; n / 8 + 1];
            let m = b.as_mut_ptr() as *mut D3D12_MESSAGE;
            if iq.GetMessage(i, Some(m), &mut n).is_ok() && (*m).Severity.0 <= D3D12_MESSAGE_SEVERITY_ERROR.0 {
                out.push(((*m).ID.0, std::ffi::CStr::from_ptr((*m).pDescription as *const i8).to_string_lossy().into_owned()));
            }
        }
        out
    }
}

#[test]
fn compute_list_predication_state() {
    let base = errors(D3D12_RESOURCE_STATE_PREDICATION);
    let pr = errors(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
    println!("PREDICATION: {base:#?}\nNON_PIXEL_SHADER_RESOURCE: {pr:#?}");
    assert!(base.is_empty() && !pr.is_empty());
}

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. I checked the points before posting.

**@⁠kacper-serewis** on GitHub · 2026-11-24 20:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/1017#issuecomment-7143319735) 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 `SetPredication` on it, clears predication, transitions back, closes, and executes: | state | debug-layer errors | |---|---| | `PREDICATION` (0x200, as on `main`) | none | | `NON_PIXEL_SHADER_RESOURCE` (0x40, this PR) | id 538: "Expected State Bits (all): 0x200 ... Actual State: 0x40 ... Missing State: 0x200" | `predication_e2e` uses only a direct list, so it does not reach this. The test below calls D3D12 directly, outside XCL. Suggested: keep `PREDICATION` on 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. <details><summary>Test (a file in crates/xcl/tests/)</summary> ```rust //! Compute list + SetPredication on WARP with the debug layer: which buffer state is accepted. use std::mem::{transmute_copy, ManuallyDrop}; use windows::core::Interface; use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0; use windows::Win32::Graphics::Direct3D12::*; use windows::Win32::Graphics::Dxgi::Common::*; use windows::Win32::Graphics::Dxgi::*; fn errors(st: D3D12_RESOURCE_STATES) -> Vec<(i32, String)> { unsafe { let mut dbg: Option<ID3D12Debug> = None; D3D12GetDebugInterface(&mut dbg).unwrap(); dbg.unwrap().EnableDebugLayer(); let f: IDXGIFactory4 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).unwrap(); let warp: IDXGIAdapter = f.EnumWarpAdapter().unwrap(); let mut dev: Option<ID3D12Device> = None; D3D12CreateDevice(&warp, D3D_FEATURE_LEVEL_11_0, &mut dev).unwrap(); let dev = dev.unwrap(); let iq: ID3D12InfoQueue = dev.cast().unwrap(); let desc = D3D12_RESOURCE_DESC { Dimension: D3D12_RESOURCE_DIMENSION_BUFFER, Width: 256, Height: 1, DepthOrArraySize: 1, MipLevels: 1, SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR, ..Default::default() }; let mut r: Option<ID3D12Resource> = None; dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_DEFAULT, ..Default::default() }, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COMMON, None, &mut r).unwrap(); let r = r.unwrap(); let ty = D3D12_COMMAND_LIST_TYPE_COMPUTE; let q: ID3D12CommandQueue = dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC { Type: ty, ..Default::default() }).unwrap(); let a: ID3D12CommandAllocator = dev.CreateCommandAllocator(ty).unwrap(); let l: ID3D12GraphicsCommandList = dev.CreateCommandList(0, ty, &a, None).unwrap(); let bar = |b, c| D3D12_RESOURCE_BARRIER { Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, Anonymous: D3D12_RESOURCE_BARRIER_0 { Transition: ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { pResource: transmute_copy(&r), Subresource: u32::MAX, StateBefore: b, StateAfter: c }) } }; iq.ClearStoredMessages(); l.ResourceBarrier(&[bar(D3D12_RESOURCE_STATE_COMMON, st)]); l.SetPredication(&r, 0, D3D12_PREDICATION_OP_EQUAL_ZERO); l.SetPredication(None, 0, D3D12_PREDICATION_OP_EQUAL_ZERO); l.ResourceBarrier(&[bar(st, D3D12_RESOURCE_STATE_COMMON)]); println!("state {:#x}: Close {:?}", st.0, l.Close()); q.ExecuteCommandLists(&[Some(l.cast().unwrap())]); let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap(); q.Signal(&fence, 1).unwrap(); while fence.GetCompletedValue() < 1 { std::thread::sleep(std::time::Duration::from_millis(1)); } let mut out = vec![]; for i in 0..iq.GetNumStoredMessages() { let mut n = 0usize; let _ = iq.GetMessage(i, None, &mut n); let mut b = vec![0u64; n / 8 + 1]; let m = b.as_mut_ptr() as *mut D3D12_MESSAGE; if iq.GetMessage(i, Some(m), &mut n).is_ok() && (*m).Severity.0 <= D3D12_MESSAGE_SEVERITY_ERROR.0 { out.push(((*m).ID.0, std::ffi::CStr::from_ptr((*m).pDescription as *const i8).to_string_lossy().into_owned())); } } out } } #[test] fn compute_list_predication_state() { let base = errors(D3D12_RESOURCE_STATE_PREDICATION); let pr = errors(D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); println!("PREDICATION: {base:#?}\nNON_PIXEL_SHADER_RESOURCE: {pr:#?}"); assert!(base.is_empty() && !pr.is_empty()); } ``` </details> **AI use:** Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. I checked the points before posting.
Author
Owner

@⁠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_PREDICATION is the state expected by SetPredication on compute command lists, while NON_PIXEL_SHADER_RESOURCE triggers debug layer error 538.

Our earlier 0x887a0006 device removal must have had another root cause, and a clean run on current main (c160d86e) no longer reproduces it across compute list splits. Closing this PR.

**@⁠Jefter5549** on GitHub · 2026-11-24 20:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1017#issuecomment-7143466588) Thanks for testing this against the D3D12 debug layer — you're right, `D3D12_RESOURCE_STATE_PREDICATION` is the state expected by `SetPredication` on compute command lists, while `NON_PIXEL_SHADER_RESOURCE` triggers debug layer error 538. Our earlier `0x887a0006` device removal must have had another root cause, and a clean run on current `main` (`c160d86e`) no longer reproduces it across compute list splits. Closing this PR.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.