Shaders: validate prepared libraries on the runtime device #3448

Merged
bmjask merged 4 commits from upstream-pr/3448 into main 2026-11-29 20:20:00 +00:00
bmjask commented 2026-11-29 18:07:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T18:07:56Z.


Validates and opens prepared native pipeline libraries on the runtime D3D12 device, eliminating the temporary preparation device and duplicate library-open work on warm launch.

Stacked on #3447; only commit 7599439b belongs here.

What is in it

  • Adapter-based driver identity without creating a temporary D3D12 preparation device.
  • Cheap size/integrity checks before launch and one real validation/open on the runtime device.
  • Receipt migration commits only after runtime-device validation succeeds.

Tested

  • NVIDIA GeForce RTX 4090, driver 610.88; Intel Core i9-12900K; Windows 11 Pro build 26200; Rust 1.100.0, debug and bench profiles.
  • cargo test -p xcl --lib warm_library -- --test-threads=4: 10 passed, 0 failed.
  • Focused pipeline-library tests: 6 passed, 0 failed.
  • On stacked head db569c7d, .\scripts\test.ps1: 2,748 passed, 0 failed, 49 ignored; 29 GPU tests explicitly skipped for unsupported/opt-in hardware paths.

Regression run

xcl-smoke v1
commit: 0fe06eb0f05459007ebfffc67bb9983acb3a832d
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1485 (PresentX 1485)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16909 MB
xcl-smoke v1
commit: 7599439b3cf23356315f2d653aedf7de1df4a02c
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1583 (PresentX 1583)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14881 MB

Not tested

  • Prepared-corpus activation/AOT behavior in the retail-title smoke: the staged corpus was temporarily absent and XCL_PREPARE=0, so the run exercised the runtime/JIT path only.
  • AMD, wave64, heap-window opt-in, GPU_UPLOAD heaps, or dxil.dll paths.

AI use

  • Codex with GPT-5 implemented and tested the change. The final diff and reported commands were reviewed from this worktree.
<!-- greyfinch-sync:ivall/xcl:issue:5553578133 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3448). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-29T18:07:56Z. --- Validates and opens prepared native pipeline libraries on the runtime D3D12 device, eliminating the temporary preparation device and duplicate library-open work on warm launch. Stacked on #3447; only commit `7599439b` belongs here. **What is in it** - Adapter-based driver identity without creating a temporary D3D12 preparation device. - Cheap size/integrity checks before launch and one real validation/open on the runtime device. - Receipt migration commits only after runtime-device validation succeeds. **Tested** - NVIDIA GeForce RTX 4090, driver 610.88; Intel Core i9-12900K; Windows 11 Pro build 26200; Rust 1.100.0, debug and bench profiles. - `cargo test -p xcl --lib warm_library -- --test-threads=4`: 10 passed, 0 failed. - Focused pipeline-library tests: 6 passed, 0 failed. - On stacked head `db569c7d`, `.\scripts\test.ps1`: 2,748 passed, 0 failed, 49 ignored; 29 GPU tests explicitly skipped for unsupported/opt-in hardware paths. **Regression run** ``` xcl-smoke v1 commit: 0fe06eb0f05459007ebfffc67bb9983acb3a832d gpu: NVIDIA GeForce RTX 4090 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1485 (PresentX 1485) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16909 MB ``` ``` xcl-smoke v1 commit: 7599439b3cf23356315f2d653aedf7de1df4a02c gpu: NVIDIA GeForce RTX 4090 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1583 (PresentX 1583) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14881 MB ``` **Not tested** - Prepared-corpus activation/AOT behavior in the retail-title smoke: the staged corpus was temporarily absent and `XCL_PREPARE=0`, so the run exercised the runtime/JIT path only. - AMD, wave64, heap-window opt-in, GPU_UPLOAD heaps, or `dxil.dll` paths. **AI use** - Codex with GPT-5 implemented and tested the change. The final diff and reported commands were reviewed from this worktree.
andrewDoing commented 2026-11-29 19:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T19:09:01Z.


