D3D12.X: retain pRootSignature in device_x::Base until forgotten #1619

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

@⁠oni-swr on GitHub · 2026-11-24 18:17 UTC · original
oni-swr:d3d12x/retain-base-root-signature → main · +91 −8 · 1 files · 1 commits · open

device_x::note_base copied raw D3D12_GRAPHICS_PIPELINE_STATE_DESC bytes into BASES without retaining pRootSignature. In D3D12 a title may release its ID3D12RootSignature immediately after CreateGraphicsPipelineState; later calls to CreateDerivedPipelineStateX or the RSSetDepthBiasX patched-PSO fallback would then pass a dangling pointer into CreateGraphicsPipelineState. Retain non-null pRootSignature in Base via ID3D12RootSignature::from_raw_borrowed().cloned() and release replaced or removed Base entries outside the BASES mutex lock. Part of #1488 (XCL-BT-005).

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs: retain pRootSignature in Base on note_base, drop old Base entries outside the BASES lock in note_base / forget_base / register_test_base, and add unit test base_retains_root_signature_until_forgotten. Rebased onto main 379725a; the only conflict was the end of the tests module, where both tests were kept.

Tested

  • Head 3aa4690173e1651d4d51a5681e927f88b01edb88, no uncommitted changes.
  • AMD Radeon RX 7800 XT, Windows 11 Pro build 26200, Rust 1.100.0 MSVC. Tests in debug, smoke runs in release.
  • cargo test -p xcl --lib hle::d3d12x::device_x::tests::base_retains_root_signature_until_forgotten -- --exact: 1 passed / 0 failed.
  • cargo build --workspace and cargo build --release -p xcl: passed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1254 passed / 1 failed / 46 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722, res[30] = 0x1, CPU 0x7fffffff). It fails the same way on clean main 379725a on this GPU (run separately: 0 passed / 1 failed), so it is not caused by this PR.
  • SKIPPED (7 lines, not coverage): f16_programs_on_the_gpu x4 and f32_programs_on_the_gpu x2 (unsupported V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32, #1426), and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Regression run

same title, 60 s, release, same GPU; first main, then this PR's head

xcl-smoke v1
commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1326 (PresentX 1326)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15257 MB
xcl-smoke v1
commit: 717b19885bc935ef9d0ce98e7fc13b648132dd62
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1374 (PresentX 1375)
presents per 2 s (last 3): 61 59 60
device removals: 0
crashes: 0
peak commit: 15750 MB

Not tested

  • NVIDIA, Intel, Wine. The retail title smoke run checks the runtime for regressions; it does not exercise a title releasing a root signature before CreateDerivedPipelineStateX or the patched-PSO RSSetDepthBiasX fallback. No claim of title performance improvement.
  • One workspace test fails on this GPU, on main too (see above).

AI use

  • T3 Code / Antigravity (Gemini 4 Neon): original fix, unit test and description.
  • Claude Code (Claude Sonnet 5.5): rebased onto main, resolved the conflict, reran the build, test suite and both smoke runs, and rewrote this description.
  • T3 Code / Codex (gpt-6-luna): ran the post-rebase 60-second release smoke runs on current main and this PR head, and updated the Regression run blocks.

🤖 Generated with Claude Code

**@⁠oni-swr** on GitHub · 2026-11-24 18:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619) `oni-swr:d3d12x/retain-base-root-signature` → `main` · +91 −8 · 1 files · 1 commits · open `device_x::note_base` copied raw `D3D12_GRAPHICS_PIPELINE_STATE_DESC` bytes into `BASES` without retaining `pRootSignature`. In D3D12 a title may release its `ID3D12RootSignature` immediately after `CreateGraphicsPipelineState`; later calls to `CreateDerivedPipelineStateX` or the `RSSetDepthBiasX` patched-PSO fallback would then pass a dangling pointer into `CreateGraphicsPipelineState`. Retain non-null `pRootSignature` in `Base` via `ID3D12RootSignature::from_raw_borrowed().cloned()` and release replaced or removed `Base` entries outside the `BASES` mutex lock. Part of #1488 (`XCL-BT-005`). **What is in it** - `crates/xcl/src/hle/d3d12x/device_x.rs`: retain `pRootSignature` in `Base` on `note_base`, drop old `Base` entries outside the `BASES` lock in `note_base` / `forget_base` / `register_test_base`, and add unit test `base_retains_root_signature_until_forgotten`. Rebased onto `main` `379725a`; the only conflict was the end of the `tests` module, where both tests were kept. **Tested** - Head `3aa4690173e1651d4d51a5681e927f88b01edb88`, no uncommitted changes. - AMD Radeon RX 7800 XT, Windows 11 Pro build 26200, Rust 1.100.0 MSVC. Tests in debug, smoke runs in release. - `cargo test -p xcl --lib hle::d3d12x::device_x::tests::base_retains_root_signature_until_forgotten -- --exact`: 1 passed / 0 failed. - `cargo build --workspace` and `cargo build --release -p xcl`: passed. - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1254 passed / 1 failed / 46 ignored. The one failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722, `res[30] = 0x1, CPU 0x7fffffff`). It fails the same way on clean `main` `379725a` on this GPU (run separately: 0 passed / 1 failed), so it is not caused by this PR. - `SKIPPED` (7 lines, not coverage): `f16_programs_on_the_gpu` x4 and `f32_programs_on_the_gpu` x2 (unsupported V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32, #1426), and `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). **Regression run** same title, 60 s, release, same GPU; first `main`, then this PR's head ``` xcl-smoke v1 commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1326 (PresentX 1326) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15257 MB ``` ``` xcl-smoke v1 commit: 717b19885bc935ef9d0ce98e7fc13b648132dd62 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1374 (PresentX 1375) presents per 2 s (last 3): 61 59 60 device removals: 0 crashes: 0 peak commit: 15750 MB ``` **Not tested** - NVIDIA, Intel, Wine. The retail title smoke run checks the runtime for regressions; it does not exercise a title releasing a root signature before `CreateDerivedPipelineStateX` or the patched-PSO `RSSetDepthBiasX` fallback. No claim of title performance improvement. - One workspace test fails on this GPU, on `main` too (see above). **AI use** - T3 Code / Antigravity (Gemini 4 Neon): original fix, unit test and description. - Claude Code (Claude Sonnet 5.5): rebased onto `main`, resolved the conflict, reran the build, test suite and both smoke runs, and rewrote this description. - T3 Code / Codex (gpt-6-luna): ran the post-rebase 60-second release smoke runs on current `main` and this PR head, and updated the **Regression run** blocks. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
device_x::note_base copied the raw D3D12_GRAPHICS_PIPELINE_STATE_DESC bytes into BASES without retaining pRootSignature. In D3D12 a title may release a root signature right after CreateGraphicsPipelineState; later calls to CreateDerivedPipelineStateX or the RSSetDepthBiasX patched-PSO fallback would then pass a dangling pointer into CreateGraphicsPipelineState.

