D3D12.X: StorePipeline gives the driver the pipeline behind a stand-in #2853

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

@⁠oni-swr on GitHub · 2026-11-26 19:00 UTC · original
oni-swr:t3/xcl-2455-store-pipeline-1126r → main · +184 −0 · 3 files · 1 commits · draft

ID3D12PipelineLibrary::StorePipeline handed the title's pointer to D3D12Core.dll as it was. A pipeline that is not built yet is a stand-in: a standin::Shell (no driver object) over a dummy driver pipeline shared by many titles' pipelines. The driver therefore got a pointer to a Shell, or (with XCL_SHARED_STANDINS=0) stored the dummy under the title's name for a later Load* / Serialize. This is the StorePipeline part of #2455 only.

Part of #2455. Independent of #2523 (MakeResident / Evict); touches different lines.

What is in it

  • real.rs: StorePipeline override on Kind::PipelineLibrary (lib_store_pipeline → store_pipeline / pipeline_to_store) and 5 CPU-only unit tests (store_pipeline_tests).
  • pso_async.rs: built(pso), a non-blocking lookup of a stand-in's real pipeline (Other / Real / NotYet).
  • standin.rs: is_shell(obj), true for one of our shells.

Behaviour:

  • Not a stand-in: forwarded unchanged (the driver judges null, foreign objects).
  • Built stand-in: the real pipeline is stored under the title's name.
  • Not built yet, build failed, or a shell with no entry: nothing is stored and the title gets E_INVALIDARG (logged for the first 3). A later StorePipeline of the same name works once the pipeline is built.
  • It does not wait (resolve_wait): a lazy pipeline is built only when bound (XCL_LAZY_PSO), and a wait would build every pipeline a title stores, defeating lazy creation (commit exhaustion), and could hold the title's thread for the driver's compile time. It does not call resolve either, which would enqueue a build.

Tested

  • CPU only; no GPU was used (XCL_ADAPTER=NONE_CPU_ONLY). Windows 11, stable-x86_64-pc-windows-msvc, debug.
  • cargo check --workspace --tests -j 4: finished, no errors.
  • cargo test -p xcl --lib -j 4 store_pipeline_tests: 5 passed, 0 failed, 0 ignored
  • cargo test -p xcl --lib -j 4 d3d12x::standin: 2 passed; d3d12x::pso_async: 14 passed
  • With the fix disabled (pipeline_to_store returning its argument), store_pipeline_tests: 1 passed, 4 failed; restored afterwards.
  • The tests drive store_pipeline with a fake driver callback and fake COM objects: pass-through, built stand-in → real pipeline (never the Shell or the dummy), lazy-unbuilt, failed build, shell with no entry.

Regression run

  • Not run. The full GPU suite (cargo test --workspace -- --test-threads=4) and the paired scripts/smoke.ps1 runs (main and this head) are pending a free RX 7800 XT (it was in use by another run). They will be pasted here; the PR checks workflow will refuse this PR until then, hence draft.

