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

Merged
legacy-code-archaeologist merged 1 commit from upstream-pr/3138 into codex/native-shader-modules 2026-11-28 06:15:48 +00:00
legacy-code-archaeologist commented 2026-11-27 17:02:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T17:02:23Z.


Fixes #3133 (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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5530345493 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T17:02:23Z. --- Fixes #3133 (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.
pigalot commented 2026-11-27 21:23:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T21:23:35Z.

Review: APPROVED


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. #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.

  • 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 #3137.

  • #3137's regressions on this build: I ran #3137'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 #3137's four cases.
  • This PR's regressions on #3137's build: run the other way, this PR's native_compile_dxil_watch_check.py fails 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 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 #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 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093457581 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138#pullrequestreview-6093457581). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T21:23:35Z. **Review:** APPROVED --- 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. #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.** - **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 #3137.** - **#3137's regressions on this build:** I ran #3137'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 #3137's four cases. - **This PR's regressions on #3137's build:** run the other way, this PR's `native_compile_dxil_watch_check.py` fails 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 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 #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 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.
R0Y00 commented 2026-11-27 21:24:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:24:45Z.

Review: APPROVED


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 #3137 and carry a single watcher fix into the #3091 compiler integration, then repeat on the final main base.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093464041 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138#pullrequestreview-6093464041). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T21:24:45Z. **Review:** APPROVED --- 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 #3137 and carry a single watcher fix into the #3091 compiler integration, then repeat on the final `main` base.
KelboLive commented 2026-11-27 23:56:08 +00:00 (Migrated from github.com)

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/.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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7230518452 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138#issuecomment-7230518452). Originally posted by [KelboLive](https://github.com/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`/`.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`.
legacy-code-archaeologist commented 2026-11-28 00:38:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-28T00:38:32Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7231076672 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138#issuecomment-7231076672). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-28T00:38:32Z. --- 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.
R0Y00 commented 2026-11-28 00:39:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T00:39:27Z.


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 #3133.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7231089409 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138#issuecomment-7231089409). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T00:39:27Z. --- 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 #3133.
R0Y00 commented 2026-11-28 01:01:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T01:01:17Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094789997 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3138#pullrequestreview-6094789997). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T01:01:17Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
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!3138
No description provided.