Shaders: keep cache activation failures off the null renderer #3467

Open
bmjask wants to merge 1 commit from upstream-pr/3467 into main
bmjask commented 2026-11-29 22:27:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:27:03Z.


A prepared pipeline library can pass receipt and size checks but still be rejected when the runtime D3D12 device opens it. Since #3448, that cache activation error propagated as real-device initialization failure and selected the null renderer.

This follow-up keeps the real renderer active and falls back to runtime/JIT pipeline creation during a normal launch. XCL_PREPARE_CACHE_ONLY=1 remains fail-closed and stops before guest entry. The change does not alter pipeline descriptors, shader translation, receipt identities, or cache keys.

What is in it

  • pipeline_library.rs: separates prepared-library opening from activation policy and records strict startup failures.
  • d3d12x / host.rs: keeps normal launches on the real renderer and stops strict launches before guest entry.
  • Tests cover policy and real-D3D12 corrupt-library rejection.

Tested

  • Hardware: NVIDIA GeForce RTX 4090, Windows, debug and release.
  • cargo test -p xcl --lib "shaders::pipeline_library::tests" -- --test-threads=1: 8 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib warm_library -- --test-threads=4: 10 passed, 0 failed, 0 ignored.
  • .\scripts\test.ps1: 2,778 passed, 0 failed, 49 ignored. GPU skips: 8 no-wave64 aggregate plus 15 reported feature/instruction skips (no heap windows, no GPU_UPLOAD heaps, no dxil.dll, wave64 and unsupported per-lane forms).

Regression run
Base:

xcl-smoke v1
commit: 5b0d5fa3d65d9aa61567f8603154d818a9307846
gpu: NVIDIA GeForce RTX 4090
title: retail-fixture
seconds: 60
exit: 0x0
frames shown: 1516 (PresentX 1516)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16888 MB

Head:

xcl-smoke v1
commit: a26adcd7fbf91fa969cb2d81812709c2ff0d126e
gpu: NVIDIA GeForce RTX 4090
title: retail-fixture
seconds: 60
exit: 0x0
frames shown: 1564 (PresentX 1564)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

Not tested

  • A retail launch with an intentionally corrupted staged library; the exact driver rejection is covered with a focused D3D12 test instead.
  • AMD hardware.

AI use
Codex with GPT-5 reviewed the regression, implemented the fix and tests, and ran the reported verification.

<!-- greyfinch-sync:ivall/xcl:issue:5555811377 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3467). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-29T22:27:03Z. --- A prepared pipeline library can pass receipt and size checks but still be rejected when the runtime D3D12 device opens it. Since #3448, that cache activation error propagated as real-device initialization failure and selected the null renderer. This follow-up keeps the real renderer active and falls back to runtime/JIT pipeline creation during a normal launch. `XCL_PREPARE_CACHE_ONLY=1` remains fail-closed and stops before guest entry. The change does not alter pipeline descriptors, shader translation, receipt identities, or cache keys. **What is in it** - `pipeline_library.rs`: separates prepared-library opening from activation policy and records strict startup failures. - `d3d12x` / `host.rs`: keeps normal launches on the real renderer and stops strict launches before guest entry. - Tests cover policy and real-D3D12 corrupt-library rejection. **Tested** - Hardware: NVIDIA GeForce RTX 4090, Windows, debug and release. - `cargo test -p xcl --lib "shaders::pipeline_library::tests" -- --test-threads=1`: 8 passed, 0 failed, 0 ignored. - `cargo test -p xcl --lib warm_library -- --test-threads=4`: 10 passed, 0 failed, 0 ignored. - `.\scripts\test.ps1`: 2,778 passed, 0 failed, 49 ignored. GPU skips: 8 no-wave64 aggregate plus 15 reported feature/instruction skips (no heap windows, no GPU_UPLOAD heaps, no dxil.dll, wave64 and unsupported per-lane forms). **Regression run** Base: ```text xcl-smoke v1 commit: 5b0d5fa3d65d9aa61567f8603154d818a9307846 gpu: NVIDIA GeForce RTX 4090 title: retail-fixture seconds: 60 exit: 0x0 frames shown: 1516 (PresentX 1516) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16888 MB ``` Head: ```text xcl-smoke v1 commit: a26adcd7fbf91fa969cb2d81812709c2ff0d126e gpu: NVIDIA GeForce RTX 4090 title: retail-fixture seconds: 60 exit: 0x0 frames shown: 1564 (PresentX 1564) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` **Not tested** - A retail launch with an intentionally corrupted staged library; the exact driver rejection is covered with a focused D3D12 test instead. - AMD hardware. **AI use** Codex with GPT-5 reviewed the regression, implemented the fix and tests, and ran the reported verification.
Foniass commented 2026-12-01 03:27:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:27:35Z.


