D3D12.X: respect compute lists and retain root signature in execute_i… #1754

Open
fixgep wants to merge 1 commit from upstream-pr/1764 into main
fixgep commented 2026-11-24 20:23:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fixgep on 2026-11-24T20:23:06Z.


Respect D3D12_COMMAND_LIST_TYPE_COMPUTE in execute_indirect, retain bound root signatures across caller Release(), and eliminate VirtualQuery (gpu::shader::readable) from the RetainedRootSig::retain hot path.

Part of #1488 (XCL-BT-019).

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs:
    • Check command-list type in execute_indirect so COMPUTE lists bind rs_cmp (SetComputeRootSignature) and never SetGraphicsRootSignature.
    • Retain bound ID3D12RootSignature COM references in RetainedRootSig so caller Release() before execute_indirect cannot leave a dangling pointer.
    • Add a same-pointer + same-layout fast path in set_graphics_root_signature and set_compute_root_signature to skip RetainedRootSig::retain (AddRef/Release) when re-binding the already-bound root signature.
    • Restrict the gpu::shader::readable (VirtualQuery) probe in RetainedRootSig::retain to #[cfg(test)]; non-test builds call ID3D12RootSignature::from_raw_borrowed(&rs).cloned() directly on non-null pointers.
    • Unit tests covering FakeTypedList (COMPUTE/DIRECT) + FakeRs refcounting/same-pointer fast path and a live D3D12 ID3D12Device compute command list.

Tested

  • Hardware: NVIDIA GeForce RTX 3060, WARP; rustc 1.100.0 (0ef1bc386 2026-11-09); debug & release (d767c523).
  • cargo build -j 4 --workspace: exited 0.
  • cargo test -j 4 --workspace --no-run: exited 0.
  • cargo build -j 4 --release -p xcl: exited 0.
  • cargo test -j 4 -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=1 (RTX 3060): 118 passed, 0 failed, 0 ignored (SKIPPED: two_pass_binds_set_the_shared_view_heap).
  • XCL_ADAPTER=warp cargo test -j 4 -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=1: 118 passed, 0 failed, 0 ignored (SKIPPED: two_pass_binds_set_the_shared_view_heap).

Regression run

xcl-smoke v1
commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1683 (PresentX 1683)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16516 MB
xcl-smoke v1
commit: d767c52379225c99e8dbbd6188410c8a39c93c4a
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1661 (PresentX 1661)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15506 MB

Not tested

  • Full cargo test --workspace -- --test-threads=4 suite was not run in this update (only hle::d3d12x::bind::tests and paired 60 s scripts/smoke.ps1).

AI use

  • Antigravity, Gemini 4 Hydrogen: removed hot-path VirtualQuery, added same-pointer fast path in set_graphics_root_signature/set_compute_root_signature, rebased onto upstream/main, ran targeted tests and paired smoke.ps1.
<!-- greyfinch-sync:ivall/xcl:issue:5479716987 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764). Originally posted by [fixgep](https://github.com/fixgep) on 2026-11-24T20:23:06Z. --- Respect `D3D12_COMMAND_LIST_TYPE_COMPUTE` in `execute_indirect`, retain bound root signatures across caller `Release()`, and eliminate `VirtualQuery` (`gpu::shader::readable`) from the `RetainedRootSig::retain` hot path. Part of #1488 (XCL-BT-019). **What is in it** - `crates/xcl/src/hle/d3d12x/bind.rs`: - Check command-list type in `execute_indirect` so `COMPUTE` lists bind `rs_cmp` (`SetComputeRootSignature`) and never `SetGraphicsRootSignature`. - Retain bound `ID3D12RootSignature` COM references in `RetainedRootSig` so caller `Release()` before `execute_indirect` cannot leave a dangling pointer. - Add a same-pointer + same-layout fast path in `set_graphics_root_signature` and `set_compute_root_signature` to skip `RetainedRootSig::retain` (`AddRef`/`Release`) when re-binding the already-bound root signature. - Restrict the `gpu::shader::readable` (`VirtualQuery`) probe in `RetainedRootSig::retain` to `#[cfg(test)]`; non-test builds call `ID3D12RootSignature::from_raw_borrowed(&rs).cloned()` directly on non-null pointers. - Unit tests covering `FakeTypedList` (`COMPUTE`/`DIRECT`) + `FakeRs` refcounting/same-pointer fast path and a live D3D12 `ID3D12Device` compute command list. **Tested** - Hardware: NVIDIA GeForce RTX 3060, WARP; `rustc 1.100.0 (0ef1bc386 2026-11-09)`; debug & release (`d767c523`). - `cargo build -j 4 --workspace`: exited 0. - `cargo test -j 4 --workspace --no-run`: exited 0. - `cargo build -j 4 --release -p xcl`: exited 0. - `cargo test -j 4 -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=1` (RTX 3060): 118 passed, 0 failed, 0 ignored (`SKIPPED`: `two_pass_binds_set_the_shared_view_heap`). - `XCL_ADAPTER=warp cargo test -j 4 -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=1`: 118 passed, 0 failed, 0 ignored (`SKIPPED`: `two_pass_binds_set_the_shared_view_heap`). **Regression run** ``` xcl-smoke v1 commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c gpu: NVIDIA GeForce RTX 3060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1683 (PresentX 1683) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16516 MB ``` ``` xcl-smoke v1 commit: d767c52379225c99e8dbbd6188410c8a39c93c4a gpu: NVIDIA GeForce RTX 3060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1661 (PresentX 1661) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15506 MB ``` **Not tested** - Full `cargo test --workspace -- --test-threads=4` suite was not run in this update (only `hle::d3d12x::bind::tests` and paired 60 s `scripts/smoke.ps1`). **AI use** - Antigravity, Gemini 4 Hydrogen: removed hot-path `VirtualQuery`, added same-pointer fast path in `set_graphics_root_signature`/`set_compute_root_signature`, rebased onto `upstream/main`, ran targeted tests and paired `smoke.ps1`.
futurepro62 commented 2026-11-24 21:30:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T21:21:31Z.


Full-suite run, since this PR has no test report yet. Tested exact head 119d483 (on its base 4178e88).

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 --skip pso_measurement_compiles_an_exact_synthetic_record: 891 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: execute_indirect_compute_list_respects_list_type_and_retains_root_signature, execute_indirect_on_d3d12_compute_list_with_and_without_root_signature.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 893 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (#1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set XCL_REQUIRE_GPU, so there both just print SKIPPED.

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:7144823351 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7144823351). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T21:21:31Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `119d483` (on its base `4178e88`). **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 --skip pso_measurement_compiles_an_exact_synthetic_record`: **891 passed, 0 failed, 42 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `execute_indirect_compute_list_respects_list_type_and_retains_root_signature`, `execute_indirect_on_d3d12_compute_list_with_and_without_root_signature`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **893 passed, 0 failed, 42 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), `pso_measurement_compiles_an_exact_synthetic_record` (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)). - Two tests were skipped with `--skip` on NVIDIA. Both fail on main `7f7e768` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns their skips into failures. `heap_window_out_of_memory_falls_back_to_the_switch_form` skips when `XCL_HEAP_WINDOWS` is unset (#1651), and `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record` skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set `XCL_REQUIRE_GPU`, so there both just print SKIPPED. **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-25 00:08:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:14:24Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7147174039 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7147174039). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T23:14:24Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
throny commented 2026-11-25 19:08:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T18:10:54Z.


Two contributors checked independently and found that #1925 solves the same problem (for #1488) in a different way: #1607, group D93. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7170552466 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7170552466). Originally posted by [throny](https://github.com/throny) on 2026-11-25T18:10:54Z. --- <!-- xcl-1607-hint:D93 --> Two contributors checked independently and found that #1925 solves the same problem (for #1488) in a different way: #1607, group D93. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
upstream-sync closed this pull request 2026-11-25 23:07:41 +00:00
CalvyPZ commented 2026-11-25 23:09:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:42:36Z.


This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.

<!-- greyfinch-sync:ivall/xcl:comment:7176695155 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7176695155). Originally posted by [CalvyPZ](https://github.com/CalvyPZ) on 2026-11-25T22:42:36Z. --- This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
upstream-sync reopened this pull request 2026-11-26 00:04:36 +00:00
github-actions[bot] commented 2026-11-29 20:44:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:44Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262324084 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7262324084). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:44Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
fixgep commented 2026-11-30 16:37:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fixgep on 2026-11-30T16:37:03Z.


Rebased onto upstream/main (9dfbe3ea), resolved the bind.rs conflict, and updated the PR description with fresh bind::tests (RTX 3060 + WARP) and paired 60s xcl-smoke results. Ready for review.

<!-- greyfinch-sync:ivall/xcl:comment:7284956711 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7284956711). Originally posted by [fixgep](https://github.com/fixgep) on 2026-11-30T16:37:03Z. --- Rebased onto `upstream/main` (`9dfbe3ea`), resolved the `bind.rs` conflict, and updated the PR description with fresh `bind::tests` (RTX 3060 + WARP) and paired 60s `xcl-smoke` results. Ready for review.
Foniass commented 2026-12-01 06:42:30 +00:00 (Migrated from github.com)

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


Triage (#1607) – head d767c52

#1925, which made the same change in bind.rs, has been closed. This PR also keeps a reference to the compute root signature and merges cleanly.
RetainedRootSig::retain no longer probes with gpu::shader::readable outside tests, and setting the same root signature again returns before retaining 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:7303180973 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1764#issuecomment-7303180973). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:42:30Z. --- **Triage (#1607)** – head d767c52 #1925, which made the same change in `bind.rs`, has been closed. This PR also keeps a reference to the compute root signature and merges cleanly. `RetainedRootSig::retain` no longer probes with `gpu::shader::readable` outside tests, and setting the same root signature again returns before retaining 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/1764:upstream-pr/1764'
git switch 'upstream-pr/1764'

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/1764'
git switch 'upstream-pr/1764'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1764'
git switch 'upstream-pr/1764'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1764'
git switch 'main'
git merge --squash 'upstream-pr/1764'
git switch 'main'
git merge --ff-only 'upstream-pr/1764'
git switch 'main'
git merge 'upstream-pr/1764'
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!1754
No description provided.