D3D12.X: PC CreateCommandList gives the driver the pipeline behind a stand-in #2861

Open
github-bot wants to merge 2 commits from github-bot/gh-2861 into main AGit
Owner

@⁠oni-swr on GitHub · 2026-11-26 19:41 UTC · original
oni-swr:t3/xcl-2455-pc-ccl-1126t → main · +218 −3 · 2 files · 2 commits · draft

Part of #2455 (the PC CreateCommandList item; MakeResident/Evict are #2523, StorePipeline is #2853).

A title that calls the PC ID3D12Device::CreateCommandList with a stand-in pipeline (standin::Shell) as pInitialState had that pointer forwarded to D3D12Core.dll unchanged, but the shell is not a driver object. The override now passes pInitialState through pso_async::resolve: the built pipeline if there is one, else the driver pipeline the stand-in shares, else the pointer as it is (null, ordinary pipelines). create_raw_pc_command_list does the same on its direct-to-driver path.

Judgement call: resolve, not resolve_for_bind. It never waits for a build still running (the caller is the title's thread), the same choice #2548 makes for Reset/KickoffX/the console-device CreateCommandList in device_x.rs. The list's first bind of the stand-in goes through bind as before, so lazy / async compile behaviour is unchanged. #2548 does not touch real.rs, so there is no overlap.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: dev_create_command_list becomes a wrapper that resolves a4 before the creator! forwarder; create_raw_pc_command_list resolves init_pso
  • real.rs create_command_list_standin_tests: 4 CPU tests with a fake driver table (pending stand-in gives the shared driver pipeline without waiting; built stand-in gives the built pipeline; null / driver pipeline unchanged; raw path)

Tested

  • CPU only (XCL_ADAPTER=NONE_CPU_ONLY), no GPU test run. Windows 11, stable MSVC, debug.
  • cargo test -p xcl --lib -j 4 create_command_list_standin: 4 passed, 0 failed, 0 ignored
  • Same tests with the two resolve calls removed: 1 passed, 3 failed (the driver got the stand-in's address)
  • cargo check --workspace --tests -j 4: finished, no errors
  • The full suite was not run (see Not tested)

Regression run

  • Pending: scripts/smoke.ps1 on main and on this head needs the RX 7800 XT, which is in use by another job. Draft until both xcl-smoke blocks are pasted here.

Not tested

  • Full cargo test --workspace and any GPU test (SKIPPED / GPU counts unknown)
  • scripts/smoke.ps1 or any retail title; AMD and NVIDIA
  • Whether a real title passes a stand-in here (the fix follows the code path; it was not observed)

AI use

  • Claude Code (Claude Sonnet 5.5): read the code, wrote the change, the tests and this description.

🤖 Generated with Claude Code

**@⁠oni-swr** on GitHub · 2026-11-26 19:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/2861) `oni-swr:t3/xcl-2455-pc-ccl-1126t` → `main` · +218 −3 · 2 files · 2 commits · draft Part of #2455 (the PC `CreateCommandList` item; MakeResident/Evict are #2523, StorePipeline is #2853). A title that calls the PC `ID3D12Device::CreateCommandList` with a stand-in pipeline (`standin::Shell`) as `pInitialState` had that pointer forwarded to `D3D12Core.dll` unchanged, but the shell is not a driver object. The override now passes `pInitialState` through `pso_async::resolve`: the built pipeline if there is one, else the driver pipeline the stand-in shares, else the pointer as it is (null, ordinary pipelines). `create_raw_pc_command_list` does the same on its direct-to-driver path. Judgement call: `resolve`, not `resolve_for_bind`. It never waits for a build still running (the caller is the title's thread), the same choice #2548 makes for Reset/KickoffX/the console-device CreateCommandList in `device_x.rs`. The list's first bind of the stand-in goes through `bind` as before, so lazy / async compile behaviour is unchanged. #2548 does not touch `real.rs`, so there is no overlap. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `dev_create_command_list` becomes a wrapper that resolves `a4` before the `creator!` forwarder; `create_raw_pc_command_list` resolves `init_pso` - `real.rs` `create_command_list_standin_tests`: 4 CPU tests with a fake driver table (pending stand-in gives the shared driver pipeline without waiting; built stand-in gives the built pipeline; null / driver pipeline unchanged; raw path) **Tested** - CPU only (`XCL_ADAPTER=NONE_CPU_ONLY`), no GPU test run. Windows 11, stable MSVC, debug. - `cargo test -p xcl --lib -j 4 create_command_list_standin`: 4 passed, 0 failed, 0 ignored - Same tests with the two `resolve` calls removed: 1 passed, 3 failed (the driver got the stand-in's address) - `cargo check --workspace --tests -j 4`: finished, no errors - The full suite was not run (see Not tested) **Regression run** - Pending: `scripts/smoke.ps1` on `main` and on this head needs the RX 7800 XT, which is in use by another job. Draft until both `xcl-smoke` blocks are pasted here. **Not tested** - Full `cargo test --workspace` and any GPU test (SKIPPED / GPU counts unknown) - `scripts/smoke.ps1` or any retail title; AMD and NVIDIA - Whether a real title passes a stand-in here (the fix follows the code path; it was not observed) **AI use** - Claude Code (Claude Sonnet 5.5): read the code, wrote the change, the tests and this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A title that calls the PC ID3D12Device::CreateCommandList with a stand-in
pipeline (standin::Shell) as pInitialState had that pointer forwarded to
D3D12Core.dll unchanged: the shell is no driver object. The override now
passes pInitialState through pso_async::resolve, as Reset and KickoffX do
(the built pipeline, else the driver pipeline the stand-in shares; no
wait for a build still running). create_raw_pc_command_list does the same
on its direct driver path.

Part of #2455.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:46:04 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-27 06:35 UTC · original · reviewed

Can the PC CreateCommandList path preserve the requested initial PSO when a caller records work without rebinding it? pInitialState is already a bind. A legal caller can supply a PSO there and issue its first draw or dispatch without ever calling SetPipelineState. If the build is still pending at creation, the new wrapper forwards the shared dummy to the driver. Completing the build afterward updates the stand-in's lookup entry, but nothing in this path updates the PSO on the native list. The first work can therefore still use the dummy. The fake driver in the new test returns failure immediately, so it checks pointer safety but does not exercise a list that successfully records with the initial state.

The PC Reset override already uses resolve_for_bind, which waits for compute PSOs. Can creation use at least the same handling for pending compute PSOs and define how graphics work recorded with a pending initial PSO gets rebound before it executes?

Creation wrapper · PC Reset · D3D12 initial pipeline state

AI-assisted review (GPT-6.2 Sol).

**@⁠luckyteagirl** on GitHub · 2026-11-27 06:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2861#pullrequestreview-6084413300) · **reviewed** Can the PC `CreateCommandList` path preserve the requested initial PSO when a caller records work without rebinding it? `pInitialState` is already a bind. A legal caller can supply a PSO there and issue its first draw or dispatch without ever calling `SetPipelineState`. If the build is still pending at creation, the new wrapper forwards the shared dummy to the driver. Completing the build afterward updates the stand-in's lookup entry, but nothing in this path updates the PSO on the native list. The first work can therefore still use the dummy. The fake driver in the new test returns failure immediately, so it checks pointer safety but does not exercise a list that successfully records with the initial state. The PC `Reset` override already uses `resolve_for_bind`, which waits for compute PSOs. Can creation use at least the same handling for pending compute PSOs and define how graphics work recorded with a pending initial PSO gets rebound before it executes? [Creation wrapper](https://github.com/xcl-dev/xcl/blob/a3b9394ebb55bf577589799a94cb0df4fc9acc21/crates/xcl/src/hle/d3d12x/real.rs#L3164-L3173) · [PC Reset](https://github.com/xcl-dev/xcl/blob/a3b9394ebb55bf577589799a94cb0df4fc9acc21/crates/xcl/src/hle/d3d12x/real.rs#L2980-L2988) · [D3D12 initial pipeline state](https://learn.microsoft.com/en-us/windows/win32/direct3d12/managing-graphics-pipeline-state-in-direct3d-12#graphics-pipeline-state-inheritance) AI-assisted review (GPT-6.2 Sol).
pInitialState is a bind: a list may draw or dispatch with it without ever
calling SetPipelineState, and nothing rebinds a pipeline that finishes
building after the list was created. With a build still pending the native
list recorded with the stand-in's shared dummy pipeline.

The creation path now resolves the initial state with resolve_wait, graphics
pipelines too (the first draw on a title list waits for its tracked pipeline
anyway, bind::graphics_bound). A failed build, or XCL_PSO_WAIT_MS running
out, still gives the driver the shared pipeline as before.

Tests: the fake driver now also succeeds and hands out an adoptable list,
so a list really records with the initial state; compute and graphics
stand-ins pending at creation, and a failed build. The two pending-state
tests fail without the change.

Assisted-by: Claude Code (Claude Sonnet 5.5)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 06:53 UTC · original

Thanks, this is right for the creation path. Fixed in e235f13c.

Behaviour chosen: wait. pInitialState is a bind that nothing repeats, so dev_create_command_list (and the title path in create_list, and the raw split-segment list) now resolve it with resolve_wait, for graphics pipelines too, not only compute ones. A failed build, or XCL_PSO_WAIT_MS running out, still gives the driver the shared pipeline as before. A title list's first draw already waits for its tracked pipeline (bind::graphics_bound), so for a list that draws this moves the wait to creation rather than adding one. I did not add a deferred rebind: it needs per-list state and hooks in every draw / dispatch / execute path. Compared with Reset, which does not wait for graphics, this is stricter on purpose.

Tests (create_command_list_standin_tests):

  • a_pending_stand_in_as_the_initial_state_is_waited_for_and_the_driver_gets_the_built_pipeline (graphics and compute).
  • a_list_made_with_a_pending_initial_state_records_with_the_built_pipeline: the fake driver now succeeds and hands out a list XCL adopts, so a list really records with the initial state (the gap you named).
  • a_failed_stand_in_as_the_initial_state_gives_the_driver_its_shared_pipeline.
  • The two existing pending-state tests were updated to the new behaviour. The first two above fail without the change.

Tested on the PR branch (CPU only, XCL_ADAPTER=warp): cargo test -p xcl --lib hle::d3d12x: 266 passed, 0 failed, 2 ignored. cargo clippy reports nothing on the changed lines. The PR still has no title smoke pair, so it stays a draft. Not tested: a real title, and a long-building graphics pipeline at creation (the hitch it could add).

AI-assisted (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-27 06:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/2861#issuecomment-7211937468) Thanks, this is right for the creation path. Fixed in e235f13c. Behaviour chosen: wait. `pInitialState` is a bind that nothing repeats, so `dev_create_command_list` (and the title path in `create_list`, and the raw split-segment list) now resolve it with `resolve_wait`, for graphics pipelines too, not only compute ones. A failed build, or `XCL_PSO_WAIT_MS` running out, still gives the driver the shared pipeline as before. A title list's first draw already waits for its tracked pipeline (`bind::graphics_bound`), so for a list that draws this moves the wait to creation rather than adding one. I did not add a deferred rebind: it needs per-list state and hooks in every draw / dispatch / execute path. Compared with Reset, which does not wait for graphics, this is stricter on purpose. Tests (`create_command_list_standin_tests`): - `a_pending_stand_in_as_the_initial_state_is_waited_for_and_the_driver_gets_the_built_pipeline` (graphics and compute). - `a_list_made_with_a_pending_initial_state_records_with_the_built_pipeline`: the fake driver now succeeds and hands out a list XCL adopts, so a list really records with the initial state (the gap you named). - `a_failed_stand_in_as_the_initial_state_gives_the_driver_its_shared_pipeline`. - The two existing pending-state tests were updated to the new behaviour. The first two above fail without the change. Tested on the PR branch (CPU only, `XCL_ADAPTER=warp`): `cargo test -p xcl --lib hle::d3d12x`: 266 passed, 0 failed, 2 ignored. `cargo clippy` reports nothing on the changed lines. The PR still has no title smoke pair, so it stays a draft. Not tested: a real title, and a long-building graphics pipeline at creation (the hitch it could add). AI-assisted (Claude Sonnet 5.5).
Author
Owner

@⁠SzczepanGrela on GitHub · 2026-11-27 07:21 UTC · original

RX 9070 / Wine check of the initial-PSO behavior at e235f13ce82c053db6321eadcb5080841feef54e, compared with main 83b008188efbf954b846667f48d75e3fa9310a01 and a conflict-free application of the two-file PR diff to that main. Source copies had test-only instrumentation, so these are focused synthetic results.

Tested

RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1, Ryzen 7 7700, CachyOS 7.3.0-5, GE-Proton11-12 / Wine 11.0 Staging, vkd3d-proton 8293130ebe370b1+ with local asserts-disabled build, DXC/DXIL 1.9.2602.17. Windows-GNU release tests, Rust 1.97.1. Network off, adapter selected explicitly, private enabled caches, XCL_PSO_WAIT_MS unset.

cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run, then the resulting PE under Wine:

  • hle::d3d12x::real::create_command_list_standin_tests --nocapture --test-threads=1 and =4: head and integration each 6 passed, 0 failed. The same six unchanged test bodies copied to main give 1 passed, 5 failed, for both thread counts.
  • Owned hle::d3d12x::real::workflow_initial_native::workflow_initial_psos_execute_without_rebinding --exact --nocapture --test-threads=1: three fresh full runs per source, plus one pilot per source. All harnesses completed. Zero ignored or skipped tests.

The GPU fixture covers the raw-PC helper and adopted-device PC wrapper, each with compute and graphics initial PSOs. It uses a native PSO as an async lookup key for paired controls: pending lazy success, already completed success, failed job with shared fallback, and an ordinary PSO. A pending job returns an already constructed target PSO after a controlled 30 ms delay. Main's job is completed after list creation but before recording work. No SetPipelineState is called. Genuine standin::Shell success/failure cases also execute on head and integration.

Results: 219 GPU work cases, including 111 physical-wave64 compute dispatches and 108 draws. Head and integration select the expected driver PSO and produce the expected data throughout. On main, 24 full-matrix cases plus the pilot retain the earlier PSO instead of the requested completed one: compute lane 0 writes 0xd00d0000 instead of 42, and graphics writes (1,0,0.5,1) instead of (0.25,0.5,0.75,1). Ordinary and failed-build fallback controls work on all sources.

A separate Python oracle checked all 126,576 readback words, including compute guards, every lane's wave width and every 16×16 RGBA32F pixel, plus 237 captured native creation arguments. Fresh repeats and head/integration outputs match. No device removal occurred.

Not tested

Retail workload, smoke run, full suite, native Windows, actual pending shader translation/driver compilation, wait-budget expiration or hitch/performance impact. Recording uses the native PC list after test-only removal of its adoption hooks, so implicit rebinding cannot mask the initial state. This does not exercise the console device_x::create_list caller or full title recording path. Allocators are native; the earlier adopted-allocator 0x80070057 boundary was not retested. A genuine Shell was not passed to main's native driver.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the public source, wrote the synthetic fixture and independent verifier, ran the tests and drafted this report. Publication authorized by the account owner.

**@⁠SzczepanGrela** on GitHub · 2026-11-27 07:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2861#issuecomment-7212388459) RX 9070 / Wine check of the initial-PSO behavior at `e235f13ce82c053db6321eadcb5080841feef54e`, compared with main `83b008188efbf954b846667f48d75e3fa9310a01` and a conflict-free application of the two-file PR diff to that main. Source copies had test-only instrumentation, so these are focused synthetic results. **Tested** RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1, Ryzen 7 7700, CachyOS 7.3.0-5, GE-Proton11-12 / Wine 11.0 Staging, vkd3d-proton `8293130ebe370b1+` with local asserts-disabled build, DXC/DXIL 1.9.2602.17. Windows-GNU release tests, Rust 1.97.1. Network off, adapter selected explicitly, private enabled caches, `XCL_PSO_WAIT_MS` unset. `cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run`, then the resulting PE under Wine: - `hle::d3d12x::real::create_command_list_standin_tests --nocapture --test-threads=1` and `=4`: head and integration each 6 passed, 0 failed. The same six unchanged test bodies copied to main give 1 passed, 5 failed, for both thread counts. - Owned `hle::d3d12x::real::workflow_initial_native::workflow_initial_psos_execute_without_rebinding --exact --nocapture --test-threads=1`: three fresh full runs per source, plus one pilot per source. All harnesses completed. Zero ignored or skipped tests. The GPU fixture covers the raw-PC helper and adopted-device PC wrapper, each with compute and graphics initial PSOs. It uses a native PSO as an async lookup key for paired controls: pending lazy success, already completed success, failed job with shared fallback, and an ordinary PSO. A pending job returns an already constructed target PSO after a controlled 30 ms delay. Main's job is completed after list creation but before recording work. No `SetPipelineState` is called. Genuine `standin::Shell` success/failure cases also execute on head and integration. Results: 219 GPU work cases, including 111 physical-wave64 compute dispatches and 108 draws. Head and integration select the expected driver PSO and produce the expected data throughout. On main, 24 full-matrix cases plus the pilot retain the earlier PSO instead of the requested completed one: compute lane 0 writes `0xd00d0000` instead of `42`, and graphics writes `(1,0,0.5,1)` instead of `(0.25,0.5,0.75,1)`. Ordinary and failed-build fallback controls work on all sources. A separate Python oracle checked all 126,576 readback words, including compute guards, every lane's wave width and every 16×16 RGBA32F pixel, plus 237 captured native creation arguments. Fresh repeats and head/integration outputs match. No device removal occurred. **Not tested** Retail workload, smoke run, full suite, native Windows, actual pending shader translation/driver compilation, wait-budget expiration or hitch/performance impact. Recording uses the native PC list after test-only removal of its adoption hooks, so implicit rebinding cannot mask the initial state. This does not exercise the console `device_x::create_list` caller or full title recording path. Allocators are native; the earlier adopted-allocator `0x80070057` boundary was not retested. A genuine Shell was not passed to main's native driver. **AI use** OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the public source, wrote the synthetic fixture and independent verifier, ran the tests and drafted this report. Publication authorized by the account owner.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-27 08:26 UTC · original

Linux (Wine) dual-lane run at e235f13c: all five new stand-in tests green on both vendor stacks, no regressions.

All of real::create_command_list_standin_tests (a_built_stand_in..., a_failed_stand_in..., a_list_made_with_a_pending_initial_state..., a_pending_stand_in..., a_raw_pc_list_over_a_driver_device...): ok on rig and boxb, both in-suite.

  • Rig (Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT, Mesa 26.2.5 RADV, Arch, wine-11.0 Proton + vkd3d-proton): 611/3 = standing two + a known sparse load flake (solo-green across runs, not yours).
  • Boxb (i5-10600K, 16 GB DDR4, GTX 1070, 550.163.01, Debian 13, wine-10.0, xvfb): 610/4 = standing three + the same sparse flake.

Head e235f13c sits on main 8b957bec (3 commits behind current tip; merge-base verified) and was compared against same-day baselines for that base (rig 606/2, boxb 605/3). Nothing moved outside the flake.

Side note from our amd-dev thread (#2764): the shader stand-in build path is where our Wine deadlock repro lives (dispatch 17 waited for the build); your a_pending_stand_in...is_waited_for... case passing here is at the main tree, not the amd-dev queue rework, so don't read this as confirming that side.

Suite: cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::.

AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-27 08:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/2861#issuecomment-7213539823) **Linux (Wine) dual-lane run at `e235f13c`: all five new stand-in tests green on both vendor stacks, no regressions.** All of `real::create_command_list_standin_tests` (`a_built_stand_in...`, `a_failed_stand_in...`, `a_list_made_with_a_pending_initial_state...`, `a_pending_stand_in...`, `a_raw_pc_list_over_a_driver_device...`): **ok on rig and boxb**, both in-suite. - Rig (Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT, Mesa 26.2.5 RADV, Arch, wine-11.0 Proton + vkd3d-proton): 611/3 = standing two + a known sparse load flake (solo-green across runs, not yours). - Boxb (i5-10600K, 16 GB DDR4, GTX 1070, 550.163.01, Debian 13, wine-10.0, xvfb): 610/4 = standing three + the same sparse flake. Head `e235f13c` sits on main `8b957bec` (3 commits behind current tip; merge-base verified) and was compared against same-day baselines for that base (rig 606/2, boxb 605/3). Nothing moved outside the flake. Side note from our amd-dev thread (#2764): the shader stand-in build path is where our Wine deadlock repro lives (`dispatch 17 waited for the build`); your `a_pending_stand_in...is_waited_for...` case passing here is at the main tree, not the amd-dev queue rework, so don't read this as confirming that side. Suite: `cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::`. AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2861/head:github-bot/gh-2861'
git switch 'github-bot/gh-2861'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2861'
git switch 'github-bot/gh-2861'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2861'
git switch 'github-bot/gh-2861'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2861'
git switch 'main'
git merge --squash 'github-bot/gh-2861'
git switch 'main'
git merge --ff-only 'github-bot/gh-2861'
git switch 'main'
git merge 'github-bot/gh-2861'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.