shader: invalidate watch manifests when sidecar content changes with an older mtime #3138
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3138"
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 legacy-code-archaeologist on 2026-11-27T17:02:23Z.
Fixes #3133 (Refs #3091).
Base:
codex/native-shader-modulesata48d39dc; commit4a7e2542.Root Cause
In tools/startup/compile_dxil.cpp,
is_watch_request_pending()only invalidated a published graphics manifest whenmax(mtime(.psin), mtime(.ps57in)) > mtime(<key>.txt)or when both sidecars disappeared while<key>.psdepexisted. Adding a contradictory.ps57inwith an older timestamp (<= mtime(<key>.txt)) or changing.psin/.ps57incontent while preserving an older timestamp left the stale<key>.txtmanifest on disk.Summary
read_pixel_inputs()in src/shader_compute_request.cpp and exposex2w::read_pixel_input_description()in src/shader_compute_request.h so the watcher and request loader share exact.psin/.ps57inparsing and conflict rules.is_watch_request_pending()in tools/startup/compile_dxil.cpp to compare canonical current sidecar content fromread_pixel_input_description()against published<key>.psdep(marking any mismatch, new sidecar, conflict, or invalid sidecar assidecar_changedregardless of timestamp)..psinand indexed reflected.ps57in), older- vs newer-mtime contradictory.ps57inequivalence (withdrawing<key>.txtwith identical stdout/.fail), preserved-older-mtime.psinand.ps57incontent changes, and base+.rtvvariant invalidation when base gains an older-mtime.ps57in.Verification
cmake --build --preset dev --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump: built cleanly.ctest --preset dev --no-tests=error -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$' -V: 5/5 passed (native_compile_dxil_watch3.47s,native_direct_container24.45s,native_rtv_variant_controls2.29s,native_startup_request_cache_controls1.60s,native_frozen_request0.01s).ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' -j 4 --output-on-failure: 26/26 passed (18.69s).tests/docs_links_check.py: passed (79Markdown files,586links).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T21:23:35Z.
Review: APPROVED
I reviewed
4a7e2542merged over currentcodex/native-shader-modulesa48d39dc, the PR's base. The merge is clean andgit diff --cached --checkis clean. #3137 fixes the same issue (#3133) a different way, so I ran each PR's new regressions against the other's build (below).What I traced.
read_pixel_inputsis a straight extraction of the.psin/.ps57inblock fromread_graphics_request, so the watcher and the request loader now apply the same parse and conflict rules.<key>.psdep, and both compile paths write.psdepfrom the sameinput.pixel_input_description. So the comparison is against what the manifest was actually compiled from, not against the sidecar bytes as they are on disk at publish time..psindescription ispsin1 <key> ena= addr=text (parse_pixel_inputscaps the source at 128 bytes), and a.ps57indescription is 12 bytes, so the cap can't refuse a real.psdep.graphics_psin_pathandreplace_extension(L".a"), so a variant checks its base's.psin/.ps57in.What I ran. I built
compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dumpindevandrelease, then ran5/5 pass in both presets.
Cross-check with #3137.
tests/native_startup_request_cache_check.pyagainst this build, with only its.psinh-file existence assert removed.native_startup_request_cache_controlspasses, so this PR also covers #3137's four cases.native_compile_dxil_watch_check.pyfails on #3137. The RTV variant keeps its stale manifest when the base gains an older-mtime.ps57in.Mutants in
tools/startup/compile_dxil.cpp. For each, I rebuiltcompile_dxilindevand ran the watch, cache and RTV tests:sidecar_changed = current_dep != published_dep;→falsecatch) →sidecar_changed = false.psdepbranch →sidecar_changed = falseRestored and rebuilt afterwards;
git diff --quietis clean.Non-blocking.
.psdepbranch isn't pinned. A 0-byte<key>.psdepnext to a published manifest with a valid.psinwould pin it. Today that should withdraw the manifest, and the mutant serves it..psdep. It writes.psdeponly when the description is non-empty and never removes an old one; the watch path does remove it. If the sidecars disappear between two batch runs, the next watch poll sees"" != published_depand retranslates once. That converges, but removing it in the batch path as well would avoid the extra compile.Verdict: approve on
4a7e2542. Of the two fixes for #3133, this is the one I'd take. It needs no new cache file, it compares with what the manifest was compiled from, and it covers RTV variants. This targetscodex/native-shader-modules, so I'm leaving the merge to the branch owner.Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10. These are CPU-only checks.
CI: none on this PR (the workflow runs only for
mainandcpp-migration).This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:24:45Z.
Review: APPROVED
Independently reviewed
4a7e2542on the exacta48d39dccompiler stack. The watcher resolves an RTV request to the base sidecar and compares canonical parsed content to.psdep, which was produced from the same input as the published stages. That avoids both a second digest file and a fresh read at publish time. The stale-manifest controls cover the base and its RTV variant.Built
compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dumpindevandrelease.ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_frozen_request)$'passed 4/4 in both builds, zero skips. The preserved-mtime conflicts withdraw both manifests, unchanged sidecars remain cache hits and the regular watch retry/skip controls pass. Windows26200.9974, SDK/DXC10.0.26100.0. Please coordinate this with #3137 and carry a single watcher fix into the #3091 compiler integration, then repeat on the finalmainbase.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:56:08Z.
Agree with both APPROVED reviews: extracting
read_pixel_inputs()so the watcher and request loader share exact.psin/.ps57inparsing is the right approach. Comparing canonical parsed content against.psdep(what the manifest was compiled from) avoids a second digest file and fresh read at publish time. RTV variant coverage is correct — reads base sidecars throughgraphics_psin_path.Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-28T00:38:32Z.
Rebased onto
codex/native-shader-modules(247530b0, preservingread_pixel_input_description()and canonical.psdepcomparison inneeds_compile()) and also addressed@pigalot's two non-blocking notes:.psdepcleanup:compile_jobintools/startup/compile_dxil.cppnow removes<key>.psdepwheninput.pixel_input_description.empty(), matching the watch path..psdepregression check: Added a check intests/native_compile_dxil_watch_check.pytruncating<key>.psdepto 0 bytes next to a published manifest and valid.psin, verifyingcompile_dxil --onceretranslates and restores.psdep.Local verification (
devandreleasepresets, Windows 10.0.26100):cmake --build --preset dev --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump: passedcmake --build --preset release --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump: passedctest --preset dev --no-tests=error -j 1 -V -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$': 5/5 passed (39.04s, 0 skips)ctest --preset release --no-tests=error -j 1 -V -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$': 5/5 passed (35.52s, 0 skips)python -B tests/docs_links_check.py: passed (127Markdown files,626links)AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T00:39:27Z.
The compiler base #3091 now points to
247530b0and this PR conflicts in compile_dxil.cpp. The base has a small guard for older-timestamp slot-57 files and the mixed-sidecar case. Your shared parser and canonical comparison cover the remaining timestamp-preserved stream changes and RTV variants. Please update this PR on the current base, use the shared comparison in place of the narrower watcher guard, and keep the unchanged-cache and old-timestamp controls. This is the follow-up we should carry forward for #3133.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T01:01:17Z.
Review: APPROVED
Reviewed
e31ffc6d63on compiler base247530b0. The watcher and request reader use the same canonical parser and compare the actual sidecar content to the dependency saved at publication. The controls cover preserved older timestamps for stream and slot-57 inputs, the derived RTV requests, unchanged cache hits and an empty dependency file. Batch and watch now both clear an obsolete dependency.Debug and Release /O2 each passed five source-built tests: native_compile_dxil_watch, native_startup_request_cache_controls, native_rtv_variant_controls, native_compute_pack and native_frozen_request. Windows 11 26200.9974, SDK 10.0.26100. This approval covers the current stack head. Once the compiler stack is integrated, rerun the required checks on the eventual main target.