shader: invalidate watch manifests when sidecar content changes with an older mtime #3140

Manually merged
github merged 1 commit from github-bot/gh-3138 into codex/native-shader-modules 2026-11-28 06:21:22 +00:00 AGit
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-27 17:02 UTC · original
legacy-code-archaeologist:shader/watch-sidecar-content-invalidation → codex/native-shader-modules · +158 −28 · 4 files · 1 commits · merged 2026-11-28 06:15 UTC

Fixes #3135 (Refs #3091).
Base: codex/native-shader-modules at a48d39dc; commit 4a7e2542.

Root Cause

In tools/startup/compile_dxil.cpp, is_watch_request_pending() only invalidated a published graphics manifest when max(mtime(.psin), mtime(.ps57in)) > mtime(<key>.txt) or when both sidecars disappeared while <key>.psdep existed. Adding a contradictory .ps57in with an older timestamp (<= mtime(<key>.txt)) or changing .psin/.ps57in content while preserving an older timestamp left the stale <key>.txt manifest on disk.

Summary

  • Extract read_pixel_inputs() in src/shader_compute_request.cpp and expose x2w::read_pixel_input_description() in src/shader_compute_request.h so the watcher and request loader share exact .psin/.ps57in parsing and conflict rules.
  • Update is_watch_request_pending() in tools/startup/compile_dxil.cpp to compare canonical current sidecar content from read_pixel_input_description() against published <key>.psdep (marking any mismatch, new sidecar, conflict, or invalid sidecar as sidecar_changed regardless of timestamp).
  • Extend tests/native_compile_dxil_watch_check.py with unchanged-input cache-hit controls (both .psin and indexed reflected .ps57in), older- vs newer-mtime contradictory .ps57in equivalence (withdrawing <key>.txt with identical stdout/.fail), preserved-older-mtime .psin and .ps57in content changes, and base+.rtv variant 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_watch 3.47s, native_direct_container 24.45s, native_rtv_variant_controls 2.29s, native_startup_request_cache_controls 1.60s, native_frozen_request 0.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 (79 Markdown files, 586 links).

AI-assisted.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-27 17:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138) `legacy-code-archaeologist:shader/watch-sidecar-content-invalidation` → `codex/native-shader-modules` · +158 −28 · 4 files · 1 commits · merged 2026-11-28 06:15 UTC Fixes #3135 (Refs #3091). Base: `codex/native-shader-modules` at `a48d39dc`; commit `4a7e2542`. ## Root Cause In [tools/startup/compile_dxil.cpp](tools/startup/compile_dxil.cpp), `is_watch_request_pending()` only invalidated a published graphics manifest when `max(mtime(.psin), mtime(.ps57in)) > mtime(<key>.txt)` or when both sidecars disappeared while `<key>.psdep` existed. Adding a contradictory `.ps57in` with an older timestamp (`<= mtime(<key>.txt)`) or changing `.psin`/`.ps57in` content while preserving an older timestamp left the stale `<key>.txt` manifest on disk. ## Summary - Extract `read_pixel_inputs()` in [src/shader_compute_request.cpp](src/shader_compute_request.cpp) and expose `x2w::read_pixel_input_description()` in [src/shader_compute_request.h](src/shader_compute_request.h) so the watcher and request loader share exact `.psin`/`.ps57in` parsing and conflict rules. - Update `is_watch_request_pending()` in [tools/startup/compile_dxil.cpp](tools/startup/compile_dxil.cpp) to compare canonical current sidecar content from `read_pixel_input_description()` against published `<key>.psdep` (marking any mismatch, new sidecar, conflict, or invalid sidecar as `sidecar_changed` regardless of timestamp). - Extend [tests/native_compile_dxil_watch_check.py](tests/native_compile_dxil_watch_check.py) with unchanged-input cache-hit controls (both `.psin` and indexed reflected `.ps57in`), older- vs newer-mtime contradictory `.ps57in` equivalence (withdrawing `<key>.txt` with identical stdout/`.fail`), preserved-older-mtime `.psin` and `.ps57in` content changes, and base+`.rtv` variant 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_watch` `3.47s`, `native_direct_container` `24.45s`, `native_rtv_variant_controls` `2.29s`, `native_startup_request_cache_controls` `1.60s`, `native_frozen_request` `0.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 (`79` Markdown files, `586` links). AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:07:14 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 21:23 UTC · original · approved these changes

