Repository navigation
startup: warn when the shader cache and the translator come from different revisions - #2820
Conversation
…nt revisions The runtime writes its graphics, compute and mesh57 key revisions to <X2W_SHADER_CACHE>/revision.txt before its first request. run.ps1 and run.sh compare it with the gfx2hlsl.py they start (tools/startup/shader_cache_revision.py) and print one warning with both revisions and the fixes; a cache with requests and no revision.txt warns too. -FreshShaderCache / --fresh-shader-cache moves a cache that is not empty aside. Fixes R0Y00#2815.
…er-cache-revision # Conflicts: # src/startup_stubs/d3d12_draw.inl
|
Merged origin/main into the branch (merge commit, no force push): main had raised the cache revision to Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
Skipped, as expected: Linux at this head: AI-assisted; commands listed were executed locally. |
…o tester-loop
|
Stage-2 gate PASS at Verification:
AI-assisted; commands listed were executed locally. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…ader cache Since R0Y00#2815 the runtime writes revision.txt into X2W_SHADER_CACHE with its first request, so `manifest, = cache.glob('*.txt')` found two files in the logical view, address SRV, joined table pointer, d16 SRV, MUBUF descriptor and pixel UAV draw checks.
…to tester-loop
|
New commit Verified on Windows Server 2025 (D3D12 WARP and the hardware adapter variant),
Linux: AI-assisted; commands listed were executed locally. |
pigalot
left a comment
There was a problem hiding this comment.
I tried to review d39f65cf over main 429f11d5, 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.
|
Updated with Not yet run on Windows after the merge: the Commands run locally: 18 Python checks including AI-assisted; commands listed were executed locally. |
|
Verification: head 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: AI-assisted; commands listed were executed locally. |
pigalot
left a comment
There was a problem hiding this comment.
Reviewed 624bc81f merged over current main c1de64a5. The merge is clean and git diff --cached --check is clean.
The conflicts from my comment on d39f65cf are resolved.
- Revisions:
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 dev and release, then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -E '(_hardware$|startup_audio_)' -R '^(startup_shader_cache_revision|startup_shader_cache_rekey.*|runtime_shader_cache_rekey.*|startup_run_ps1.*|startup_run_sh.*|startup_compute_request.*|startup_address_srv.*|startup_d16_srv.*|startup_indirect_draw_indexed.*|startup_joined_table_pointer.*|startup_logical_view.*|startup_mubuf_descriptor.*|startup_pixel_uav.*)$'
# with X2W_TEST_DEBUG_LAYER=1, one at a time
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_address_srv|startup_d16_srv|startup_indirect_draw_indexed|startup_joined_table_pointer|startup_logical_view|startup_mubuf_descriptor|startup_pixel_uav|startup_compute_request).*_hardware$'The results were the same in both presets:
- Without
_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_sh and startup_compute_request*:
| Mutant | Result |
|---|---|
publish_shader_request no longer calls write_cache_revision |
killed (startup_compute_request_warp) |
warning() returns None when no revision kind is shared (shared and dropped) |
killed (startup_shader_cache_revision) |
a cache with requests but no revision.txt gets no warning |
killed (startup_shader_cache_revision) |
--fresh moves an empty cache aside too |
killed (startup_shader_cache_revision) |
warning() compares only the graphics revision |
survives |
run.ps1 skips the post-run check |
survives |
Restored and rebuilt afterwards; git diff --quiet is clean.
Non-blocking.
- Compute and mesh57 mismatches are unpinned. No case has a
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. - The post-run warning is unpinned.
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 fixtures and Run platform-independent Python checks on Linux pass on 624bc81f.
This reply was AI-assisted.
|
Follow-up to my approval: this change broke two tests on
The cause: Reproduced locally on a current- ctest --test-dir out/build/dev --no-tests=error -R '^(startup_compute_dispatch_native_(warp|hardware)|native_rtv_variant_warp)$' --output-on-failureAll three fail. The third failure in that run, Suggested fix (untested): have both checks ignore 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. |
… texture-output cases Since R0Y00#2820 the stand-in writes revision.txt into the shader cache with the first request. R0Y00#3231 allowed it in step 1 of startup_compute_dispatch_native_check.py; the two exact-set assertions that close table_views and texture_outputs need the same exception, or the check fails after its last Dispatch. Refs R0Y00#3149 AI-assisted. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
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.