Skip to content

tooling: report a missing fxc instead of publishing a shader manifest without bytecode - #1662

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
RenzoWit35:tooling/gfx2hlsl-missing-fxc
Nov 24, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
RenzoWit35:tooling/gfx2hlsl-missing-fxc

Conversation

@RenzoWit35

Copy link
Copy Markdown
Contributor

Change

tools/startup/gfx2hlsl.py compiled the translated pair only when os.path.exists(FXC), where FXC defaulted to the Windows SDK 10.0.26100.0 path. On a machine with another SDK version the compile was skipped silently and <key>.txt was still published, so the runtime (which loads .vs.cso/.ps.cso) found no bytecode and nothing reported why.

  • New find_fxc(): X2W_FXC if it is a file, else the previous default path, else the newest numeric Windows Kits\10\bin\<version>\x64\fxc.exe, else fxc.exe on PATH.
  • translate_to with check true and no fxc found writes <key>.fail ("fxc.exe not found (X2W_FXC=...): set X2W_FXC ...") and publishes no manifest, returning that message as it does for a compile failure.
  • X2W_FXC set to the empty string, or check=False, still publishes the manifest without bytecode. The DXC variant of tests/startup_mrt_check.py runs --pending that way and compiles with DXC itself.
  • docs/startup-runtime.md: the X2W_SHADER_CACHE row now describes the fxc lookup and the failure.

Verification

On top of c864f13, Windows 11, Python 3.14.5.

  • python -B tests/startup_translator_check.py -> startup translator checks: 0 failed (rc 0).
  • New cases (stub Pipeline, temporary Windows Kits-shaped tree, PATH emptied): missing X2W_FXC and no discovery gives .fail naming X2W_FXC and no .txt; check=False and empty X2W_FXC publish the manifest; discovery picks 10.0.26200.0 over 10.0.22621.0 and 10.0.9.0 (numeric, not string, order); explicit X2W_FXC; missing override falls back; PATH.
  • Fails without the fix: with the fxc is None branch disabled the check reports FAIL missing fxc: result 'ok', files [...ps.hlsl, ...txt, ...vs.hlsl] (rc 1); with the version sort ascending it reports two find_fxc failures (rc 1).
  • Reproduction on main: X2W_FXC=C:\nope\fxc.exe, translate_to returns ok with files .ps.hlsl .txt .vs.hlsl, no .cso, no .fail.
  • With the default path hidden, find_fxc() returns the installed SDK's fxc.exe on this machine.
  • Other checks importing gfx2hlsl: startup_flat_param, image_sample_l, image_sample_c, inline_sampler, sampler_heap, image_3d, image_2d_array, gfx2hlsl_capture, gfx2hlsl_sdwa, uniform_lane all rc 0. tests/docs_links_check.py passes.
  • Not run locally: the D3D12 draw tests that call --pending with a real fxc (startup_stream_* and similar), which need the built consumers.

Evidence and follow-up

Refs #870 (the report there of a cache run with no .cso files on a machine without fxc at the default path). Open PRs #1631, #1526 and #1277 touch gfx2hlsl.py; none of their diffs mentions FXC, translate_to or X2W_FXC. A set but missing X2W_FXC falls back to discovery and only fails when nothing is found; the message shows the configured value. Not measured: a full translation with a real fxc on a machine whose SDK differs from 10.0.26100.0.

AI-assisted.

… without bytecode

gfx2hlsl.translate_to skipped compilation when fxc.exe was not at the
hard-coded SDK 10.0.26100.0 path and still published the manifest, so a
cache run produced no .cso files and no error. find_fxc now tries X2W_FXC,
that path, the newest installed Windows Kits bin version and PATH. When
compilation is requested and none exists, the translation writes <key>.fail
naming X2W_FXC and no manifest. X2W_FXC set to the empty string still
skips compilation, as the DXC variants of startup_mrt_check use it.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer review at head_sha: 4bbfee25be9fa8c8f56349833eecdc2d4ec35ed0

Findings

  • P2 (tests/startup_translator_check.py): check_fxc_discovery creates the stub fxc.exe on PATH with open(os.path.join(on_path, 'fxc.exe'), 'w').close() without setting execute permissions (0o755). On Linux, shutil.which('fxc.exe') requires os.X_OK, so python3 -B tests/startup_translator_check.py fails on Linux with FAIL find_fxc (PATH): got None. Adding os.chmod(..., 0o755) on that stub file fixes Linux execution while remaining safe on Windows.
  • tools/startup/gfx2hlsl.py and docs/startup-runtime.md: no defects found (find_fxc() search order, X2W_FXC='' manifest-only behavior, and <key>.fail reporting when fxc.exe is missing all match the documented contract). Title-neutrality clean.

Verification

  • Linux:
    • python3 -B tests/startup_translator_check.py: failed 1 check (FAIL find_fxc (PATH): got None, exit 1; see P2 above).
    • Local mutation check: temporarily replaced if fxc is None: with if False: in tools/startup/gfx2hlsl.py and ran python3 -B tests/startup_translator_check.py — failed as expected (FAIL missing fxc: result 'ok', files ['0000000000001234.ps.hlsl', '0000000000001234.txt', '0000000000001234.vs.hlsl'], exit 1); restored cleanly (git status --short clean).
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • python3 -B tests/startup_translator_check.py: 0 failed (0.2s, exit 0).
    • Debug (--preset dev): cmake --build --preset dev --target offscreen_check -- -j 6 (22.41s); ctest --preset dev -R '^startup_translator$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (0.27s).
    • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check -- -j 6 (24.66s); ctest --preset release -R '^startup_translator$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (0.25s).

AI-assisted; commands listed were executed locally.

shutil.which needs the execute bit outside Windows, so the PATH case of
startup_translator_check failed in the Linux Python job.
@RenzoWit35

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The P2 finding (no execute bit on the PATH stub, so shutil.which returns nothing outside Windows) is fixed in 50cd06c, which adds os.chmod(..., 0o755) on that stub. The Linux Python job passes on that commit; python -B tests/startup_translator_check.py still reports 0 failed on Windows.

AI-assisted.

@R0Y00
R0Y00 merged commit f2cb67f into R0Y00:main Nov 24, 2026
5 checks passed
RenzoWit35 added a commit to RenzoWit35/Xbox2Windows that referenced this pull request Nov 24, 2026
Since R0Y00#1662 a request that translates is refused when no fxc.exe is
found, so on a host without the Windows SDK the check's valid request got
a .fail file instead of a manifest and the check failed. The check is
about root signature parsing, not compilation: run the tool with the
empty X2W_FXC, which publishes the manifest alone on every host, as the
other startup checks do.
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