Shaders: fail closed when prepared caches differ #3445

Merged
bmjask merged 1 commit from upstream-pr/3445 into main 2026-11-29 20:19:28 +00:00
bmjask commented 2026-11-29 18:07:17 +00:00 (Migrated from github.com)

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


Adds a fail-closed mode for prepared pipeline caches so launch cannot silently fall back to expensive preparation when cache identity differs.

What is in it

  • XCL_PREPARE_CACHE_ONLY=1 rejects missing or incompatible prepared caches.
  • xcl cache status reports saved and current cache compatibility without preparing pipelines.
  • Unit coverage for missing, compatible, and incompatible cache states.

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.
  • Focused cache-only/status/settings tests: 3 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: dbe1ca6163cd3e91dc4e5a41f5fd3dde4c532ba0
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1529 (PresentX 1529)
presents per 2 s (last 3): 61 60 61
device removals: 0
crashes: 0
peak commit: 17022 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:5553572545 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3445). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-29T18:07:17Z. --- Adds a fail-closed mode for prepared pipeline caches so launch cannot silently fall back to expensive preparation when cache identity differs. **What is in it** - `XCL_PREPARE_CACHE_ONLY=1` rejects missing or incompatible prepared caches. - `xcl cache status` reports saved and current cache compatibility without preparing pipelines. - Unit coverage for missing, compatible, and incompatible cache states. **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. - Focused cache-only/status/settings tests: 3 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: dbe1ca6163cd3e91dc4e5a41f5fd3dde4c532ba0 gpu: NVIDIA GeForce RTX 4090 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1529 (PresentX 1529) presents per 2 s (last 3): 61 60 61 device removals: 0 crashes: 0 peak commit: 17022 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 18:22:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T18:22:35Z.


On dbe1ca6163cd3e91dc4e5a41f5fd3dde4c532ba0, the cache-only launch guard rejected a driver blob that xcl cache status still reported as compatible. I extended the existing cold_publish_makes_an_unchanged_corpus_reusable native fixture. With XCL_PREPARE_CACHE_ONLY=1, the original 1,396-byte compute library was reused successfully. Then the fixture replaced only that blob with 1,396 zero bytes, keeping the receipt, expected size, corpus and settings fixed.

The command's cache_status entry point returned 0 and printed pipeline cache: compatible and compute library: 1396 bytes, present for both files. The same fixture's prepare_for_launch correctly returned the prepared native pipeline cache is not reusable for the replaced file. This is a diagnostic mismatch. If the status command is intended for callers to check launch readiness, it can reuse the existing native-library validation without preparing any PSOs. If it is intended to compare only identity and size, naming that explicitly in the output would distinguish it from launch readiness.

cargo test --offline --locked -p xcl --lib -- shaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable shaders::warm_library::tests::status_names_each_changed_identity --exact --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored, 0 skips. RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0 debug. This synthetic driver-library fixture does not load a retail title. Codex with GPT-6.2 Sol adapted the fixture and ran the controls.

<!-- greyfinch-sync:ivall/xcl:comment:7260432486 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3445#issuecomment-7260432486). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-29T18:22:35Z. --- On `dbe1ca6163cd3e91dc4e5a41f5fd3dde4c532ba0`, the cache-only launch guard rejected a driver blob that `xcl cache status` still reported as compatible. I extended the existing `cold_publish_makes_an_unchanged_corpus_reusable` native fixture. With `XCL_PREPARE_CACHE_ONLY=1`, the original 1,396-byte compute library was reused successfully. Then the fixture replaced only that blob with 1,396 zero bytes, keeping the receipt, expected size, corpus and settings fixed. The command's `cache_status` entry point returned 0 and printed `pipeline cache: compatible` and `compute library: 1396 bytes, present` for both files. The same fixture's `prepare_for_launch` correctly returned `the prepared native pipeline cache is not reusable` for the replaced file. This is a diagnostic mismatch. If the status command is intended for callers to check launch readiness, it can reuse the existing native-library validation without preparing any PSOs. If it is intended to compare only identity and size, naming that explicitly in the output would distinguish it from launch readiness. `cargo test --offline --locked -p xcl --lib -- shaders::warm_library::tests::cold_publish_makes_an_unchanged_corpus_reusable shaders::warm_library::tests::status_names_each_changed_identity --exact --test-threads=1 --nocapture`: 2 passed, 0 failed, 0 ignored, 0 skips. RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0 debug. This synthetic driver-library fixture does not load a retail title. Codex with GPT-6.2 Sol adapted the fixture and ran the controls.
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!3445
No description provided.