On 7599439b3cf23356315f2d653aedf7de1df4a02c, the runtime device rejected a same-size corrupt prepared compute library, but cache-only startup reached the null backend instead of returning a launch error. I used the synthetic native library from cold_publish_makes_an_unchanged_corpus_reusable and tested two fresh processes with XCL_PREPARE_CACHE_ONLY=1.

1,396-byte library cache_status prepare_for_launch backend_before_guest
Valid driver output compatible, exit 0 succeeded Real (RTX 5070)
File replaced with zeros, receipt unchanged compatible, exit 0 succeeded Null

The corrupt case logged Pipeline library: runtime compute activation failed with 0x80070057. The real device backend correctly rejected the bytes. backend_with_remap handled that like a device-init failure and selected Null. The caller in host.rs discards the result of backend_before_guest. This is the next stage of the #3445 status discrepancy. It would help to propagate the activation error to the host in cache-only mode. For ordinary launches, an invalid prepared blob can be treated as a cache miss while keeping the real D3D12 device.

cargo test --offline --locked -p xcl --lib -- shaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable --exact --test-threads=1 --nocapture: one pass per process, zero skips. RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0, debug. The fixture calls the production preparation and backend entry points directly. No guest or retail title was launched. Codex with GPT-6.2 Sol adapted and ran the fixture.

I tested a companion commit that preserves the original activation error through the host startup check. A valid cache kept the Real backend in cache-only mode, the same-size corrupt cache returned the 0x80070057 activation error in cache-only mode, and an ordinary launch with that corrupt cache kept the Real backend without an active prepared library. All three fresh-process checks passed with zero skips. The 16 focused tests from cargo test --offline --locked -p xcl --lib -- shaders::warm_library:: shaders::pipeline_library:: --test-threads=1 --nocapture also passed with zero skips. The companion addresses startup behavior. The status command still reports receipt identity and size.

<!-- greyfinch-sync:ivall/xcl:comment:7261048246 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3448#issuecomment-7261048246). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-29T19:09:01Z. --- On `7599439b3cf23356315f2d653aedf7de1df4a02c`, the runtime device rejected a same-size corrupt prepared compute library, but cache-only startup reached the null backend instead of returning a launch error. I used the synthetic native library from `cold_publish_makes_an_unchanged_corpus_reusable` and tested two fresh processes with `XCL_PREPARE_CACHE_ONLY=1`. | 1,396-byte library | `cache_status` | `prepare_for_launch` | `backend_before_guest` | | --- | --- | --- | --- | | Valid driver output | compatible, exit 0 | succeeded | Real (RTX 5070) | | File replaced with zeros, receipt unchanged | compatible, exit 0 | succeeded | Null | The corrupt case logged `Pipeline library: runtime compute activation failed` with `0x80070057`. The real device backend correctly rejected the bytes. `backend_with_remap` handled that like a device-init failure and selected Null. The caller in `host.rs` discards the result of `backend_before_guest`. This is the next stage of the [#3445 status discrepancy](https://github.com/xcl-dev/xcl/pull/3445#issuecomment-7260432486). It would help to propagate the activation error to the host in cache-only mode. For ordinary launches, an invalid prepared blob can be treated as a cache miss while keeping the real D3D12 device. `cargo test --offline --locked -p xcl --lib -- shaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable --exact --test-threads=1 --nocapture`: one pass per process, zero skips. RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0, debug. The fixture calls the production preparation and backend entry points directly. No guest or retail title was launched. Codex with GPT-6.2 Sol adapted and ran the fixture. I tested a [companion commit](https://github.com/andrewDoing/xcl/commit/544548b9a1419482920c0af0473f587c77f9d1c4) that preserves the original activation error through the host startup check. A valid cache kept the Real backend in cache-only mode, the same-size corrupt cache returned the `0x80070057` activation error in cache-only mode, and an ordinary launch with that corrupt cache kept the Real backend without an active prepared library. All three fresh-process checks passed with zero skips. The 16 focused tests from `cargo test --offline --locked -p xcl --lib -- shaders::warm_library:: shaders::pipeline_library:: --test-threads=1 --nocapture` also passed with zero skips. The companion addresses startup behavior. The status command still reports receipt identity and size.
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!3448
No description provided.