Shaders: preserve translated cache across unrelated rebuilds #762

Manually merged
github merged 1 commit from gh-pr/762/head into gh-pr/762/base 2026-11-26 04:31:40 +00:00
Owner

@⁠bmjask on GitHub · 2026-11-24 04:49 UTC · original
bmjask:shaders/semantic-translated-cache → main · +149 −17 · 4 files · 1 commits · merged 2026-11-24 04:58 UTC

Part of #156. The translated-shader disk cache was tied to the complete xcl executable, so profile changes, symbols, and unrelated relinks discarded otherwise compatible translations. This keys a v2 namespace by the translator sources and loaded DXC toolchain while retaining the full request inputs in each entry.

What is in it

  • crates/xcl/build.rs: build-time identity for sources that determine generated HLSL and DXIL
  • crates/xcl/src/gpu/recomp/pso.rs: semantic v2 namespace, corruption-safe reuse tests, and bypasses for HLSL-changing diagnostics
  • crates/xcl/src/gpu/recomp/dxc.rs: exposes the existing DXC toolchain identity to the translated cache
  • README.md: documents cross-build reuse and XCL_TRANSLATED_CACHE=0

Tested

  • Windows 11 Pro build 26200; Intel Core i9-12900K; NVIDIA GeForce RTX 4090; Rust 1.100.0 MSVC; debug and release
  • cargo test -p xcl --lib shader_cache_tests -- --test-threads=1: 11 passed, 0 failed, 0 ignored
  • cargo test -p xcl --lib cache_key_tracks_the_dxc_toolchain -- --test-threads=1: 1 passed, 0 failed, 0 ignored
  • .\scripts\test.ps1: 704 passed, 0 failed, 41 ignored; 2 GPU tests skipped (no wave64)
  • cargo build --release -p xcl: passed

Regression run

Upstream main:

xcl-smoke v1
commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175
gpu: NVIDIA GeForce RTX 4090
title: game
seconds: 60
exit: 0x0
frames shown: 1573 (PresentX 1573)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14756 MB

This PR:

xcl-smoke v1
commit: 242a6ead0b2c79dbd6e4ae7148682af773078096
gpu: NVIDIA GeForce RTX 4090
title: game
seconds: 60
exit: 0x0
frames shown: 1563 (PresentX 1563)
presents per 2 s (last 3): 60 59 36
device removals: 0
crashes: 0
peak commit: 15850 MB

Not tested

  • AMD, Intel, or native-wave64 GPUs
  • startup-time improvement on a controlled cold/warm title corpus
  • migration of v1 root-level entries; they are intentionally left untouched and ignored

AI use

  • OpenAI Codex with GPT-5 wrote and reviewed the implementation, tests, and description and ran the reported validation. The human requester directed the branch and PR creation in this session.
**@⁠bmjask** on GitHub · 2026-11-24 04:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/762) `bmjask:shaders/semantic-translated-cache` → `main` · +149 −17 · 4 files · 1 commits · merged 2026-11-24 04:58 UTC Part of #156. The translated-shader disk cache was tied to the complete xcl executable, so profile changes, symbols, and unrelated relinks discarded otherwise compatible translations. This keys a v2 namespace by the translator sources and loaded DXC toolchain while retaining the full request inputs in each entry. **What is in it** - crates/xcl/build.rs: build-time identity for sources that determine generated HLSL and DXIL - crates/xcl/src/gpu/recomp/pso.rs: semantic v2 namespace, corruption-safe reuse tests, and bypasses for HLSL-changing diagnostics - crates/xcl/src/gpu/recomp/dxc.rs: exposes the existing DXC toolchain identity to the translated cache - README.md: documents cross-build reuse and XCL_TRANSLATED_CACHE=0 **Tested** - Windows 11 Pro build 26200; Intel Core i9-12900K; NVIDIA GeForce RTX 4090; Rust 1.100.0 MSVC; debug and release - cargo test -p xcl --lib shader_cache_tests -- --test-threads=1: 11 passed, 0 failed, 0 ignored - cargo test -p xcl --lib cache_key_tracks_the_dxc_toolchain -- --test-threads=1: 1 passed, 0 failed, 0 ignored - .\scripts\test.ps1: 704 passed, 0 failed, 41 ignored; 2 GPU tests skipped (no wave64) - cargo build --release -p xcl: passed **Regression run** Upstream main: ``` xcl-smoke v1 commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175 gpu: NVIDIA GeForce RTX 4090 title: game seconds: 60 exit: 0x0 frames shown: 1573 (PresentX 1573) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14756 MB ``` This PR: ``` xcl-smoke v1 commit: 242a6ead0b2c79dbd6e4ae7148682af773078096 gpu: NVIDIA GeForce RTX 4090 title: game seconds: 60 exit: 0x0 frames shown: 1563 (PresentX 1563) presents per 2 s (last 3): 60 59 36 device removals: 0 crashes: 0 peak commit: 15850 MB ``` **Not tested** - AMD, Intel, or native-wave64 GPUs - startup-time improvement on a controlled cold/warm title corpus - migration of v1 root-level entries; they are intentionally left untouched and ignored **AI use** - OpenAI Codex with GPT-5 wrote and reviewed the implementation, tests, and description and ran the reported validation. The human requester directed the branch and PR creation in this session.
Key translated DXIL by the shader translator sources and loaded DXC toolchain instead of the linked xcl executable. This preserves compatible translations across profile and metadata-only rebuilds while isolating incompatible translator revisions in a v2 namespace.

Assisted-by: OpenAI Codex (GPT-5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:37 +00:00
github manually merged commit 242a6ead0b into gh-pr/762/base 2026-11-26 04:31:40 +00:00
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-24 05:09 UTC · original

Test report: #762 under Wine (Linux, NVIDIA): a second build of the same commit uses the same v2 namespace

This checks the PR's main claim with a cross build from Linux (mingw-w64), where build.rs hashes the sources of a Linux (LF) checkout. Two executables of the same commit share one translated/v2/<identity> folder, and the second one wrote nothing new to it.

Setup

  • CachyOS, kernel 7.3.3-1-cachyos, Intel i5-10400F, 16 GB RAM, NVIDIA GeForce RTX 3060 12 GB, driver 620.70.06
  • Proton Experimental experimental-11.0-20261112 (wine-11.0), vkd3d-proton v3.1 (4522cc1a) + the patch from #257, DXVK from Proton, DXC 1.9.2609, DXVK_CONFIG="dxgi.hideNvidiaGpu = False"
  • Rust 1.100.0, x86_64-pc-windows-gnu (mingw-w64-gcc 16.2.0), release builds of this PR's head 242a6ea
  • GTA VI 1.0.2.1 (my own dump), 60 s runs with scripts/linux/smoke.sh from #257, XCL_NETWORK=0

What I did

  1. Built 242a6ea twice, in two separate target directories: A and B, executables of different bytes (sha256 5a81184d… / f854d641…). I meant B to be a profile change (CARGO_PROFILE_RELEASE_DEBUG=true), but [profile.release] debug = 2 is already in Cargo.toml, so the only difference is the build directory.
  2. Ran A, then B, with the same XCL data folder. It already held 814 unnamespaced translated/*.bin files from earlier runs of other builds, and no v2.

Result

  • After A: dxil/translated/v2/a4eab38a5d5586ff/ with 11 files, all written during A's run (02:06).
  • After B: still the one namespace, the same 11 files, none newer than 02:06 (B ran 02:07–02:08). So B found its translations under A's identity.
  • Both runs: 975 / 982 frames shown, 0 device removals, 0 crashes, first presents at 22 s. The 814 old unnamespaced files were left alone.

Not tested

  • A real profile or symbols change; a change to a file outside TRANSLATOR_SOURCES (the case the PR is for); Windows; whether a Windows (CRLF) checkout of the same commit gets the same identity as this LF one (build.rs hashes the files' raw bytes); the test suite on this branch; a main pair

AI use: Claude Code (Claude Opus 5.5) built both executables, ran everything above on the machine above and wrote this report. The counts, times and hashes are from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one.

**@⁠JoaoPauluu** on GitHub · 2026-11-24 05:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/762#issuecomment-7122679857) ### Test report: #762 under Wine (Linux, NVIDIA): a second build of the same commit uses the same v2 namespace This checks the PR's main claim with a cross build from Linux (mingw-w64), where `build.rs` hashes the sources of a Linux (LF) checkout. Two executables of the same commit share one `translated/v2/<identity>` folder, and the second one wrote nothing new to it. **Setup** - CachyOS, kernel 7.3.3-1-cachyos, Intel i5-10400F, 16 GB RAM, NVIDIA GeForce RTX 3060 12 GB, driver 620.70.06 - Proton Experimental `experimental-11.0-20261112` (wine-11.0), vkd3d-proton v3.1 (`4522cc1a`) + the patch from #257, DXVK from Proton, DXC 1.9.2609, `DXVK_CONFIG="dxgi.hideNvidiaGpu = False"` - Rust 1.100.0, `x86_64-pc-windows-gnu` (mingw-w64-gcc 16.2.0), release builds of this PR's head `242a6ea` - GTA VI 1.0.2.1 (my own dump), 60 s runs with `scripts/linux/smoke.sh` from #257, `XCL_NETWORK=0` **What I did** 1. Built `242a6ea` twice, in two separate target directories: A and B, executables of different bytes (sha256 `5a81184d…` / `f854d641…`). I meant B to be a profile change (`CARGO_PROFILE_RELEASE_DEBUG=true`), but `[profile.release] debug = 2` is already in `Cargo.toml`, so the only difference is the build directory. 2. Ran A, then B, with the same XCL data folder. It already held 814 unnamespaced `translated/*.bin` files from earlier runs of other builds, and no `v2`. **Result** - After A: `dxil/translated/v2/a4eab38a5d5586ff/` with 11 files, all written during A's run (02:06). - After B: still the one namespace, the same 11 files, none newer than 02:06 (B ran 02:07–02:08). So B found its translations under A's identity. - Both runs: 975 / 982 frames shown, 0 device removals, 0 crashes, first presents at 22 s. The 814 old unnamespaced files were left alone. **Not tested** - A real profile or symbols change; a change to a file outside `TRANSLATOR_SOURCES` (the case the PR is for); Windows; whether a Windows (CRLF) checkout of the same commit gets the same identity as this LF one (`build.rs` hashes the files' raw bytes); the test suite on this branch; a `main` pair **AI use:** Claude Code (Claude Opus 5.5) built both executables, ran everything above on the machine above and wrote this report. The counts, times and hashes are from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one.
This discussion has been locked. Commenting is limited to contributors.
No description provided.