Skip to content

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

Draft
oni-swr wants to merge 2 commits into
xcl-dev:mainfrom
oni-swr:t3/xcl-2455-pc-ccl-1126t
Draft

oni-swr wants to merge 2 commits into
xcl-dev:mainfrom
oni-swr:t3/xcl-2455-pc-ccl-1126t

Conversation

@oni-swr

@oni-swr oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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

…stand-in

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 xcl-dev#2455.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

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 <noreply@anthropic.com>
@oni-swr

oni-swr commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

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

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).

@SzczepanGrela

Copy link
Copy Markdown

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.

@SlopTart

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants