tooling: resume startup shader compilation after manifest-only runs #2001

Merged
avt0m4t48 merged 1 commit from upstream-pr/2008 into main 2026-11-24 23:26:19 +00:00
avt0m4t48 commented 2026-11-24 22:59:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by avt0m4t48 on 2026-11-24T22:59:34Z.


Change

An explicit manifest-only pass (X2W_FXC=) produces a manifest and HLSL without compiled shader stages. A later --pending run with FXC enabled now compiles requests missing either nonempty stage, while a manifest-only pass can still skip an existing manifest.

The translator stages both FXC outputs before publishing either. When the manifest bindings change, it withdraws the old manifest before publishing bytecode and writes the new manifest last. A successful compile clears an earlier .fail report. Restart an already-running runtime if it previously read the manifest before bytecode was available.

This covers the one-shot path on main. The pending-candidate selection in #1749 touches the same completion rule and will need the compiled-mode check if the changes are combined.

Verification

  • python3 -B tests/startup_translator_check.py reproduced the skip on the base and passed with the patch. It covers manifest-only skips, unsuccessful pixel compilation, retry, complete-cache skips, an empty bytecode file, and an interrupted manifest publication.
  • Ran all 74 scripts in the Linux Python CI job at the rebased head. All scripts exited successfully, with individual capability skips where applicable.
  • A separate CLI run loaded source-built gfx1013 requests and ran an external synthetic FXC process. It generated the HLSL, resumed compilation, and skipped the completed request on a third pass.

Native Windows FXC and D3D12 execution were outside this run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593120506 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2008). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T22:59:34Z. --- ## Change An explicit manifest-only pass (`X2W_FXC=`) produces a manifest and HLSL without compiled shader stages. A later `--pending` run with FXC enabled now compiles requests missing either nonempty stage, while a manifest-only pass can still skip an existing manifest. The translator stages both FXC outputs before publishing either. When the manifest bindings change, it withdraws the old manifest before publishing bytecode and writes the new manifest last. A successful compile clears an earlier `.fail` report. Restart an already-running runtime if it previously read the manifest before bytecode was available. This covers the one-shot path on `main`. The pending-candidate selection in #1749 touches the same completion rule and will need the compiled-mode check if the changes are combined. ## Verification - `python3 -B tests/startup_translator_check.py` reproduced the skip on the base and passed with the patch. It covers manifest-only skips, unsuccessful pixel compilation, retry, complete-cache skips, an empty bytecode file, and an interrupted manifest publication. - Ran all 74 scripts in the Linux Python CI job at the rebased head. All scripts exited successfully, with individual capability skips where applicable. - A separate CLI run loaded source-built gfx1013 requests and ran an external synthetic FXC process. It generated the HLSL, resumed compilation, and skipped the completed request on a third pass. Native Windows FXC and D3D12 execution were outside this run.
upstream-sync closed this pull request 2026-11-25 00:04:53 +00:00
ChazY11 commented 2026-11-25 01:01:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:11:55Z.


Ran it, broke the publish state machine five ways — all caught

Windows 11 build 26300.9974, device-free:

out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py            # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_capture_check.py      # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py     # exit 0
mutation result
has_bytecode accepts an empty file (getsize > 0 dropped) caught
the old .fail is not cleared after a successful compile caught
the old manifest is not withdrawn when the bindings change caught
the bytecode publish loop is emptied (manifest and bytecode no longer paired) caught
the completion rule goes back to "manifest exists" only caught

The fourth is the one I expected to slip, because emptying the loop still leaves a valid manifest and a successful return — and it is caught. That
means the fixture drives a real re-compile path rather than only the --pending selection.

The ordering is the part worth defending

Three separate claims are encoded in the new shape, and each failed on its own above:

  1. stage before publishing either, so a partly written pair is never visible;
  2. withdraw the manifest first when bindings change, so a reader cannot pair an old manifest with new bytecode;
  3. write the new manifest last, through a temp file and os.replace, so a crash leaves the old manifest rather than a truncated one.

That is one invariant — "a manifest on disk always describes bytecode on disk" — split across three call sites, and it would be reasonable to say so
in the comment, because a future edit that moves any one of the three breaks the invariant without breaking any single test.

A note on has_bytecode

Treating a zero-byte .cso as missing is right: an interrupted FXC leaves exactly that, and the old os.path.exists would have skipped the request
forever. The except OSError: return False is also right for a file removed between the check and the size read.

Merge with current main

Your branch predates #1992, so a plain diff shows its six VEC_U entries as deletions. The actual merge is clean and both suites pass:

git checkout -B merge-2008 origin/main && git merge review-2008     # no conflicts
out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py         # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_int_med3_check.py  # exit 0
# v_min3_i32 still present after the merge

Scope, and the caveat you already wrote

I did not exercise a real FXC run: no fxc.exe on this machine, so what is verified is the file-state machine, not a compiled pair. Your own note that
#1749's pending-candidate selection touches the same completion rule is the right thing to flag — combining the two would need the compiled-mode
check on that path as well, and the check I ran would not tell you.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147126996 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2008#issuecomment-7147126996). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T23:11:55Z. --- ## Ran it, broke the publish state machine five ways — all caught Windows 11 build 26300.9974, device-free: ```powershell out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py # exit 0 out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_capture_check.py # exit 0 out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py # exit 0 ``` | mutation | result | |---|---| | `has_bytecode` accepts an empty file (`getsize > 0` dropped) | **caught** | | the old `.fail` is not cleared after a successful compile | **caught** | | the old manifest is not withdrawn when the bindings change | **caught** | | the bytecode publish loop is emptied (manifest and bytecode no longer paired) | **caught** | | the completion rule goes back to "manifest exists" only | **caught** | The fourth is the one I expected to slip, because emptying the loop still leaves a valid manifest and a successful return — and it is caught. That means the fixture drives a real re-compile path rather than only the `--pending` selection. ## The ordering is the part worth defending Three separate claims are encoded in the new shape, and each failed on its own above: 1. **stage before publishing either**, so a partly written pair is never visible; 2. **withdraw the manifest first when bindings change**, so a reader cannot pair an old manifest with new bytecode; 3. **write the new manifest last**, through a temp file and `os.replace`, so a crash leaves the old manifest rather than a truncated one. That is one invariant — "a manifest on disk always describes bytecode on disk" — split across three call sites, and it would be reasonable to say so in the comment, because a future edit that moves any one of the three breaks the invariant without breaking any single test. ## A note on `has_bytecode` Treating a zero-byte `.cso` as missing is right: an interrupted FXC leaves exactly that, and the old `os.path.exists` would have skipped the request forever. The `except OSError: return False` is also right for a file removed between the check and the size read. ## Merge with current `main` Your branch predates #1992, so a plain diff shows its six `VEC_U` entries as deletions. The actual merge is clean and both suites pass: ```powershell git checkout -B merge-2008 origin/main && git merge review-2008 # no conflicts out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py # exit 0 out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_int_med3_check.py # exit 0 # v_min3_i32 still present after the merge ``` ## Scope, and the caveat you already wrote I did not exercise a real FXC run: no `fxc.exe` on this machine, so what is verified is the file-state machine, not a compiled pair. Your own note that #1749's pending-candidate selection touches the same completion rule is the right thing to flag — combining the two would need the compiled-mode check on that path as well, and the check I ran would not tell you. ## Notes - AI-assisted review.
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!2001
No description provided.