merge-check
base: d0832e614f
head: a26adcd7fb
merge: clean
build: ok
tests: 2892 passed, 0 failed, 51 ignored; 28 skipped, the same as on main
review: 2 high, 1 medium, 2 nits (below)
performance: 60 s smoke run: 1516 → 1445 frames (95 % of main), peak commit 18133 → 17187 MB, no device removal, no crash. No cost on a launch whose cache is accepted
title run: not run
verdict: not yet: 2 high findings (below): no test fails without the fix, and a rejected cache is likely rejected again on every later launch
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: It only changes a launch where a staged pipeline cache passes its checks and the device then rejects it. On main, activate(&device)? in init_with_remap (real.rs ~1025) turns that into a device failure and the null renderer; with this PR the title keeps the real device and builds pipelines as it runs, and XCL_PREPARE_CACHE_ONLY=1 stops the launch instead. The suite and smoke run are clean, but nothing tests the fix, and a rejected cache likely stays rejected.

High

  1. No test fails without the fix. activation_failure_continues_normally_and_stops_cache_only_launches checks the two-line if strict helper, and corrupt_ready_bytes_are_rejected_by_the_runtime_device shows corrupt bytes are rejected, which main already does. Restoring the ? in real.rs would keep both green. A test of activate itself (rejection → no startup error, ACTIVE unset) would cover it.
  2. A rejected cache is likely rejected again on every launch. On a rejection the cache's receipt seems to stay, so each later launch skips preparation, reports the libraries as reused, is rejected again and builds every pipeline at run time. Drop the receipt on rejection so the next launch prepares again. (From reading, not run.)

Medium

  1. The test panics where it should skip. preparation_driver_identity(..).unwrap() panics instead of calling skip_test where the identity can't be read.

Nit

  1. Exit code reused. 0x7C1_0003 already means a failed coherent-window restore in uma_driver.rs.
  2. AI model name. AI use says "GPT-5"; check that it is the exact model.
Checked and fine
  • The cache is staged before the backend is chosen, and STARTUP_ERROR is set once.
  • Strict mode stops before HOST_MODE is set and before the game loads.
  • warm_library.rs only follows the new signature.
How this was tested
  • Merged onto main d0832e61, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main d0832e61 and on this merge (81d0a87d); 60 presents per 2 s in both. The smoke run has no staged cache (smoke sets XCL_PREPARE=0), so it does not reach the changed branch.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7299726315 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3467#issuecomment-7299726315). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:27:35Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: a26adcd7fbf91fa969cb2d81812709c2ff0d126e merge: clean build: ok tests: 2892 passed, 0 failed, 51 ignored; 28 skipped, the same as on main review: 2 high, 1 medium, 2 nits (below) performance: 60 s smoke run: 1516 → 1445 frames (95 % of main), peak commit 18133 → 17187 MB, no device removal, no crash. No cost on a launch whose cache is accepted title run: not run verdict: not yet: 2 high findings (below): no test fails without the fix, and a rejected cache is likely rejected again on every later launch hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** It only changes a launch where a staged pipeline cache passes its checks and the device then rejects it. On main, `activate(&device)?` in `init_with_remap` (`real.rs` ~1025) turns that into a device failure and the null renderer; with this PR the title keeps the real device and builds pipelines as it runs, and `XCL_PREPARE_CACHE_ONLY=1` stops the launch instead. The suite and smoke run are clean, but nothing tests the fix, and a rejected cache likely stays rejected. #### High 1. **No test fails without the fix.** `activation_failure_continues_normally_and_stops_cache_only_launches` checks the two-line `if strict` helper, and `corrupt_ready_bytes_are_rejected_by_the_runtime_device` shows corrupt bytes are rejected, which main already does. Restoring the `?` in `real.rs` would keep both green. A test of `activate` itself (rejection → no startup error, `ACTIVE` unset) would cover it. 2. **A rejected cache is likely rejected again on every launch.** On a rejection the cache's receipt seems to stay, so each later launch skips preparation, reports the libraries as reused, is rejected again and builds every pipeline at run time. Drop the receipt on rejection so the next launch prepares again. (From reading, not run.) #### Medium 3. **The test panics where it should skip.** `preparation_driver_identity(..).unwrap()` panics instead of calling `skip_test` where the identity can't be read. #### Nit 4. **Exit code reused.** 0x7C1_0003 already means a failed coherent-window restore in `uma_driver.rs`. 5. **AI model name.** AI use says "GPT-5"; check that it is the exact model. <details><summary>Checked and fine</summary> - The cache is staged before the backend is chosen, and `STARTUP_ERROR` is set once. - Strict mode stops before `HOST_MODE` is set and before the game loads. - `warm_library.rs` only follows the new signature. </details> <details><summary>How this was tested</summary> - Merged onto main `d0832e61`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `d0832e61` and on this merge (`81d0a87d`); 60 presents per 2 s in both. The smoke run has no staged cache (smoke sets `XCL_PREPARE=0`), so it does not reach the changed branch. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3467:upstream-pr/3467'
git switch 'upstream-pr/3467'

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