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

Manually merged
github merged 2 commits from gh-pr/1662/head into gh-pr/1662/base 2026-11-26 23:24:19 +00:00
Owner

@⁠RenzoWit35 on GitHub · 2026-11-24 16:40 UTC · original
RenzoWit35:tooling/gfx2hlsl-missing-fxc → main · +151 −6 · 3 files · 2 commits · merged 2026-11-24 17:00 UTC

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 c864f138, 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.

**@⁠RenzoWit35** on GitHub · 2026-11-24 16:40 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1662) `RenzoWit35:tooling/gfx2hlsl-missing-fxc` → `main` · +151 −6 · 3 files · 2 commits · merged 2026-11-24 17:00 UTC ## 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 c864f138, 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.
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.
shutil.which needs the execute bit outside Windows, so the PATH case of
startup_translator_check failed in the Linux Python job.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:24:18 +00:00
github manually merged commit 50cd06c8af into gh-pr/1662/base 2026-11-26 23:24:19 +00:00
Author
Owner

@⁠RenzoWit35 on GitHub · 2026-11-24 16:52 UTC · original

Thanks for the review. The P2 finding (no execute bit on the PATH stub, so shutil.which returns nothing outside Windows) is fixed in 50cd06c8, 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.

**@⁠RenzoWit35** on GitHub · 2026-11-24 16:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1662#issuecomment-7138341054) Thanks for the review. The P2 finding (no execute bit on the `PATH` stub, so `shutil.which` returns nothing outside Windows) is fixed in 50cd06c8, 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 16:47 UTC · original · reviewed

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.

**@⁠tedin7** on GitHub · 2026-11-24 16:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1662#pullrequestreview-6043547885) · **reviewed** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.