D3D12.X: MakeResident and Evict give the driver the pipeline behind a stand-in #2523

Open
github-bot wants to merge 1 commit from github-bot/gh-2523 into main AGit
Owner

@⁠oni-swr on GitHub · 2026-11-25 21:33 UTC · original
oni-swr:t3/xcl-fix-2455-standin-hooks → main · +298 −2 · 3 files · 1 commits · draft

A shared stand-in (standin::shell) is a Rust object, not a D3D12Core pipeline. Device #34 MakeResident and #35 Evict keep the PC layout for console code and had no override, so a stand-in pipeline in the title's ppObjects array reached the driver as *mut Shell. Both are overridden now: each shell goes to the driver as the pipeline behind it (the real one once built, otherwise its shared driver pipeline) in a copy of the array. The title's array is not changed, and a residency call does not start or wait for a lazy build.

Fixes #2455

I checked each entry point in #2455 against main @ 6d12f58a. Title code cannot reach the others, so this PR leaves them alone:

  • #46 SetResidencyPriority, #51 EnqueueMakeResident: device slots from #44 that are not in console_slots are console extensions (console_extensions). A title call gets the logged S_OK stub and never reaches D3D12Core.
  • ID3D12PipelineLibrary::StorePipeline: console device #44 is CreatePlacedResourceX, so a title never gets a native pipeline library. Only the runtime can reach the PC CreatePipelineLibrary, and it has no shells. (#2001 would wire up a pipeline library. If it lands, StorePipeline needs this treatment.)
  • PC CreateCommandList (dev_create_command_list): title calls of #12 are split to device_x::create_command_list_pc, which resolves pInitialState. XCL's own callers pass resolved pipelines or 0 (create_list, create_raw_pc_command_list from list_x), and console-shaped lists turn shared stand-ins off.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: dev_make_resident / dev_evict overrides via with_driver_objects, plus CPU tests (residency_tests) with a fake adopted device and fake driver methods
  • crates/xcl/src/hle/d3d12x/standin.rs: driver_object (shell → driver pipeline, any other object unchanged). The shells' vtable moves to a module static so a non-shell is told apart without making the vtable.
  • crates/xcl/src/hle/d3d12x/pso_async.rs: current, the pipeline behind a stand-in now, without building or waiting

Tested

  • AMD Ryzen 7 5700X3D, Windows 11 Pro 10.0.26200, Rust 1.100.0, debug, CPU only (XCL_ADAPTER=NONE_CPU_ONLY; the GPU was in use by another job), commit 8b290bf2
  • cargo build --workspace -j 4: OK
  • cargo test -j 4 -p xcl --lib -- hle::d3d12x::standin:: hle::d3d12x::pso_async:: hle::d3d12x::real::residency_tests::: 19 passed, 0 failed, 0 ignored, no SKIPPED
  • Negative control: with driver_object bypassed in with_driver_objects, residency_calls_give_the_driver_the_pipeline_behind_a_stand_in fails because the driver gets the shell's address. The other two tests pass.
  • cargo clippy -p xcl --lib --tests: no warnings on the changed lines. The crate fails clippy on main already (3 approx_constant errors in gpu/dxil/lower_valu.rs, lower_wide.rs, gpu/recomp/lower.rs).
  • cargo fmt --check: no diffs on the changed lines. The tree is not rustfmt-clean, so only the new items were formatted.

Regression run

  • Not run yet: scripts/smoke.ps1 needs the GPU, which another job holds. This PR stays a draft until both xcl-smoke blocks are added.

Not tested

  • The whole suite on a GPU (cargo test --workspace), and GPU tests in general
  • A retail title smoke run (scripts/smoke.ps1) on main and on this head
  • A title that actually passes a stand-in pipeline to MakeResident / Evict. The fix is only checked with fake objects.

AI use

  • Claude Code (Claude Opus 5.5): checked the issue's entry points against main, wrote the code, the tests and this description, and ran the commands above.

🤖 Generated with Claude Code

**@⁠oni-swr** on GitHub · 2026-11-25 21:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2523) `oni-swr:t3/xcl-fix-2455-standin-hooks` → `main` · +298 −2 · 3 files · 1 commits · draft A shared stand-in (`standin::shell`) is a Rust object, not a D3D12Core pipeline. Device #34 `MakeResident` and #35 `Evict` keep the PC layout for console code and had no override, so a stand-in pipeline in the title's `ppObjects` array reached the driver as `*mut Shell`. Both are overridden now: each shell goes to the driver as the pipeline behind it (the real one once built, otherwise its shared driver pipeline) in a copy of the array. The title's array is not changed, and a residency call does not start or wait for a lazy build. Fixes #2455 I checked each entry point in #2455 against `main @ 6d12f58a`. Title code cannot reach the others, so this PR leaves them alone: - **#46 `SetResidencyPriority`, #51 `EnqueueMakeResident`:** device slots from #44 that are not in `console_slots` are console extensions (`console_extensions`). A title call gets the logged S_OK stub and never reaches D3D12Core. - **`ID3D12PipelineLibrary::StorePipeline`:** console device #44 is `CreatePlacedResourceX`, so a title never gets a native pipeline library. Only the runtime can reach the PC `CreatePipelineLibrary`, and it has no shells. (#2001 would wire up a pipeline library. If it lands, `StorePipeline` needs this treatment.) - **PC `CreateCommandList` (`dev_create_command_list`):** title calls of #12 are split to `device_x::create_command_list_pc`, which resolves `pInitialState`. XCL's own callers pass resolved pipelines or 0 (`create_list`, `create_raw_pc_command_list` from `list_x`), and console-shaped lists turn shared stand-ins off. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `dev_make_resident` / `dev_evict` overrides via `with_driver_objects`, plus CPU tests (`residency_tests`) with a fake adopted device and fake driver methods - `crates/xcl/src/hle/d3d12x/standin.rs`: `driver_object` (shell → driver pipeline, any other object unchanged). The shells' vtable moves to a module static so a non-shell is told apart without making the vtable. - `crates/xcl/src/hle/d3d12x/pso_async.rs`: `current`, the pipeline behind a stand-in now, without building or waiting **Tested** - AMD Ryzen 7 5700X3D, Windows 11 Pro 10.0.26200, Rust 1.100.0, debug, CPU only (`XCL_ADAPTER=NONE_CPU_ONLY`; the GPU was in use by another job), commit `8b290bf2` - `cargo build --workspace -j 4`: OK - `cargo test -j 4 -p xcl --lib -- hle::d3d12x::standin:: hle::d3d12x::pso_async:: hle::d3d12x::real::residency_tests::`: 19 passed, 0 failed, 0 ignored, no SKIPPED - Negative control: with `driver_object` bypassed in `with_driver_objects`, `residency_calls_give_the_driver_the_pipeline_behind_a_stand_in` fails because the driver gets the shell's address. The other two tests pass. - `cargo clippy -p xcl --lib --tests`: no warnings on the changed lines. The crate fails clippy on `main` already (3 `approx_constant` errors in `gpu/dxil/lower_valu.rs`, `lower_wide.rs`, `gpu/recomp/lower.rs`). - `cargo fmt --check`: no diffs on the changed lines. The tree is not rustfmt-clean, so only the new items were formatted. **Regression run** - Not run yet: `scripts/smoke.ps1` needs the GPU, which another job holds. This PR stays a draft until both `xcl-smoke` blocks are added. **Not tested** - The whole suite on a GPU (`cargo test --workspace`), and GPU tests in general - A retail title smoke run (`scripts/smoke.ps1`) on `main` and on this head - A title that actually passes a stand-in pipeline to `MakeResident` / `Evict`. The fix is only checked with fake objects. **AI use** - Claude Code (Claude Opus 5.5): checked the issue's entry points against `main`, wrote the code, the tests and this description, and ran the commands above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A shared stand-in (`standin::shell`) is a Rust object, not a D3D12Core
pipeline. Device #34 MakeResident and #35 Evict keep the PC layout for
console code and had no override, so a stand-in pipeline in the title's
object array reached the driver as `*mut Shell`.

Both are overridden now: each shell in the array goes to the driver as
the pipeline behind it (the real one once built, else its shared driver
pipeline), in a copy of the array; the title's array is left as it is.
`pso_async::current` looks the pipeline up without building or waiting
for it, so a residency call does not start a lazy build.

The other entry points named in #2455 are not reachable by title code on
main: device #46 SetResidencyPriority and #51 EnqueueMakeResident are
console extensions there (a logged S_OK stub), #44 is the console's
CreatePlacedResourceX (no native pipeline library for StorePipeline),
and #12 CreateCommandList goes to `create_command_list_pc`, which
resolves the initial pipeline.

