Shaders: stabilize prepared cache identities #3447

Merged
bmjask merged 3 commits from upstream-pr/3447 into main 2026-11-29 20:19:50 +00:00
bmjask commented 2026-11-29 18:07:43 +00:00 (Migrated from github.com)

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


Replaces unstable prepared-cache identities with deterministic semantic identities so diagnostics, scheduling changes, and implementation-only cache plumbing do not discard compatible native libraries.

Stacked on #3446; only commit e62a02ff belongs here.

What is in it

  • Deterministic FNV/canonical encoding for an explicit allowlist of pipeline-semantic settings.
  • Translator-output identity separated from DXC cache implementation details.
  • Narrow pipeline-layout identity instead of hashing the whole implementation file.
  • Conservative migration only from exact known legacy identities; strict cache-only mode still rejects migration.

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_settings -- --test-threads=4: 3 passed, 0 failed.
  • Focused warm-library tests at this phase: 9 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: e62a02ff33bfbe6777a3e3dbd41346fd52dfd432
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1572 (PresentX 1572)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14836 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:5553576319 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3447). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-29T18:07:43Z. --- Replaces unstable prepared-cache identities with deterministic semantic identities so diagnostics, scheduling changes, and implementation-only cache plumbing do not discard compatible native libraries. Stacked on #3446; only commit `e62a02ff` belongs here. **What is in it** - Deterministic FNV/canonical encoding for an explicit allowlist of pipeline-semantic settings. - Translator-output identity separated from DXC cache implementation details. - Narrow pipeline-layout identity instead of hashing the whole implementation file. - Conservative migration only from exact known legacy identities; strict cache-only mode still rejects migration. **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_settings -- --test-threads=4`: 3 passed, 0 failed. - Focused warm-library tests at this phase: 9 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: e62a02ff33bfbe6777a3e3dbd41346fd52dfd432 gpu: NVIDIA GeForce RTX 4090 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1572 (PresentX 1572) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14836 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.
Foniass commented 2026-11-29 21:01:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T21:01:44Z.


Post-merge review of e62a02ff (now on main at 1bd9cee1). I read the diff and ran the whole stack merged onto 0fe06eb0: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2748 passed, 0 failed, 49 ignored, 31 SKIPPED (no wave64, per-lane form refused, no heap windows, no debug layer). The suite passes, but four changes can let stale DXIL or native libraries be reused. Items 1–3 come from reading the code, not from a reproduction.

  1. src/gpu/recomp/dxc.rs left TRANSLATOR_SOURCES (build.rs:9), but it holds the DXC arguments. These are -HV 2021 (dxc.rs:1065) and the -O0/-O1 size thresholds. The DXIL file key (cache_key_for_toolchain, dxc.rs:1124) hashes only the crate version, toolchain, profile, entry and source, not the arguments. A change to the DXC flags now invalidates neither the translated cache nor the native libraries. A TRANSLATION_GLUE_REVISION-style constant for the DXC arguments, bumped when they change, would restore the invalidation.
  2. src/gpu/recomp/pso.rs left PREPARATION_LAYOUT_SOURCES (build.rs:60). Its old comment there read "root signatures, translation glue, split pipeline layout". The description promises a narrow pipeline-layout identity, but nothing replaces the file. The NATIVE_PREPARATION_ABI comment does not ask for a bump on root-signature changes either.
  3. The legacy migration never expires. LEGACY_TRANSLATOR_SOURCE_ID = 35a3ab2f5e487481 and LEGACY_PIPELINE_LAYOUT_ID = 8aeabcb8e2578671 match 0fe06eb0; I recomputed both with the source_hash formula. However, compatible_identity_migration (warm_library.rs:132) treats them as equal to whatever the current identity is. A receipt written by a 0fe06eb0-era build that has not been migrated yet is therefore accepted by every later build, even after edits to emit.rs, gfx_records.rs and the other files. Gating the migration on the current new-formula ID equalling the value at this commit would make it expire on the next translator change.
  4. warm_settings changed from a deny list to an allow list (shaders.rs:29). The XCL_TRACEX assertion was flipped to match (shaders.rs:139). I compared the list with the XCL_ variables read under gpu/ and hle/d3d12x/real* and found no pipeline-changing switch missing today. A switch added later that is not put on the list will not invalidate the cache, though, so the default is now fail-open.

RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 Pro 26300, Rust 1.100.0 debug. This review was written by Claude Code (Claude Opus 5.5) and checked by @Foniass.

<!-- greyfinch-sync:ivall/xcl:comment:7262545109 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3447#issuecomment-7262545109). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T21:01:44Z. --- Post-merge review of `e62a02ff` (now on `main` at `1bd9cee1`). I read the diff and ran the whole stack merged onto `0fe06eb0`: `cargo test --workspace --no-fail-fast -- --test-threads=4` -> 2748 passed, 0 failed, 49 ignored, 31 SKIPPED (no wave64, per-lane form refused, no heap windows, no debug layer). The suite passes, but four changes can let stale DXIL or native libraries be reused. Items 1–3 come from reading the code, not from a reproduction. 1. **`src/gpu/recomp/dxc.rs` left `TRANSLATOR_SOURCES` (`build.rs:9`), but it holds the DXC arguments.** These are `-HV 2021` (`dxc.rs:1065`) and the `-O0`/`-O1` size thresholds. The DXIL file key (`cache_key_for_toolchain`, `dxc.rs:1124`) hashes only the crate version, toolchain, profile, entry and source, not the arguments. A change to the DXC flags now invalidates neither the translated cache nor the native libraries. A `TRANSLATION_GLUE_REVISION`-style constant for the DXC arguments, bumped when they change, would restore the invalidation. 2. **`src/gpu/recomp/pso.rs` left `PREPARATION_LAYOUT_SOURCES` (`build.rs:60`).** Its old comment there read "root signatures, translation glue, split pipeline layout". The description promises a narrow pipeline-layout identity, but nothing replaces the file. The `NATIVE_PREPARATION_ABI` comment does not ask for a bump on root-signature changes either. 3. **The legacy migration never expires.** `LEGACY_TRANSLATOR_SOURCE_ID = 35a3ab2f5e487481` and `LEGACY_PIPELINE_LAYOUT_ID = 8aeabcb8e2578671` match `0fe06eb0`; I recomputed both with the `source_hash` formula. However, `compatible_identity_migration` (`warm_library.rs:132`) treats them as equal to whatever the current identity is. A receipt written by a `0fe06eb0`-era build that has not been migrated yet is therefore accepted by every later build, even after edits to `emit.rs`, `gfx_records.rs` and the other files. Gating the migration on the current new-formula ID equalling the value at this commit would make it expire on the next translator change. 4. **`warm_settings` changed from a deny list to an allow list (`shaders.rs:29`).** The `XCL_TRACEX` assertion was flipped to match (`shaders.rs:139`). I compared the list with the `XCL_` variables read under `gpu/` and `hle/d3d12x/real*` and found no pipeline-changing switch missing today. A switch added later that is not put on the list will not invalidate the cache, though, so the default is now fail-open. RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 Pro 26300, Rust 1.100.0 debug. This review was written by Claude Code (Claude Opus 5.5) and checked by @Foniass.
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!3447
No description provided.