I reviewed 4a7e2542 merged over current codex/native-shader-modules a48d39dc, the PR's base. The merge is clean and git diff --cached --check is clean. #3139 fixes the same issue (#3135) a different way, so I ran each PR's new regressions against the other's build (below).

What I traced.

  • Shared parsing: read_pixel_inputs is a straight extraction of the .psin / .ps57in block from read_graphics_request, so the watcher and the request loader now apply the same parse and conflict rules.
  • What the watcher compares: it compares the canonical description with <key>.psdep, and both compile paths write .psdep from the same input.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.
  • The 256-byte cap: a .psin description is psin1 <key> ena= addr= text (parse_pixel_inputs caps the source at 128 bytes), and a .ps57in description is 12 bytes, so the cap can't refuse a real .psdep.
  • RTV variants: the watcher reads the base's sidecars through graphics_psin_path and replace_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_dump in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$'

5/5 pass in both presets.

Cross-check with #3139.

  • #3137's regressions on this build: I ran #3139's tests/native_startup_request_cache_check.py against this build, with only its .psinh-file existence assert removed. native_startup_request_cache_controls passes, so this PR also covers #3139's four cases.
  • This PR's regressions on #3139's build: run the other way, this PR's native_compile_dxil_watch_check.py fails on #3139. 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 rebuilt compile_dxil in dev and ran the watch, cache and RTV tests:

Mutant Result
sidecar_changed = current_dep != published_dep; → false killed (1 of 3 fails)
invalid or conflicting sidecar (catch) → sidecar_changed = false killed
unreadable or empty .psdep branch → sidecar_changed = false survives

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking.

  1. The unreadable-.psdep branch isn't pinned. A 0-byte <key>.psdep next to a published manifest with a valid .psin would pin it. Today that should withdraw the manifest, and the mutant serves it.
  2. The batch path can leave a stale .psdep. It writes .psdep only 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_dep and 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 #3135, 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 targets codex/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 main and cpp-migration).

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 21:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138#pullrequestreview-6093457581) · **approved these changes** I reviewed `4a7e2542` merged over current `codex/native-shader-modules` `a48d39dc`, the PR's base. The merge is clean and `git diff --cached --check` is clean. #3139 fixes the same issue (#3135) a different way, so I ran each PR's new regressions against the other's build (below). **What I traced.** - **Shared parsing:** `read_pixel_inputs` is a straight extraction of the `.psin` / `.ps57in` block from `read_graphics_request`, so the watcher and the request loader now apply the same parse and conflict rules. - **What the watcher compares:** it compares the canonical description with `<key>.psdep`, and both compile paths write `.psdep` from the same `input.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. - **The 256-byte cap:** a `.psin` description is `psin1 <key> ena= addr=` text (`parse_pixel_inputs` caps the source at 128 bytes), and a `.ps57in` description is 12 bytes, so the cap can't refuse a real `.psdep`. - **RTV variants:** the watcher reads the base's sidecars through `graphics_psin_path` and `replace_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_dump` in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_compile_dxil_watch|native_startup_request_cache_controls|native_rtv_variant_controls|native_direct_container|native_frozen_request)$' ``` 5/5 pass in both presets. **Cross-check with #3139.** - **#3137's regressions on this build:** I ran #3139's `tests/native_startup_request_cache_check.py` against this build, with only its `.psinh`-file existence assert removed. `native_startup_request_cache_controls` passes, so this PR also covers #3139's four cases. - **This PR's regressions on #3139's build:** run the other way, this PR's `native_compile_dxil_watch_check.py` fails on #3139. 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 rebuilt `compile_dxil` in `dev` and ran the watch, cache and RTV tests: | Mutant | Result | |---|---| | `sidecar_changed = current_dep != published_dep;` → `false` | killed (1 of 3 fails) | | invalid or conflicting sidecar (`catch`) → `sidecar_changed = false` | killed | | unreadable or empty `.psdep` branch → `sidecar_changed = false` | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** 1. **The unreadable-`.psdep` branch isn't pinned.** A 0-byte `<key>.psdep` next to a published manifest with a valid `.psin` would pin it. Today that should withdraw the manifest, and the mutant serves it. 2. **The batch path can leave a stale `.psdep`.** It writes `.psdep` only 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_dep` and 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 #3135, 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 targets `codex/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 `main` and `cpp-migration`). This reply was AI-assisted.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 21:24 UTC · original · approved these changes

Independently reviewed 4a7e2542 on the exact a48d39dc compiler 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_dump in dev and release. 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. Windows 26200.9974, SDK/DXC 10.0.26100.0. Please coordinate this with #3139 and carry a single watcher fix into the #3091 compiler integration, then repeat on the final main base.

**@⁠R0Y00** on GitHub · 2026-11-27 21:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138#pullrequestreview-6093464041) · **approved these changes** Independently reviewed `4a7e2542` on the exact `a48d39dc` compiler 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_dump` in `dev` and `release`. `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. Windows `26200.9974`, SDK/DXC `10.0.26100.0`. Please coordinate this with #3139 and carry a single watcher fix into the #3091 compiler integration, then repeat on the final `main` base.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-27 23:56 UTC · original

Agree with both APPROVED reviews: extracting read_pixel_inputs() so the watcher and request loader share exact .psin/.ps57in parsing 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 through graphics_psin_path.

**@⁠KelboLive** on GitHub · 2026-11-27 23:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138#issuecomment-7230518452) Agree with both APPROVED reviews: extracting `read_pixel_inputs()` so the watcher and request loader share exact `.psin`/`.ps57in` parsing 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 through `graphics_psin_path`.
github-bot force-pushed github-bot/gh-3138 from 4a7e254234 to e31ffc6d63 2026-11-28 00:39:35 +00:00 Compare
Author
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-28 00:38 UTC · original

Rebased onto codex/native-shader-modules (247530b0, preserving read_pixel_input_description() and canonical .psdep comparison in needs_compile()) and also addressed @pigalot's two non-blocking notes:

  1. Batch-path stale .psdep cleanup: compile_job in tools/startup/compile_dxil.cpp now removes <key>.psdep when input.pixel_input_description.empty(), matching the watch path.
  2. 0-byte .psdep regression check: Added a check in tests/native_compile_dxil_watch_check.py truncating <key>.psdep to 0 bytes next to a published manifest and valid .psin, verifying compile_dxil --once retranslates and restores .psdep.

Local verification (dev and release presets, 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: passed
  • cmake --build --preset release --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump: passed
  • ctest --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 (127 Markdown files, 626 links)

AI-assisted.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-28 00:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138#issuecomment-7231076672) Rebased onto `codex/native-shader-modules` (`247530b0`, preserving `read_pixel_input_description()` and canonical `.psdep` comparison in `needs_compile()`) and also addressed `@pigalot`'s two non-blocking notes: 1. **Batch-path stale `.psdep` cleanup:** `compile_job` in `tools/startup/compile_dxil.cpp` now removes `<key>.psdep` when `input.pixel_input_description.empty()`, matching the watch path. 2. **0-byte `.psdep` regression check:** Added a check in `tests/native_compile_dxil_watch_check.py` truncating `<key>.psdep` to 0 bytes next to a published manifest and valid `.psin`, verifying `compile_dxil --once` retranslates and restores `.psdep`. **Local verification (`dev` and `release` presets, 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`: passed - `cmake --build --preset release --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump native_compute_ir_dump`: passed - `ctest --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 (`127` Markdown files, `626` links) AI-assisted.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 00:39 UTC · original

The compiler base #3091 now points to 247530b0 and 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 #3135.

**@⁠R0Y00** on GitHub · 2026-11-28 00:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138#issuecomment-7231089409) The compiler base #3091 now points to 247530b0 and 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 #3135.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-28 01:01 UTC · original · approved these changes

Reviewed e31ffc6d63 on compiler base 247530b0. 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.

**@⁠R0Y00** on GitHub · 2026-11-28 01:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3138#pullrequestreview-6094789997) · **approved these changes** Reviewed e31ffc6d637c4335455693d6bb90459cb3e7e9d4 on compiler base 247530b0. 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.
github manually merged commit 0b505c1cb5 into codex/native-shader-modules 2026-11-28 06:21:22 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.