Retain a non-null pRootSignature via ID3D12RootSignature::from_raw_borrowed().cloned() inside Base and drop replaced or removed Base entries outside the BASES mutex lock.

Part of #1488 (XCL-BT-005).
Assisted-by: Antigravity (Gemini 4 Neon)

Rebased onto main and re-verified with 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 04:59:40 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 18:59 UTC · original

Full-suite run, since this PR has no test report yet. Tested exact head 8cc8b6c (on its base 9e3831e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 776 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: base_retains_root_signature_until_forgotten.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • heap_window_out_of_memory_falls_back_to_the_switch_form was skipped with --skip. It fails on main 9e3831e too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWS unset). Reported as #1651.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 18:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7141432624) Full-suite run, since this PR has no test report yet. Tested exact head `8cc8b6c` (on its base `9e3831e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form`: **776 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `base_retains_root_signature_until_forgotten`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **777 passed, 0 failed, 41 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `heap_window_out_of_memory_falls_back_to_the_switch_form` was skipped with `--skip`. It fails on main `9e3831e` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (`XCL_HEAP_WINDOWS` unset). Reported as #1651. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

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

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 20:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7143841389) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:08 UTC · original

XCL PR #1619 focused Windows verification

Tested head 8cc8b6ce2b18e8bdbb6f3df577ab842ef0bd9cf0 on STOR-WINLAB from a clean detached checkout. The PR changes only crates/xcl/src/hle/d3d12x/device_x.rs.