Fixes #2455

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:51 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 21:54 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 21:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/2523#issuecomment-7175684016) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 22:49 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of residency_calls_give_the_driver_the_pipeline_behind_a_stand_in and residency_calls_without_stand_ins_hand_the_driver_the_titles_array: 2 passed.

Not tested: retail titles (no title data on this lane, counts only).

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

**@⁠SlopTart** on GitHub · 2026-11-25 22:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2523#issuecomment-7176837105) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `residency_calls_give_the_driver_the_pipeline_behind_a_stand_in` and `residency_calls_without_stand_ins_hand_the_driver_the_titles_array`: 2 passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 00:24 UTC · original

Synthetic verification on Windows for head 8b290bf2944d9dd30cfc5c1f234b4cf312975331.

  • cargo build --workspace -j 4 passed.
  • cargo test --workspace -j 4 --no-fail-fast -- --test-threads=4 --show-output reported 1,425 passed, 1 failed, and 46 ignored. Seven skip messages already reflected in Cargo’s counts covered six direct-DXIL subcases and one heap-window test.
  • All three residency tests passed. The sole failure, fuzz_validate_and_gpu_1 at seed 722, also reproduced in the preceding run on main at e1d84b7d.
  • Test host was an RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 25H2 (26200.9974), and Rust 1.100.0 in debug mode. XCL_ADAPTER selected the AMD card and XCL_SAMPLE_* was unset.

Real-title smoke remains pending. The PR is still a draft.

AI use: Codex (gpt-6.2-sol) ran the verification and prepared this report.

**@⁠oni-swr** on GitHub · 2026-11-26 00:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2523#issuecomment-7178730546) Synthetic verification on Windows for head `8b290bf2944d9dd30cfc5c1f234b4cf312975331`. - `cargo build --workspace -j 4` passed. - `cargo test --workspace -j 4 --no-fail-fast -- --test-threads=4 --show-output` reported 1,425 passed, 1 failed, and 46 ignored. Seven skip messages already reflected in Cargo’s counts covered six direct-DXIL subcases and one heap-window test. - All three residency tests passed. The sole failure, `fuzz_validate_and_gpu_1` at seed 722, also reproduced in the preceding run on `main` at `e1d84b7d`. - Test host was an RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 25H2 (26200.9974), and Rust 1.100.0 in debug mode. `XCL_ADAPTER` selected the AMD card and `XCL_SAMPLE_*` was unset. Real-title smoke remains pending. The PR is still a draft. AI use: Codex (gpt-6.2-sol) ran the verification and prepared this report.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:11 UTC · original · reviewed

This removes the Rust shell pointer from the driver call, but replaces it with a native pipeline state object. Microsoft's MakeResident contract and Evict contract limit residency changes to descriptor heaps, heaps, committed resources, and query heaps; a PSO is not supported even though it implements ID3D12Pageable. A mixed array with a real heap and a stand-in still reaches the native call with an unsupported PSO entry. The fake driver in the new tests records and accepts that array, so it cannot establish the real call's behavior.

Could the shell entry be handled explicitly before forwarding the supported objects, and could a real D3D12 device/debug-layer test check the HRESULT and diagnostics for a mixed array? I have not observed a driver failure or run a title; this is an exact-head API-contract review of 8b290bf2944d9dd30cfc5c1f234b4cf312975331. AI-assisted review with Codex.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/2523#pullrequestreview-6069887210) · **reviewed** This removes the Rust shell pointer from the driver call, but replaces it with a native pipeline state object. [Microsoft's `MakeResident` contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-makeresident) and [`Evict` contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-evict) limit residency changes to descriptor heaps, heaps, committed resources, and query heaps; a PSO is not supported even though it implements `ID3D12Pageable`. A mixed array with a real heap and a stand-in still reaches the native call with an unsupported PSO entry. The fake driver in the new tests records and accepts that array, so it cannot establish the real call's behavior. Could the shell entry be handled explicitly before forwarding the supported objects, and could a real D3D12 device/debug-layer test check the HRESULT and diagnostics for a mixed array? I have not observed a driver failure or run a title; this is an exact-head API-contract review of `8b290bf2944d9dd30cfc5c1f234b4cf312975331`. AI-assisted review with Codex.
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/2523/head:github-bot/gh-2523'
git switch 'github-bot/gh-2523'

Merge

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