tooling: add --watch mode to compile_dxil for live startup shader requests #2992

Merged
stan495 merged 1 commit from upstream-pr/2992 into cpp-migration 2026-11-27 03:47:30 +00:00
stan495 commented 2026-11-27 03:30:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-27T03:30:16Z.


Target branch cpp-migration. Fixes #2988. Refs #2935.

Behavior

Add continuous and one-shot --watch mode to tools/startup/compile_dxil.cpp (building on #2984):

  • CLI: compile_dxil --watch SDK_DIRECTORY CACHE_DIRECTORY REQUEST_DIRECTORY [--jobs N] [--interval MS] [--once]. Loads and fingerprints the DXC SDK once, then polls REQUEST_DIRECTORY for ready startup graphics (req_<16-hex>.a) and slot-67 compute (req_<16-hex>.c67) requests across N workers.
  • Pending, resume, and retry semantics (aligned with tools/startup/gfx2hlsl.py::pending_keys):
    • Skips completed entries with <key>.txt and complete DXBC stage .cso containers (checking the DXBC magic, total size, and part count).
    • Resumes entries with missing, truncated, or corrupt stage .cso bytecode.
    • Rechecks graphics requests when req_<key>.psin is newer than <key>.txt or removed while <key>.psdep exists.
    • Retries pre-existing <key>.fail entries once on the first watcher pass, skips unchanged .fail entries on later passes unless the marker or .psin is rewritten, and removes stale <key>.fail upon compilation success.
    • Refuses entries whose runtime manifest is unavailable (writing <key>.fail) so later passes do not spin on them.
  • Tests & docs: adds tests/native_compile_dxil_watch_check.py, tests/cmake/native_compile_dxil_watch.cmake, and docs/experiments/native-compile-dxil-watch.md.

Verification

  • Commit under test: ad1e9dad (based on origin/cpp-migration 4ff5e36d)
  • Environment: x64 Windows Release, MSVC, Windows SDK 10.0.26100.0
  • Commands and observed results:
    .\tools\dev.ps1
    cmake --preset release
    cmake --build --preset release --target compile_dxil
    ctest --preset release --no-tests=error -V -R ^(native_compile_dxil_watch|native_compile_dxil_refusals|native_startup_request_cache_controls)$
    # 3/3 passed:
    #   native_compile_dxil_refusals (0.68 sec)
    #   native_compile_dxil_watch (1.33 sec)
    #   native_startup_request_cache_controls (0.66 sec)
    .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py    # Checked 47 Markdown files and 568 links.
    .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py # Checked 2156 tracked source, script and build/CI files: no bidirectional controls.
    
  • Negative controls: incomplete markers ignored, truncated stage .cso resumed, updated/removed .psin rechecked and stale .txt withdrawn, live watcher retries pre-existing .fail once and skips unchanged .fail on subsequent passes until fixed, and invalid --watch CLI invocations fail with diagnostics.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5520681014 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2992). Originally posted by [stan495](https://github.com/stan495) on 2026-11-27T03:30:16Z. --- Target branch `cpp-migration`. Fixes #2988. Refs #2935. ## Behavior Add continuous and one-shot `--watch` mode to `tools/startup/compile_dxil.cpp` (building on #2984): - **CLI**: `compile_dxil --watch SDK_DIRECTORY CACHE_DIRECTORY REQUEST_DIRECTORY [--jobs N] [--interval MS] [--once]`. Loads and fingerprints the DXC SDK once, then polls `REQUEST_DIRECTORY` for ready startup graphics (`req_<16-hex>.a`) and slot-67 compute (`req_<16-hex>.c67`) requests across `N` workers. - **Pending, resume, and retry semantics** (aligned with `tools/startup/gfx2hlsl.py::pending_keys`): - Skips completed entries with `<key>.txt` and complete DXBC stage `.cso` containers (checking the DXBC magic, total size, and part count). - Resumes entries with missing, truncated, or corrupt stage `.cso` bytecode. - Rechecks graphics requests when `req_<key>.psin` is newer than `<key>.txt` or removed while `<key>.psdep` exists. - Retries pre-existing `<key>.fail` entries once on the first watcher pass, skips unchanged `.fail` entries on later passes unless the marker or `.psin` is rewritten, and removes stale `<key>.fail` upon compilation success. - Refuses entries whose runtime manifest is unavailable (writing `<key>.fail`) so later passes do not spin on them. - **Tests & docs**: adds `tests/native_compile_dxil_watch_check.py`, `tests/cmake/native_compile_dxil_watch.cmake`, and `docs/experiments/native-compile-dxil-watch.md`. ## Verification - Commit under test: `ad1e9dad` (based on `origin/cpp-migration` `4ff5e36d`) - Environment: x64 Windows Release, MSVC, Windows SDK `10.0.26100.0` - Commands and observed results: ```powershell .\tools\dev.ps1 cmake --preset release cmake --build --preset release --target compile_dxil ctest --preset release --no-tests=error -V -R ^(native_compile_dxil_watch|native_compile_dxil_refusals|native_startup_request_cache_controls)$ # 3/3 passed: # native_compile_dxil_refusals (0.68 sec) # native_compile_dxil_watch (1.33 sec) # native_startup_request_cache_controls (0.66 sec) .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py # Checked 47 Markdown files and 568 links. .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py # Checked 2156 tracked source, script and build/CI files: no bidirectional controls. ``` - Negative controls: incomplete markers ignored, truncated stage `.cso` resumed, updated/removed `.psin` rechecked and stale `.txt` withdrawn, live watcher retries pre-existing `.fail` once and skips unchanged `.fail` on subsequent passes until fixed, and invalid `--watch` CLI invocations fail with diagnostics.
MasterDomino commented 2026-11-27 03:47:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T03:47:27Z.

Review: APPROVED


Review of head ad1e9dad. CI on the head is green. Approving and merging.

Code read:

  • Pending rules: a key is done when <key>.txt exists and every stage .cso passes a DXBC header, size and part-count check. A .psin newer than the manifest, or a removed .psin with a .psdep left, rechecks it. That is the gfx2hlsl.py::pending_keys contract.
  • Retries: every .fail is retried once on the first pass. After that, a .fail at least as new as the marker and .psin is skipped.
  • Publication order: the manifest is withdrawn first and published last, after the stage files, and the .fail is removed on success. A stale .psdep is removed when the request no longer has a description, which the --requests job does not do.
  • Compute: for slot-67 requests the item matches --requests with gfx1013-direct-cs@0 (no .views, entry 0, the same as the stand-in's in-process route).

Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release. This was tested together with #2989, #2990 and #2994 merged onto cpp-migration 4ff5e36d; all four merge cleanly with each other. ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_dispatch(_.*)?_(warp|hardware)|startup_slot67_indirect_dispatch_warp|startup_compute_translate_e2e_warp|startup_stream_draw.*|startup_native_graphics.*)$' gives 88 tests, 84 passed and 4 skipped (77, WARP has no 32-lane waves). native_compile_dxil_watch, native_compile_dxil_refusals and native_startup_request_cache_controls passed.

Mutation here: never skipping an unchanged .fail on later passes fails native_compile_dxil_watch with "watcher rewrote unchanged .fail on subsequent pass". With it restored, it passes.

Notes, not blocking:

  • Duplicated job: compile_watch_item re-implements the --requests compile job instead of sharing it. It is equivalent today, but the two will drift. For example, the .rtv variants from #2989 reach --requests and not --watch. Moving the job into one shared function would keep them in step.
  • Two watchers on one cache: do not run this next to gfx2hlsl.py --watch (which run.ps1 -Translate starts) on the same cache. Whichever translator refuses a fresh request first writes <key>.fail, and after its first pass the other one skips that key. With the native compiler refusing most current compute requests, the Python fallback would lose those keys. One sentence in docs/experiments/native-compile-dxil-watch.md would prevent that.

I will close #2988 by hand.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083202756 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2992#pullrequestreview-6083202756). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-27T03:47:27Z. **Review:** APPROVED --- Review of head `ad1e9dad`. CI on the head is green. Approving and merging. **Code read:** - **Pending rules:** a key is done when `<key>.txt` exists and every stage `.cso` passes a DXBC header, size and part-count check. A `.psin` newer than the manifest, or a removed `.psin` with a `.psdep` left, rechecks it. That is the `gfx2hlsl.py::pending_keys` contract. - **Retries:** every `.fail` is retried once on the first pass. After that, a `.fail` at least as new as the marker and `.psin` is skipped. - **Publication order:** the manifest is withdrawn first and published last, after the stage files, and the `.fail` is removed on success. A stale `.psdep` is removed when the request no longer has a description, which the `--requests` job does not do. - **Compute:** for slot-67 requests the item matches `--requests` with `gfx1013-direct-cs@0` (no `.views`, entry 0, the same as the stand-in's in-process route). **Run on AMD:** Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release. This was tested together with #2989, #2990 and #2994 merged onto `cpp-migration` `4ff5e36d`; all four merge cleanly with each other. `ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_dispatch(_.*)?_(warp|hardware)|startup_slot67_indirect_dispatch_warp|startup_compute_translate_e2e_warp|startup_stream_draw.*|startup_native_graphics.*)$'` gives 88 tests, 84 passed and 4 skipped (77, WARP has no 32-lane waves). `native_compile_dxil_watch`, `native_compile_dxil_refusals` and `native_startup_request_cache_controls` passed. **Mutation here:** never skipping an unchanged `.fail` on later passes fails `native_compile_dxil_watch` with "watcher rewrote unchanged .fail on subsequent pass". With it restored, it passes. **Notes, not blocking:** - **Duplicated job:** `compile_watch_item` re-implements the `--requests` compile job instead of sharing it. It is equivalent today, but the two will drift. For example, the `.rtv` variants from #2989 reach `--requests` and not `--watch`. Moving the job into one shared function would keep them in step. - **Two watchers on one cache:** do not run this next to `gfx2hlsl.py --watch` (which `run.ps1 -Translate` starts) on the same cache. Whichever translator refuses a fresh request first writes `<key>.fail`, and after its first pass the other one skips that key. With the native compiler refusing most current compute requests, the Python fallback would lose those keys. One sentence in `docs/experiments/native-compile-dxil-watch.md` would prevent that. I will close #2988 by hand. AI-assisted; the commands above were run locally.
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!2992
No description provided.