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

Open
oni-swr wants to merge 1 commit from upstream-pr/1619 into main
oni-swr commented 2026-11-24 18:17:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-24T18:17:37Z.


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

  • device_x.rs retains each tracked graphics PSO’s root signature and drops replaced or removed entries outside the registry lock. The rebase preserves #3292’s shader bytecode ownership and both lifetime tests.

Tested

  • Head d94caf384eb7b4dff9fb35a040e8fdfa419c3f57 on Windows 11 build 26200, Ryzen 7 5700X3D, Radeon RX 7800 XT (driver 32.0.31035.1003), Rust 1.100.0 MSVC, debug profile. The focused tests ran on the CPU.
  • cargo test -j 4 -p xcl --lib 'hle::d3d12x::device_x::tests::base_' -- --nocapture ran the root-signature and shader-bytecode lifetime tests. 2 passed, 0 failed, 0 ignored, 0 skipped, 2564 filtered out.

Regression run

  • The paired real-title smoke runs are pending for this head.

Not tested

  • Full workspace suite on GPU and real-title regression on main and this head.

AI use

  • Antigravity (Gemini 4 Neon) wrote the original fix and unit test. Claude Code (Claude Sonnet 5.5) and Codex (gpt-6-luna) handled prior rebases and validation.
  • Codex (gpt-6.2-sol) resolved the current conflicts, compared #1634, ran the focused tests, and updated this description.
<!-- greyfinch-sync:ivall/xcl:issue:5477843630 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-24T18:17:37Z. --- `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** - `device_x.rs` retains each tracked graphics PSO’s root signature and drops replaced or removed entries outside the registry lock. The rebase preserves #3292’s shader bytecode ownership and both lifetime tests. **Tested** - Head `d94caf384eb7b4dff9fb35a040e8fdfa419c3f57` on Windows 11 build 26200, Ryzen 7 5700X3D, Radeon RX 7800 XT (driver 32.0.31035.1003), Rust 1.100.0 MSVC, debug profile. The focused tests ran on the CPU. - `cargo test -j 4 -p xcl --lib 'hle::d3d12x::device_x::tests::base_' -- --nocapture` ran the root-signature and shader-bytecode lifetime tests. 2 passed, 0 failed, 0 ignored, 0 skipped, 2564 filtered out. **Regression run** - The paired real-title smoke runs are pending for this head. **Not tested** - Full workspace suite on GPU and real-title regression on `main` and this head. **AI use** - Antigravity (Gemini 4 Neon) wrote the original fix and unit test. Claude Code (Claude Sonnet 5.5) and Codex (gpt-6-luna) handled prior rebases and validation. - Codex (gpt-6.2-sol) resolved the current conflicts, compared #1634, ran the focused tests, and updated this description.
futurepro62 commented 2026-11-24 19:07:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:59:20Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7141432624 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7141432624). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T18:59:20Z. --- 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.
DavidM1911 commented 2026-11-24 21:09:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:37:48Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7143841389 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7143841389). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:37:48Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
JJAutoCompare commented 2026-11-25 06:05:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:08:51Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7153492991 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7153492991). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T05:08:51Z. --- # 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.
thehollowedone commented 2026-11-25 11:09:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T10:36:10Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7159919298 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7159919298). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-25T10:36:10Z. --- 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.
oni-swr commented 2026-11-25 19:09:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T18:47:55Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7171414576 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7171414576). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T18:47:55Z. --- 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.
DavidM1911 commented 2026-11-26 06:06:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:58:03Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7183967786 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7183967786). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:58:03Z. --- 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
oni-swr commented 2026-11-28 03:32:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-28T03:32:38Z.


Rebased onto current main (e429936c, after #3085 and the #2959–#2962 stack). The only conflict was two additive test blocks in device_x.rs; both are kept and the PR's code is unchanged. New head: cec364b6.

Tested (CPU/WARP only, XCL_WARP=1, no retail title, no smoke run): cargo test -p xcl --lib -j 4 d3d12x::device_x: 19 passed, 0 failed, 0 ignored, 0 skipped (includes base_retains_root_signature_until_forgotten). The full suite and a regression run were not repeated after this rebase.

AI use: Claude Code, Claude Sonnet 5.5 (rebase and targeted test run).

<!-- greyfinch-sync:ivall/xcl:comment:7233159826 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7233159826). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-28T03:32:38Z. --- Rebased onto current `main` (e429936c, after #3085 and the #2959–#2962 stack). The only conflict was two additive test blocks in `device_x.rs`; both are kept and the PR's code is unchanged. New head: cec364b6. **Tested (CPU/WARP only, `XCL_WARP=1`, no retail title, no smoke run):** `cargo test -p xcl --lib -j 4 d3d12x::device_x`: 19 passed, 0 failed, 0 ignored, 0 skipped (includes `base_retains_root_signature_until_forgotten`). The full suite and a regression run were not repeated after this rebase. **AI use:** Claude Code, Claude Sonnet 5.5 (rebase and targeted test run).
Foniass commented 2026-12-01 06:18:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:18:22Z.


Triage (#1607) – head d94caf3

#1634 makes the same change: device_x::Base holds an ID3D12RootSignature taken from the desc's pRootSignature and releases it when the base is forgotten. This PR was opened first, is mergeable, and its test also covers a replaced entry and an in-flight Arc<Base>. It also drops the old base outside the BASES lock.
The Build and test check fails on this head. The log was not available, so it is not clear whether this change causes it.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302721601 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1619#issuecomment-7302721601). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:18:22Z. --- **Triage (#1607)** – head d94caf3 #1634 makes the same change: `device_x::Base` holds an `ID3D12RootSignature` taken from the desc's `pRootSignature` and releases it when the base is forgotten. This PR was opened first, is mergeable, and its test also covers a replaced entry and an in-flight `Arc<Base>`. It also drops the old base outside the `BASES` lock. The `Build and test` check fails on this head. The log was not available, so it is not clear whether this change causes it. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1619:upstream-pr/1619'
git switch 'upstream-pr/1619'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1619'
git switch 'upstream-pr/1619'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1619'
git switch 'upstream-pr/1619'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1619'
git switch 'main'
git merge --squash 'upstream-pr/1619'
git switch 'main'
git merge --ff-only 'upstream-pr/1619'
git switch 'main'
git merge 'upstream-pr/1619'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1609
No description provided.