tooling: write .fail diagnostics and add read-only --refusals summary to compile_dxil #2984

Merged
stan495 merged 1 commit from upstream-pr/2984 into cpp-migration 2026-11-27 03:17:19 +00:00
stan495 commented 2026-11-27 02:53:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-27T02:53:42Z.


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

Behavior

  1. Per-request .fail lifecycle in compile_dxil --requests ( ools/startup/compile_dxil.cpp):
    • Reserves <stem>.fail alongside <stem>.txt in batch mode.
    • Atomically publishes a sanitized single-line <key>.fail when a startup graphics (req_<key>.a) or slot-67 compute (req_<key>.c67) request is refused, while publishing no stage .cso or <key>.txt.
    • Removes any stale <key>.fail when the same request succeeds on a subsequent run.
  2. Read-only compile_dxil --refusals REQUEST_DIRECTORY [--jobs N] [--json] ( ools/startup/compile_dxil.cpp, src/direct_compute_cache.{h,cpp}):
    • Scans req_<key>.a and req_<key>.c67 requests and runs native translation/validation across N workers without invoking DXC or writing any cache/output files (adding write_cache = true to prepare_direct_graphics so --refusals passes false).
    • Strips leading native compute +0x...: PC prefixes and normalizes hex literals, byte offsets, VGPR indices, and register numbers/ranges in aggregated refusal counts; emits TSV text or JSON.
  3. Allowlisted triage_run.py classification ( ools/startup/triage_run.py):
    • Classifies native .fail first lines under SHADER_REASONS using fixed tokens or instruction-family prefixes without copying arbitrary text, paths, or hex words.

Verification

  • Commit under test: b6342d98 (based on origin/cpp-migration 05438d65)
  • 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_refusals|native_startup_request_cache_controls)$
    # 2/2 passed:
    #   native_compile_dxil_refusals (0.58 sec)
    #   native_startup_request_cache_controls (0.72 sec)
    .\out\pe-env\Scripts\python.exe -B tests/startup_triage_run_check.py   # startup triage_run checks: 0 failed
    .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py          # Checked 46 Markdown files and 567 links.
    .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py       # Checked 2154 tracked source, script and build/CI files: no bidirectional controls.
    
  • Negative controls: stale .fail removal, refused re-run withdrawing <key>.txt, directory snapshot proving --refusals performs zero writes, hex/key/PC redaction in --refusals and triage_run.py, and invalid --refusals CLI arguments.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5520364021 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2984). Originally posted by [stan495](https://github.com/stan495) on 2026-11-27T02:53:42Z. --- Target branch `cpp-migration`. Fixes #2983. Refs #2935. ## Behavior 1. **Per-request `.fail` lifecycle in `compile_dxil --requests` ( ools/startup/compile_dxil.cpp)**: - Reserves `<stem>.fail` alongside `<stem>.txt` in batch mode. - Atomically publishes a sanitized single-line `<key>.fail` when a startup graphics (`req_<key>.a`) or slot-67 compute (`req_<key>.c67`) request is refused, while publishing no stage `.cso` or `<key>.txt`. - Removes any stale `<key>.fail` when the same request succeeds on a subsequent run. 2. **Read-only `compile_dxil --refusals REQUEST_DIRECTORY [--jobs N] [--json]` ( ools/startup/compile_dxil.cpp, src/direct_compute_cache.{h,cpp})**: - Scans `req_<key>.a` and `req_<key>.c67` requests and runs native translation/validation across `N` workers without invoking DXC or writing any cache/output files (adding `write_cache = true` to `prepare_direct_graphics` so `--refusals` passes `false`). - Strips leading `native compute +0x...:` PC prefixes and normalizes hex literals, byte offsets, VGPR indices, and register numbers/ranges in aggregated refusal counts; emits TSV text or JSON. 3. **Allowlisted `triage_run.py` classification ( ools/startup/triage_run.py)**: - Classifies native `.fail` first lines under `SHADER_REASONS` using fixed tokens or instruction-family prefixes without copying arbitrary text, paths, or hex words. ## Verification - Commit under test: `b6342d98` (based on `origin/cpp-migration` `05438d65`) - 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_refusals|native_startup_request_cache_controls)$ # 2/2 passed: # native_compile_dxil_refusals (0.58 sec) # native_startup_request_cache_controls (0.72 sec) .\out\pe-env\Scripts\python.exe -B tests/startup_triage_run_check.py # startup triage_run checks: 0 failed .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py # Checked 46 Markdown files and 567 links. .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py # Checked 2154 tracked source, script and build/CI files: no bidirectional controls. ``` - Negative controls: stale `.fail` removal, refused re-run withdrawing `<key>.txt`, directory snapshot proving `--refusals` performs zero writes, hex/key/PC redaction in `--refusals` and `triage_run.py`, and invalid `--refusals` CLI arguments.
MasterDomino commented 2026-11-27 03:17:04 +00:00 (Migrated from github.com)

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

Review: APPROVED


Review of head b6342d98, which is on the current cpp-migration tip 05438d65. CI on the head is green. Approving and merging.

Code read:

  • .fail lifecycle: <stem>.fail is reserved with the other outputs. It is published atomically only from the batch worker's catch, after the job has already withdrawn <key>.txt and published no stage bytecode, and it is removed after each successful compute or graphics publication.
  • --refusals: it reads req_*.a and req_*.c67, runs read_graphics_request + prepare_direct_graphics(..., write_cache = false) and read_compute_request + translate_compute(req, 0, true), and never starts DXC. Entry 0 matches the stand-in's in-process route. With write_cache = false the pair cache is neither read nor published. Interface companions are still read from REQUEST_DIRECTORY/interfaces, so the decode matches a real run.
  • Redaction: the PC prefix is stripped, and hex words, at byte N, VGPR N and sN/vN/s[N:N] are normalized before counting. The triage_run.py patterns are anchored allowlists, and the private-text check gains two native lines.
  • parse_jobs_count is shared with the existing --jobs path, with the same 1–64 bounds.

Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release.

  • ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_translate_e2e_warp|startup_slot67_indirect_dispatch_warp)$' gives 60 tests, 57 passed and 3 skipped (77: native_comparison_pso_warp, native_heap_handle_probe_warp, native_global_srv_heap_replay_warp, because WARP has no 32-lane waves). That includes native_compile_dxil_refusals and native_startup_request_cache_controls.
  • tests/startup_triage_run_check.py: 0 failed.

