Skip to content

Shaders: preserve translated cache across unrelated rebuilds - #762

Merged
theaustinayers merged 1 commit into
xcl-dev:mainfrom
bmjask:shaders/semantic-translated-cache
Nov 24, 2026
Merged

theaustinayers merged 1 commit into
xcl-dev:mainfrom
bmjask:shaders/semantic-translated-cache

Conversation

@bmjask

@bmjask bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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)
@theaustinayers
theaustinayers merged commit d5442d2 into xcl-dev:main Nov 24, 2026
2 checks passed
@JoaoPauluu

Copy link
Copy Markdown

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

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.

theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 24, 2026
Upstream's release profile (full symbols, xcl-dev#713) replaces the fork's line tables.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
ivall pushed a commit that referenced this pull request Nov 24, 2026
…under 2^40 (PR #631)

A retail title's XboxBvhBuilder refuses an acceleration structure whose GPU address is at or
above 2^40 (#585). xcl.exe was linked with high-entropy VA (Rust's default), and Windows then
places a process's bottom-up allocations around 1 to 2.5 TiB, where the title's memory lives.
build.rs links the xcl binary with /HIGHENTROPYVA:NO (MSVC) or --disable-high-entropy-va
(GNU); tests/low_va.rs fails if the flag is set. Ported onto main's build.rs (#762) as
maephisto666 described in the PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants