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

Merged
RenzoWit35 merged 2 commits from upstream-pr/1662 into main 2026-11-24 17:00:38 +00:00
RenzoWit35 commented 2026-11-24 16:40:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T16:40:56Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6586746278 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1662). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-24T16:40:56Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 17:01:55 +00:00
tedin7 commented 2026-11-24 17:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:47:20Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043547885 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1662#pullrequestreview-6043547885). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:47:20Z. **Review:** COMMENTED --- 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.
RenzoWit35 commented 2026-11-24 17:02:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T16:52:31Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7138341054 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1662#issuecomment-7138341054). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-24T16:52:31Z. --- 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.
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!1655
No description provided.