startup: warn when the shader cache and the translator come from different revisions #2812
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2820"
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 tedin7 on 2026-11-26T11:33:16Z.
Part of #870
Fixes #2815
What this unblocks: a run whose stand-ins and translator come from different revisions now says so in one warning, instead of looking like "nothing translates" (every cached request refused as a key mismatch).
What changed
src/startup_stubs/d3d12_draw.inl): the three revision strings the request keys start with (graphicsx2w-startup-shader-27, computex2w-startup-shader-27cs, slot 57 meshx2w-startup-mesh-57-3) move into oneshader_cachenamespace; the keys are unchanged. Before its first request a process writes them to<X2W_SHADER_CACHE>\revision.txt(graphics ...,compute ...,mesh57 ...lines), through a temporary file andMoveFileExW(..., MOVEFILE_REPLACE_EXISTING). A file that already says the same is not rewritten; a run that publishes no request writes nothing.tools/startup/shader_cache_revision.py(new, standard library only): readsrevision.txtand the revision literals of thegfx2hlsl.pyit is given (only read; no translation code changes). Silent when they agree or the cache holds no request; one line with both revisions and the two fixes when they differ, or when the cache holdsreq_*files but norevision.txt.--freshmoves a cache folder that is not empty to<cache>.old-<date>-<time>.run.ps1/run.sh: with-Render -Translate(--render --translate) the helper runs before the watcher starts and prints the line as a warning. If that was silent, it runs once more after the run, so the first run with an empty cache still warns once its own stand-ins wroterevision.txt. New-FreshShaderCache/--fresh-shader-cache(with-Render) moves the old cache aside first.run.shruns the helper with the host Python (X2W_HOST_PYTHON, defaultpython3).docs/startup-runtime.md: the shader cache section describesrevision.txt, the warning and the switch.Tests
tests/startup_shader_cache_revision_check.py(new, Linux and Windows): same revisions silent; a different revision (also only one kind) warns with both values and both fixes; a garbledrevision.txtwarns; requests withoutrevision.txtwarn; an empty or missing cache is silent;--freshmoves a cache with files aside and leaves an empty or missing one alone; usage errors exit 2; the realgfx2hlsl.pyyields all three revisions, compute = graphics +cs.tests/startup_compute_request_check.py(Windows, built stand-in consumer): after the stand-in publishes,revision.txtequals the revisions thegfx2hlsl.pyof the same commit spells, the helper is silent for that cache, a stalerevision.txtleft in the cache is replaced, and a second process does not rewrite it. The request file lists skiprevision.txt.tests/startup_run_sh_check.py: four new cases (olderrevision.txt: one warning with both revisions; requests withoutrevision.txt: one warning; matching cache: no warning;--fresh-shader-cache: cache moved aside, no warning) and two new mutants (warning dropped, fresh cache kept), both detected.tests/startup_run_ps1_check.py: the scratch tree gets the helper; on Windows, a-Translaterun on an older cache must print the warning once (compared without whitespace, since PowerShell may wrap it).tests/startup_indirect_draw_indexed.cpp: the slot 57 request count skipsrevision.txt.Not covered
archive_requests.pyorshader_cache_rekey.pyhave norevision.txt, so they get the "no revision.txt" warning (its text names both tools). A follow-up can have them write the translator's revisions.x2w-startup-mesh-86-1,mesh86_cache.py) are not part ofrevision.txt.Source: repository code only: the key seeds of
src/startup_stubs/d3d12_draw.inlandpipeline_key/compute_key/mesh57_keyintools/startup/gfx2hlsl.py(#2815); Microsoft Learn, "MoveFileExW function (winbase.h)" (MOVEFILE_REPLACE_EXISTING); PowerShell SDK, "PathIntrinsics.GetUnresolvedProviderPathFromPSPath".Verification (Linux, head
1bc4a534a; Win2025 dev+release 6/8 each at1bc4a534a, 2 skipped as expected, see the comment):python3 -B tests/startup_shader_cache_revision_check.py: PASS (16 checks).python3 -B tests/startup_run_sh_check.py: 0 failed (every case and mutant).python3 -B tests/startup_run_ps1_check.py: 0 failed (text only: not a Windows host).startup_gfx2hlsl_fract_check,startup_archive_requests_check,startup_gfx2hlsl_export_mask_check,startup_image_load_mip_check,startup_image_sample_a16_check,startup_compute_request_offline_check,startup_shader_cache_rekey_check,startup_shader_cache_key_check(they read the revision constants from the runtime source),docs_links_check,bidi_controls_check,startup_tools_lint_check;git diff --checkclean.d39f65cfc(therevision.txtfix for six draw checks, see the comments):ctest -R '^startup_(logical_view|address_srv|joined_table_pointer|d16_srv|mubuf_descriptor|pixel_uav)_'16/16 dev and 16/16 release; the same regex at1bc4a534afailed 14 of 16 (too many values to unpack). An independent second check ond39f65cfcpassed (dev and release).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:40:54Z.
Merged origin/main into the branch (merge commit, no force push): main had raised the cache revision to
x2w-startup-shader-28/28csin the same lines this PR moves intoshader_cache; the constants are now 28 / 28cs, matchinggfx2hlsl.pyat the same commit (slot 57 mesh unchanged atx2w-startup-mesh-57-3).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
1bc4a534afd710cf0c13788cdd1f23fcf5538b24:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2):31.61s(configure0.00s)ctest --preset dev -R '^(startup_shader_cache_revision|startup_compute_request_warp|startup_compute_request_disabled_control|startup_compute_request_offline|startup_indirect_draw_indexed_.*|startup_run_ps1|startup_run_sh)$' --parallel 3 --no-tests=error --output-on-failure): 6/8 passed (17.95s:startup_shader_cache_revision0.95s,startup_compute_request_offline0.85s,startup_compute_request_disabled_control0.22s,startup_indirect_draw_indexed_warp0.13s,startup_indirect_draw_indexed_hardware0.03s,startup_run_sh0.11s,startup_compute_request_warp2.53s,startup_run_ps117.76s); skipped (capability, not a pass):startup_indirect_draw_indexed_hardware,startup_run_sh/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2):73.86s(configure0.00s)ctest --preset release -R '^(startup_shader_cache_revision|startup_compute_request_warp|startup_compute_request_disabled_control|startup_compute_request_offline|startup_indirect_draw_indexed_.*|startup_run_ps1|startup_run_sh)$' --parallel 3 --no-tests=error --output-on-failure): 6/8 passed (24.96s:startup_compute_request_offline1.05s,startup_compute_request_disabled_control0.27s,startup_indirect_draw_indexed_warp0.12s,startup_indirect_draw_indexed_hardware0.04s,startup_shader_cache_revision1.22s,startup_run_sh0.16s,startup_compute_request_warp3.62s,startup_run_ps124.69s); skipped (capability, not a pass):startup_indirect_draw_indexed_hardware,startup_run_shtests/startup_compute_translate_check.pyok (0.2s),tests/startup_run_ps1_check.pyok (12.7s),tests/startup_run_sh_check.pyskipped (0.1s)sccache: 3/18 hits; wall148.6sSkipped, as expected:
startup_indirect_draw_indexed_hardware(no hardware adapter on the VM) andstartup_run_sh(POSIX launcher, runs on Linux).startup_compute_request_warppassed with the new check that the built stand-in'srevision.txtequals the revisions ofgfx2hlsl.pyat this commit;startup_run_ps1passed with the older-cache case (one warning naming both revisions).Linux at this head:
tests/startup_shader_cache_revision_check.pyPASS; the revision-reading checks (startup_gfx2hlsl_fract,archive_requests,export_mask,image_load_mip,image_sample_a16,compute_request_offline,shader_cache_rekey,shader_cache_key),docs_links,bidi_controls,startup_tools_lintpass; the launcher files are unchanged by the merge (startup_run_sh_check.py0 failed at421a9c684).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:31:09Z.
Stage-2 gate PASS at
1bc4a534afd710cf0c13788cdd1f23fcf5538b24.Verification:
x2w_pipe.py win2025 2820 --host proxmox --force --keep-release --regex 'startup_shader_cache_revision|startup_compute_request|startup_indirect_draw_indexed|startup_run_ps1': dev 7 tests, release 7 tests, all passed exceptstartup_indirect_draw_indexed_hardware(skipped, no hardware adapter). Includesstartup_compute_request_warp(revision.txt matches gfx2hlsl at the same commit),startup_shader_cache_revision,startup_run_ps1(stale-cache case)....-27cs):startup_compute_request_warpFAILS on Win2025 dev,startup_shader_cache_revisionstill passes. The clean head passes both.startup_shader_cache_revision_check.pyexits 1 (Linux). Clean head exits 0.startup_run_ps1).shader_cache::); revision.txt written once per process before the first request, through a temporary file andMoveFileExW(REPLACE_EXISTING); an identical file is not rewritten.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T12:31:15Z.
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.1bc4a53ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T12:31:17Z.
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:04:09Z.
New commit
d39f65cfc(no force push): six Windows draw checks counted the.txtfiles in their shader cache and expected exactly one manifest. With this PR the runtime also writesrevision.txtthere with its first request, somanifest, = cache.glob('*.txt')found two files and the checks failed withValueError: too many values to unpack. They now skiprevision.txt:tests/startup_logical_view_check.py,startup_address_srv_check.py,startup_joined_table_pointer_check.py,startup_d16_srv_check.py,startup_mubuf_descriptor_check.py,startup_pixel_uav_check.py. No runtime or tool change.Verified on Windows Server 2025 (D3D12 WARP and the hardware adapter variant),
ctest -R '^startup_(logical_view|address_srv|joined_table_pointer|d16_srv|mubuf_descriptor|pixel_uav)_':1bc4a534a(before): dev 2 of 16 passed, 14 failed (too many values to unpack).d39f65cfc: dev 16/16 passed, release 16/16 passed.Linux:
python3 -B tests/startup_tools_lint_check.pyandtests/startup_joined_table_pointer_check.py(its CPU part) pass; the other five need the Windows build. Still needs the independent second check on this head.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T18:32:55Z.
Review: COMMENTED
I tried to review
d39f65cfovermain429f11d5, but the trial merge (git merge --no-ff --no-commit) stops with conflicts in three files:src/startup_stubs/d3d12_draw.inl, mostly against #2919 (persisted PSO recipes), which addspso_recipe_path/read_pso_recipe_text/load_pso_recipesbesideread_text. Main now spells the request-key seedsx2w-startup-shader-29andx2w-startup-shader-29cs. This head'sshader_cachenamespace still has 28 / 28cs, so the resolution has to take main's values. If it keeps 28,revision.txtwould disagree with every key the stand-in writes.tools/startup/run.ps1andtests/startup_run_ps1_check.py, against #2958 (slot 67 compute requests translated in the stand-in) and #2870 (literal data directory manifest). #2958 changes the-Translatepath that the new pre-run and post-run helper calls hook into, so the warning's placement needs re-checking after the merge.The merge base is
02075500. I have not built or run anything on this head. I'll review the commit that resolves these.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:28:40Z.
Updated with
main: pushed624bc81f6, a merge commit. The three conflicts are resolved. Request-key seeds andrevision.txtnow usex2w-startup-shader-29/29csfrom main, so the revision text agrees with every key the stand-in writes. Inrun.ps1the shader-cache warning helpers now sit around the new-Translateflow (slot 67 compute translation, literal data directory manifest); both sides' features are kept.Not yet run on Windows after the merge: the
run.ps1path.Commands run locally: 18 Python checks including
tests/startup_run_ps1_check.pyand therun.shcheck,git diff --check,cmake -S . -B <tmp> -DDXC_EXECUTABLE=/bin/true,public_guard.py.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:47:21Z.
Verification: head
624bc81f6after the main merge and the latest fixes.Environment: Windows Server 2025 (build 26100), MSVC 14.44, D3D12 WARP and the hardware adapter, dev and release legs in parallel.
Commands (the same selection in both legs):
Result: 24 selected, no failures in both legs (skips by capability:
startup_logical_view_warp,startup_indirect_draw_indexed_hardware,startup_run_sh), includingstartup_run_ps1andstartup_shader_cache_revision.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:42:50Z.
Review: APPROVED
Reviewed
624bc81fmerged over currentmainc1de64a5. The merge is clean andgit diff --cached --checkis clean.The conflicts from my comment on
d39f65cfare resolved.shader_cache::revision,compute_revisionandmesh57_revisionarex2w-startup-shader-29,29csandx2w-startup-mesh-57-3, the same seedsmainuses ind3d12_draw.inlandgfx2hlsl.py. Sorevision.txtagrees with the keys the stand-in writes.run.ps1with-Translate: the pre-run check runs just before the watcher starts, and the post-run check runs only if the pre-run one didn't warn.write_cache_revision: it runs once per process frompublish_shader_request, and that call covers all four request kinds: graphics, compute, slot 57 and.rtv.What I ran. I did a full build in
devandrelease, then ranThe results were the same in both presets:
_hardware: 16 of 18 pass and 2 skip.startup_logical_view_warpis a capability skip; its_hardwarevariant passes.startup_run_shskips because this host has no POSIX shell for it, so I didn't exercise therun.shside._hardware: 8/8 pass.Mutants. For each, I rebuilt where needed and ran the 6 tests
startup_shader_cache_revision,startup_run_ps1,startup_run_shandstartup_compute_request*:publish_shader_requestno longer callswrite_cache_revisionstartup_compute_request_warp)warning()returnsNonewhen no revision kind is shared (shared anddropped)startup_shader_cache_revision)revision.txtgets no warningstartup_shader_cache_revision)--freshmoves an empty cache aside toostartup_shader_cache_revision)warning()compares only thegraphicsrevisionrun.ps1skips the post-run checkRestored and rebuilt afterwards;
git diff --quietis clean.Non-blocking.
revision.txtwhose graphics line matches the translator while itscomputeormesh57line doesn't. Bumping only29cs(ormesh-57-3) is the case most likely to slip through, so a single case with one stalecomputeline would pin the comparison.startup_run_ps1passes without theif ($watchShaders -and -not $revisionWarned)line. That's the path for a fresh cache, whererevision.txtonly appears during the run.Verdict: approve on
624bc81f.Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on624bc81f.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T23:38:14Z.
Follow-up to my approval: this change broke two tests on
main, and I missed them in my review because my test selection didn't include them.Build and test on Windowson the merge commit14d56502(run 46078334414) fails these two:startup_compute_dispatch_native_warpwithAssertionError: the native route left ['revision.txt'] in the cache(tests/startup_compute_dispatch_native_check.py:80).native_rtv_variant_warpattests/native_rtv_variant_check.py:291. This check compares the exact file list of the cache, which now also holdsrevision.txt.The cause:
publish_shader_requestnow callswrite_cache_revision. So every cache a stand-in writes a request into gets arevision.txt, the native and.rtvroutes included. Both checks list the cache and allow only request files (andnative).Reproduced locally on a current-
mainbuild (fad97f47plus an unrelated PR), Debug:All three fail.
startup_compute_dispatch_native_hardwarefails the same way as the WARP one.The third failure in that run,
linear_buffer_backing_copy_warp, passes locally and looks unrelated.Suggested fix (untested): have both checks ignore
revision.txtwhen they list the cache. That's a test-only change, and the file is part of the cache format now. For example, addand p.name != 'revision.txt'instartup_compute_dispatch_native_check.py, and leaverevision.txtout of the listing innative_rtv_variant_check.py.Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; D3D12 WARP and NVIDIA GeForce RTX 5090, driver 32.0.16.1088.
This reply was AI-assisted.