Tested

  • Windows 11 Enterprise Evaluation x64, build 26200. AMD64 Family 23 Model 113 Stepping 0 (12 logical processors visible). Intel Arc A770 installed with driver 32.0.101.9175. DXC 1.9.2609.5 from the configured XCL tool directory. rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc).
  • cargo build --workspace succeeded. cargo test --workspace --no-run compiled the workspace test binaries. Both ran outside the Arc lock with incremental compilation and debug info disabled.
  • cargo test -p xcl --lib hle::d3d12x::device_x::tests::base_retains_root_signature_until_forgotten -- --exact ran outside the Arc lock with XCL_ADAPTER=NONE_CPU_ONLY. Parsed pr1619-focused.log counts were 1 passed, 0 failed, 0 ignored, 0 skipped, with 748 filtered out.
  • The CPU fixture verified the descriptor field offset and used a fake COM object to check AddRef on registration, survival after the caller releases its reference and the base is forgotten while an Arc<Base> is held, final release after that Arc is dropped, and release on replacement. It also checked null root signatures and stream-output exclusion.

Not tested

Coverage was limited to full-workspace compilation and the focused PR test. The full GPU workspace suite, real D3D12 pipeline creation and retail-title smoke runs were omitted.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1619-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7153492991) # XCL PR #1619 focused Windows verification Tested head `8cc8b6ce2b18e8bdbb6f3df577ab842ef0bd9cf0` on STOR-WINLAB from a clean detached checkout. The PR changes only `crates/xcl/src/hle/d3d12x/device_x.rs`. **Tested** - Windows 11 Enterprise Evaluation x64, build 26200. AMD64 Family 23 Model 113 Stepping 0 (12 logical processors visible). Intel Arc A770 installed with driver 32.0.101.9175. DXC 1.9.2609.5 from the configured XCL tool directory. rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). - `cargo build --workspace` succeeded. `cargo test --workspace --no-run` compiled the workspace test binaries. Both ran outside the Arc lock with incremental compilation and debug info disabled. - `cargo test -p xcl --lib hle::d3d12x::device_x::tests::base_retains_root_signature_until_forgotten -- --exact` ran outside the Arc lock with `XCL_ADAPTER=NONE_CPU_ONLY`. Parsed `pr1619-focused.log` counts were **1 passed, 0 failed, 0 ignored, 0 skipped**, with 748 filtered out. - The CPU fixture verified the descriptor field offset and used a fake COM object to check AddRef on registration, survival after the caller releases its reference and the base is forgotten while an `Arc<Base>` is held, final release after that Arc is dropped, and release on replacement. It also checked null root signatures and stream-output exclusion. **Not tested** Coverage was limited to full-workspace compilation and the focused PR test. The full GPU workspace suite, real D3D12 pipeline creation and retail-title smoke runs were omitted. **AI use** T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1619-focused.log` and published.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-25 10:36 UTC · original

Independent Windows run on 8cc8b6c. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.

cargo build --workspace --offline --locked -j 4 passed. cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4 finished with 777 passed, 0 failed, 41 ignored, including three runtime skips in Cargo’s pass count. The stock root-signature ownership test passed.

With the D3D12 debug layer enabled and asynchronous PSO creation off, the scratch fixture verified that XCL kept its own root-signature reference. After dropping the caller's reference, both CreateDerivedPipelineStateX and the patched depth-bias pipeline helper created native pipelines. A repeat request returned the cached variant. The device stayed healthy, and releasing both base entries cleared their metadata and the cached variant.

