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

Closed
opened 2026-11-26 11:16:46 +00:00 by tedin7 · 1 comment
tedin7 commented 2026-11-26 11:16:46 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:16:46Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6625483024 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2815). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T11:16:46Z. --- 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 commented 2026-11-26 12:04:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:16:53Z.


Taking this one; a Draft PR will follow.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7190523269 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2815#issuecomment-7190523269). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T11:16:53Z. --- Taking this one; a Draft PR will follow.
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#2807
No description provided.