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

Manually merged
github merged 1 commit from gh-pr/2008/head into gh-pr/2008/base 2026-11-26 23:49:22 +00:00
Owner

@⁠avt0m4t48 on GitHub · 2026-11-24 22:59 UTC · original
avt0m4t48:fix/startup-resume-shader-compilation → main · +143 −19 · 4 files · 1 commits · merged 2026-11-24 23:26 UTC

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.

**@⁠avt0m4t48** on GitHub · 2026-11-24 22:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2008) `avt0m4t48:fix/startup-resume-shader-compilation` → `main` · +143 −19 · 4 files · 1 commits · merged 2026-11-24 23:26 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:49:20 +00:00
github manually merged commit b87a99a3f1 into gh-pr/2008/base 2026-11-26 23:49:22 +00:00
Author
Owner

@⁠ChazY11 on GitHub · 2026-11-24 23:11 UTC · original

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.
**@⁠ChazY11** on GitHub · 2026-11-24 23:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2008#issuecomment-7147126996) ## 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.