startup-tools: warn when the shader cache and the translator come from different revisions #2815

Closed
opened 2026-11-27 01:24:48 +00:00 by github-bot · 1 comment
Owner

@⁠tedin7 on GitHub · 2026-11-26 11:16 UTC · original

Part of #870

Problem. tools/startup/run.ps1 -Render -Translate starts tools/startup/gfx2hlsl.py --watch from the repo checkout next to the script, while the runtime stand-ins come from whatever build the user last compiled. The request key on both sides starts with a shader revision string (x2w-startup-shader-<n> in src/startup_stubs/d3d12_draw.inl and x2w-startup-shader-<n>cs for compute, mirrored in gfx2hlsl.py). That revision moves often on main.

If the checkout is updated (git pull) without rebuilding, or a shader cache from an older build is reused, the two revisions differ. Then every cached request is refused with compute request files do not match the key in their name or shader request source key mismatch, and nothing in translate.txt says the real cause is a version mismatch. A run looks like "nothing translates" when the fix is just "rebuild, or use the matching tools".

Proposal (launcher/runtime side, no change to the translation itself).

  1. The runtime writes its shader revision strings (graphics and compute) once into the shader cache folder, for example X2W_SHADER_CACHE/revision.txt.
  2. Before starting the translator, run.ps1 (and run.sh) compare that file with the revision in the gfx2hlsl.py it is about to start. On mismatch: print one clear warning naming both revisions and the two fixes (rebuild from this checkout, or start with an empty cache folder). A cache folder from an older build that has no revision.txt gets the same warning when it already holds req_* files.
  3. Optional: a -FreshShaderCache switch that moves the old cache aside.

Tests. A Linux check for the comparison helper (same revision: silent; different: warning with both values; old cache with no revision file: warning). A Windows check that runs the built stand-in once and confirms revision.txt matches the revision in gfx2hlsl.py at the same commit, so the two cannot drift silently.

**@⁠tedin7** on GitHub · 2026-11-26 11:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2815) Part of #870 **Problem.** `tools/startup/run.ps1 -Render -Translate` starts `tools/startup/gfx2hlsl.py --watch` from the repo checkout next to the script, while the runtime stand-ins come from whatever build the user last compiled. The request key on both sides starts with a shader revision string (`x2w-startup-shader-<n>` in `src/startup_stubs/d3d12_draw.inl` and `x2w-startup-shader-<n>cs` for compute, mirrored in `gfx2hlsl.py`). That revision moves often on main. If the checkout is updated (`git pull`) without rebuilding, or a shader cache from an older build is reused, the two revisions differ. Then every cached request is refused with `compute request files do not match the key in their name` or `shader request source key mismatch`, and nothing in `translate.txt` says the real cause is a version mismatch. A run looks like "nothing translates" when the fix is just "rebuild, or use the matching tools". **Proposal (launcher/runtime side, no change to the translation itself).** 1. The runtime writes its shader revision strings (graphics and compute) once into the shader cache folder, for example `X2W_SHADER_CACHE/revision.txt`. 2. Before starting the translator, `run.ps1` (and `run.sh`) compare that file with the revision in the `gfx2hlsl.py` it is about to start. On mismatch: print one clear warning naming both revisions and the two fixes (rebuild from this checkout, or start with an empty cache folder). A cache folder from an older build that has no `revision.txt` gets the same warning when it already holds `req_*` files. 3. Optional: a `-FreshShaderCache` switch that moves the old cache aside. **Tests.** A Linux check for the comparison helper (same revision: silent; different: warning with both values; old cache with no revision file: warning). A Windows check that runs the built stand-in once and confirms `revision.txt` matches the revision in `gfx2hlsl.py` at the same commit, so the two cannot drift silently.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:24:48 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 11:16 UTC · original

Taking this one; a Draft PR will follow.

**@⁠tedin7** on GitHub · 2026-11-26 11:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2815#issuecomment-7190523269) Taking this one; a Draft PR will follow.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#2815
No description provided.