startup: re-key saved shader requests after a cache revision change #2393
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2401"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-25T15:21:28Z.
The startup shader cache key hashes a translation revision string (
x2w-startup-shader-Ninpipeline_key/compute_keyand in the runtime). After a revision bump the runtime asks for new keys, so a kept cache is coldand every pipeline has to be requested again by a running title before
gfx2hlsl.py --pendingcan translate it.tools/startup/shader_cache_rekey.py <old cache> <new dir>recomputes the key of every graphics request, RTVvariant and slot 67 compute request with the
gfx2hlsl.pynext to it and copies the request files under the newnames.
--pending <new dir>then translates them offline, and the results are merged into the cache withoutoverwriting (
robocopy /XC /XN /XO, orcp -rn).req_*request files, never results or.fail. Files that alreadyexist are kept.
missing base makes it print the count, write nothing and exit 1. A destination equal to the source exits 2.
X2W_TRANSLATE_JOBSsets the number of hashing processes, as for--pending.Docs:
docs/startup-runtime.md, "Keep the shader cache between runs".Test
python -B tests/startup_shader_cache_rekey_check.py-> 24 ok,all checks passed, exit 0. The check is pure Pythonon synthetic byte strings, with no game data, Wine or DXC. Its older and newer revisions come from gfx2hlsl's source
with the revision number changed. It is registered in CMake (
startup_shader_cache_rekey), the Linux Python job andAGENTS.md.
python -B tools/run_checks_parallel.py <python-linux list>->all 135 checks passed(Linux, Python 3.13.5).The check has three negative controls: a missing
.root, a truncated RTV variant and an RTV variant whose baserequest is missing. Each exits 1 with its reason and creates nothing. Every one of these mutations of the tool makes
the check fail: key not recomputed,
.iadropped, RTV base kept, errors ignored, overwrite, source touched,compute key altered, RTV self-hash check removed, missing RTV base accepted.
Measured vs not
pipeline_key/compute_keyof the currentrevision, and the properties listed above hold.
separate from the cache key. Nothing here claims that a title runs.
Evidence from a running title
One local A/B with a single unmodified build of upstream main, on a Linux host running the title under Wine/Proton
(16 cores,
X2W_TRANSLATE_JOBS=16). Each run had a 150 s cap and its own cache directory, with a--pendingwatcher on that directory:
150 s. It wrote several thousand new pipeline requests during the run.
--pendingbefore the run. Two runs, each from its own copy of that cache, reached the first gamepad poll atabout 18 s. Neither created a new request file.
does not involve the cache. The other prewarmed run and the cold run reached the 150 s cap.
Caveats: this is one run per arm on one machine, so it is not a statistic. The prewarmed cache was built with an
earlier prototype of this tool that makes the same
pipeline_key/compute_keycalls but does not yet have theall-or-nothing checks above. This exact file was not used for that run.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-25T15:58:51Z.
APPROVED: Shader cache re-keying tool. All-or-nothing, atomic writes, multi-process hashing, RTV re-linking. 180-line tool + 235-line test with 24 cases.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:38:38Z.
Review: COMMENTED
Review of head
6bd46d89(after updating with main). Offline tooling only: no game claim, no runtime or startup path touched.What I checked:
tools/startup/shader_cache_rekey.pyrecomputes keys with the samepipeline_key/compute_keythe runtime uses (imported from the adjacentgfx2hlsl.py), reads everything before writing, writes temp-then-rename with the ready marker last, never overwrites, refuses dst == src.windows.ymllist and AGENTS.md all list the new check. No other open or merged PR covers this slice.Commands run (Linux, worktree at this head):
python3 -B tests/startup_shader_cache_rekey_check.py-> all checks passedpython3 tests/docs_links_check.py-> ok (19 files, 475 links)python3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> cleanpipeline_key(...)replaced by the old key -> check fails (8 failed)No blocking findings. Win2025 run follows separately.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:45:29Z.
Win2025 WARP receipt for head
6bd46d89after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
6bd46d89f34a7005cea167ca5e97ea0556a12689:--preset dev):cmake --build --preset dev -- -j 2):85.57s(configure2.00s)ctest --preset dev -R 'startup_shader_cache_rekey' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.95s:startup_shader_cache_rekey1.85s)/O2(--preset release):cmake --build --preset release -- -j 2):114.56s(configure1.75s)ctest --preset release -R 'startup_shader_cache_rekey' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.73s:startup_shader_cache_rekey1.63s)tests/startup_shader_cache_rekey_check.pyok (1.9s)sccache: 611/649 hits; wall214.4sAI-assisted; commands listed were executed locally.