cargo test --offline --locked -j 4 -p xcl --lib local_retained_root_signature_supports_native_derived_pipelines -- --nocapture --test-threads=1 passed 1 of 1 without skips. Synthetic pipeline creation and cleanup coverage.

AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-25 10:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7159919298) Independent Windows run on [8cc8b6c](https://github.com/xcl-dev/xcl/commit/8cc8b6ce2b18e8bdbb6f3df577ab842ef0bd9cf0). Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11. `cargo build --workspace --offline --locked -j 4` passed. `cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4` finished with **777 passed, 0 failed, 41 ignored**, including three runtime skips in Cargo’s pass count. The stock root-signature ownership test passed. With the D3D12 debug layer enabled and asynchronous PSO creation off, the scratch fixture verified that XCL kept its own root-signature reference. After dropping the caller's reference, both `CreateDerivedPipelineStateX` and the patched depth-bias pipeline helper created native pipelines. A repeat request returned the cached variant. The device stayed healthy, and releasing both base entries cleared their metadata and the cached variant. `cargo test --offline --locked -j 4 -p xcl --lib local_retained_root_signature_supports_native_derived_pipelines -- --nocapture --test-threads=1` passed 1 of 1 without skips. Synthetic pipeline creation and cleanup coverage. AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:47 UTC · original

Rebased onto origin/main and force-pushed (--force-with-lease).

  • New head: 717b19885bc935ef9d0ce98e7fc13b648132dd62
  • Base origin/main: 3f2777019544c0ada2cd294aa792d3c378ff0df8
  • Reason: conflict in crates/xcl/src/hle/d3d12x/device_x.rs after #2280. Both sides appended a test at the end of mod tests; I kept both, and the code change is unchanged.
  • GitHub now reports the PR as MERGEABLE.

Tested (CPU only, no GPU touched; debug build, Windows 11)

  • cargo build --workspace: finished, 0 errors (3 existing warnings in xcl lib)
  • XCL_ADAPTER=NONE_CPU_ONLY cargo test -p xcl --lib hle::d3d12x::device_x::tests::base_retains_root_signature_until_forgotten -- --exact: 1 passed, 0 failed, 0 ignored

Not tested

  • Full GPU workspace suite, release build, scripts/smoke.ps1 (no xcl-smoke blocks for this head), retail title

AI use: Claude Code (Claude Sonnet 5.5): resolved the rebase conflict and ran the build and test above.

**@⁠oni-swr** on GitHub · 2026-11-25 18:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7171414576) Rebased onto `origin/main` and force-pushed (`--force-with-lease`). - New head: `717b19885bc935ef9d0ce98e7fc13b648132dd62` - Base `origin/main`: `3f2777019544c0ada2cd294aa792d3c378ff0df8` - Reason: conflict in `crates/xcl/src/hle/d3d12x/device_x.rs` after #2280. Both sides appended a test at the end of `mod tests`; I kept both, and the code change is unchanged. - GitHub now reports the PR as `MERGEABLE`. **Tested** (CPU only, no GPU touched; debug build, Windows 11) - `cargo build --workspace`: finished, 0 errors (3 existing warnings in `xcl` lib) - `XCL_ADAPTER=NONE_CPU_ONLY cargo test -p xcl --lib hle::d3d12x::device_x::tests::base_retains_root_signature_until_forgotten -- --exact`: 1 passed, 0 failed, 0 ignored **Not tested** - Full GPU workspace suite, release build, `scripts/smoke.ps1` (no `xcl-smoke` blocks for this head), retail title **AI use**: Claude Code (Claude Sonnet 5.5): resolved the rebase conflict and ran the build and test above.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 05:58 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 05:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7183967786) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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/1619/head:github-bot/gh-1619'
git switch 'github-bot/gh-1619'

Merge

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