On one local start-up capture (copied request files only; counts only):

--refusals --jobs 8 --requests --jobs 8 with DXC
Compute (req_*.c67) 2,747 examined, 415 no refusal, 2,332 refused (56 distinct reasons) 415 compiled, 2,332 refused, 2,332 .fail
Graphics (req_*.a) 628 examined, 3 no refusal, 625 refused (7 distinct reasons) 3 compiled, 625 refused, 625 .fail

The census agrees with the real compile on both counts. A snapshot of names, sizes and modification times of the request directory is identical before and after --refusals.

Mutations here:

  • Passing write_cache = true from --refusals fails native_compile_dxil_refusals with read-only --refusals modified the request directory.
  • Dropping both stale-.fail removals fails it with stale .fail survived successful compilation.
  • With each restored, it passes.

Note, not blocking: <key>.fail is the same name gfx2hlsl.py writes, as #2935 asks, so triage_run.py reads both. If compile_dxil --requests writes into a directory where gfx2hlsl.py --watch also runs, a native .fail newer than its request makes later watch passes skip that key (pending_keys(skip_failed=True)). Running both translators into one directory was already unsafe before this PR, since a native refusal withdraws a published <key>.txt. A line in the topic note saying the two should use separate output directories during the migration would help.

I will close #2983 by hand.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083008446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2984#pullrequestreview-6083008446). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-27T03:17:04Z. **Review:** APPROVED --- Review of head `b6342d98`, which is on the current `cpp-migration` tip `05438d65`. CI on the head is green. Approving and merging. **Code read:** - **`.fail` lifecycle:** `<stem>.fail` is reserved with the other outputs. It is published atomically only from the batch worker's catch, after the job has already withdrawn `<key>.txt` and published no stage bytecode, and it is removed after each successful compute or graphics publication. - **`--refusals`:** it reads `req_*.a` and `req_*.c67`, runs `read_graphics_request` + `prepare_direct_graphics(..., write_cache = false)` and `read_compute_request` + `translate_compute(req, 0, true)`, and never starts DXC. Entry 0 matches the stand-in's in-process route. With `write_cache = false` the pair cache is neither read nor published. Interface companions are still read from `REQUEST_DIRECTORY/interfaces`, so the decode matches a real run. - **Redaction:** the PC prefix is stripped, and hex words, `at byte N`, `VGPR N` and `sN`/`vN`/`s[N:N]` are normalized before counting. The `triage_run.py` patterns are anchored allowlists, and the private-text check gains two native lines. - `parse_jobs_count` is shared with the existing `--jobs` path, with the same 1–64 bounds. **Run on AMD:** Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release. - `ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_translate_e2e_warp|startup_slot67_indirect_dispatch_warp)$'` gives 60 tests, 57 passed and 3 skipped (77: `native_comparison_pso_warp`, `native_heap_handle_probe_warp`, `native_global_srv_heap_replay_warp`, because WARP has no 32-lane waves). That includes `native_compile_dxil_refusals` and `native_startup_request_cache_controls`. - `tests/startup_triage_run_check.py`: 0 failed. **On one local start-up capture** (copied request files only; counts only): | | `--refusals --jobs 8` | `--requests --jobs 8` with DXC | |---|---|---| | Compute (`req_*.c67`) | 2,747 examined, 415 no refusal, 2,332 refused (56 distinct reasons) | 415 compiled, 2,332 refused, 2,332 `.fail` | | Graphics (`req_*.a`) | 628 examined, 3 no refusal, 625 refused (7 distinct reasons) | 3 compiled, 625 refused, 625 `.fail` | The census agrees with the real compile on both counts. A snapshot of names, sizes and modification times of the request directory is identical before and after `--refusals`. **Mutations here:** - Passing `write_cache = true` from `--refusals` fails `native_compile_dxil_refusals` with `read-only --refusals modified the request directory`. - Dropping both stale-`.fail` removals fails it with `stale .fail survived successful compilation`. - With each restored, it passes. **Note, not blocking:** `<key>.fail` is the same name `gfx2hlsl.py` writes, as #2935 asks, so `triage_run.py` reads both. If `compile_dxil --requests` writes into a directory where `gfx2hlsl.py --watch` also runs, a native `.fail` newer than its request makes later watch passes skip that key (`pending_keys(skip_failed=True)`). Running both translators into one directory was already unsafe before this PR, since a native refusal withdraws a published `<key>.txt`. A line in the topic note saying the two should use separate output directories during the migration would help. I will close #2983 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!2984
No description provided.