Not tested

  • The whole suite, any GPU test, scripts/smoke.ps1, any retail title: all pending a free GPU.
  • The real vtable override path (adopt + slot_of on a native ID3D12PipelineLibrary) was not exercised: the tests cover the logic behind it, not the dispatch. No native library was created.
  • ID3D12PipelineLibrary1::LoadPipeline, GetCachedBlob on a shell (see the comment on #2455) and other entry points are out of scope.
  • AMD / NVIDIA, wave32-only GPUs.

AI use

  • Claude Code, Claude Sonnet 5.5: wrote the change, the tests and this description; ran the CPU tests above.

🤖 Generated with Claude Code

**@⁠oni-swr** on GitHub · 2026-11-26 19:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2853) `oni-swr:t3/xcl-2455-store-pipeline-1126r` → `main` · +184 −0 · 3 files · 1 commits · draft `ID3D12PipelineLibrary::StorePipeline` handed the title's pointer to D3D12Core.dll as it was. A pipeline that is not built yet is a stand-in: a `standin::Shell` (no driver object) over a dummy driver pipeline shared by many titles' pipelines. The driver therefore got a pointer to a Shell, or (with `XCL_SHARED_STANDINS=0`) stored the dummy under the title's name for a later `Load*` / `Serialize`. This is the `StorePipeline` part of #2455 only. Part of #2455. Independent of #2523 (MakeResident / Evict); touches different lines. **What is in it** - `real.rs`: `StorePipeline` override on `Kind::PipelineLibrary` (`lib_store_pipeline` → `store_pipeline` / `pipeline_to_store`) and 5 CPU-only unit tests (`store_pipeline_tests`). - `pso_async.rs`: `built(pso)`, a non-blocking lookup of a stand-in's real pipeline (`Other` / `Real` / `NotYet`). - `standin.rs`: `is_shell(obj)`, true for one of our shells. Behaviour: - Not a stand-in: forwarded unchanged (the driver judges null, foreign objects). - Built stand-in: the **real** pipeline is stored under the title's name. - Not built yet, build failed, or a shell with no entry: nothing is stored and the title gets `E_INVALIDARG` (logged for the first 3). A later `StorePipeline` of the same name works once the pipeline is built. - It does **not** wait (`resolve_wait`): a lazy pipeline is built only when bound (`XCL_LAZY_PSO`), and a wait would build every pipeline a title stores, defeating lazy creation (commit exhaustion), and could hold the title's thread for the driver's compile time. It does not call `resolve` either, which would enqueue a build. **Tested** - CPU only; no GPU was used (`XCL_ADAPTER=NONE_CPU_ONLY`). Windows 11, stable-x86_64-pc-windows-msvc, debug. - `cargo check --workspace --tests -j 4`: finished, no errors. - `cargo test -p xcl --lib -j 4 store_pipeline_tests`: 5 passed, 0 failed, 0 ignored - `cargo test -p xcl --lib -j 4 d3d12x::standin`: 2 passed; `d3d12x::pso_async`: 14 passed - With the fix disabled (`pipeline_to_store` returning its argument), `store_pipeline_tests`: 1 passed, 4 failed; restored afterwards. - The tests drive `store_pipeline` with a fake driver callback and fake COM objects: pass-through, built stand-in → real pipeline (never the Shell or the dummy), lazy-unbuilt, failed build, shell with no entry. **Regression run** - Not run. The full GPU suite (`cargo test --workspace -- --test-threads=4`) and the paired `scripts/smoke.ps1` runs (main and this head) are pending a free RX 7800 XT (it was in use by another run). They will be pasted here; the `PR checks` workflow will refuse this PR until then, hence draft. **Not tested** - The whole suite, any GPU test, `scripts/smoke.ps1`, any retail title: all pending a free GPU. - The real vtable override path (`adopt` + `slot_of` on a native `ID3D12PipelineLibrary`) was not exercised: the tests cover the logic behind it, not the dispatch. No native library was created. - `ID3D12PipelineLibrary1::LoadPipeline`, `GetCachedBlob` on a shell (see the comment on #2455) and other entry points are out of scope. - AMD / NVIDIA, wave32-only GPUs. **AI use** - Claude Code, Claude Sonnet 5.5: wrote the change, the tests and this description; ran the CPU tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A title's pipeline that is not built yet is a stand-in: a `standin::Shell`
(no driver object) over a dummy driver pipeline shared by many. The library
passed the title's pointer to D3D12Core.dll as it was, so the driver got a
Shell it cannot use, or (with XCL_SHARED_STANDINS=0) stored the dummy under
the title's name for a later Load / Serialize.

StorePipeline on Kind::PipelineLibrary now stores the real pipeline once it
is built and leaves a pointer that is no stand-in alone. A stand-in whose real
pipeline is not built, or whose build failed, is not stored: the title gets
E_INVALIDARG and may store it again later. It does not wait for the build
(a lazy pipeline is not built until a bind asks), so storing never builds
what the title does not use.

Part of #2455.

Assisted-by: Claude Code (Claude Sonnet 5.5)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:00:42 +00:00
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/2853/head:github-bot/gh-2853'
git switch 'github-bot/gh-2853'

Merge

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