Skip to content

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

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
avt0m4t48:fix/startup-resume-shader-compilation
Nov 24, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
avt0m4t48:fix/startup-resume-shader-compilation

Conversation

@avt0m4t48

Copy link
Copy Markdown
Contributor

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.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@R0Y00
R0Y00 merged commit 8ec2553 into R0Y00:main Nov 24, 2026
5 checks passed
cursor Bot pushed a commit to SimSalabimse/Xbox2Windows that referenced this pull request Nov 25, 2026
Cold -Render runs stay black when pipelines write req_* requests but
never get manifests (pipelines translated 0 / missing N). Add
gfx2hlsl.py --watch and run.ps1 -Translate so translations publish
while the title runs; keep R0Y00#2008 bytecode resume and -TraceCalls.

Rebases reviewed R0Y00#1749 onto current main. Refs R0Y00#870.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants