tooling: add a translator corpus hash check and an IR dump option #3793

Manually merged
github merged 3 commits from github-bot/gh-3791 into gh-pr/3791/base 2026-12-02 05:23:56 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-12-01 22:54 UTC · original
Leyukaka:quality/translator-corpus-hash → main · +364 −38 · 7 files · 3 commits · merged 2026-12-02 05:18 UTC

Problem

There is no single check that says whether a change to the native translator alters its output. Refactors, build-flag changes and cache changes each have to argue "no output change" from individual fixtures.

Change

  • tests/translator_corpus_hash.py runs compile_dxil over a source-built corpus (graphics pairs, RTV variants, compute requests, raw mesh shaders) and writes a sorted TSV: one row per request with its status and either a SHA-256 fingerprint of the published DXIL or the refusal reason. Running the same script and DXC directory against two builds and diffing the TSVs compares their output.
  • compile_dxil --dump-ir writes the exact text handed to the compiler beside each stage as OUTPUT.cso.ir. The corpus script accepts --ir to fingerprint that text instead.
  • Two CTests, native_translator_corpus_dxil and native_translator_corpus_ir, check known compilations and refusals and compare two cold snapshots byte for byte. The IR test also compares DXIL from runs with and without the dump option.
  • The corpus reuses the existing synthetic fixtures; the refusal, watch and mesh checks only expose their request builders as helpers. No lowering code changes.
  • docs/experiments/translator-corpus.md has the base-to-head procedure.

Possible follow-up: a translator-corpus job in windows.yml that builds compile_dxil for the PR head and its merge base and requires identical TSVs.

Validation

Windows, MSVC, dev preset, at 2568a0d59: 8/8 tests passed.

cmake --build --preset dev --target compile_dxil
ctest --preset dev --no-tests=error -R '^(native_translator_corpus_(dxil|ir)|native_compile_dxil_(refusals|rekey|watch)|native_direct_mesh|native_rtv_variant_controls|startup_compute_translate_requests)$' --output-on-failure

Comparing two builds:

$sdk = (Get-Content out/build/dev/x2w-dxc-dir.txt -Raw).Trim()
python -B tests/translator_corpus_hash.py $baseCompiler $sdk --out out/translator-base.tsv
python -B tests/translator_corpus_hash.py $headCompiler $sdk --out out/translator-head.tsv
git diff --no-index --exit-code -- out/translator-base.tsv out/translator-head.tsv

Fixtures are generated from the synthetic instruction words already in the repository's tests.

**@⁠Leyukaka** on GitHub · 2026-12-01 22:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3791) `Leyukaka:quality/translator-corpus-hash` → `main` · +364 −38 · 7 files · 3 commits · merged 2026-12-02 05:18 UTC ## Problem There is no single check that says whether a change to the native translator alters its output. Refactors, build-flag changes and cache changes each have to argue "no output change" from individual fixtures. ## Change - `tests/translator_corpus_hash.py` runs `compile_dxil` over a source-built corpus (graphics pairs, RTV variants, compute requests, raw mesh shaders) and writes a sorted TSV: one row per request with its status and either a SHA-256 fingerprint of the published DXIL or the refusal reason. Running the same script and DXC directory against two builds and diffing the TSVs compares their output. - `compile_dxil --dump-ir` writes the exact text handed to the compiler beside each stage as `OUTPUT.cso.ir`. The corpus script accepts `--ir` to fingerprint that text instead. - Two CTests, `native_translator_corpus_dxil` and `native_translator_corpus_ir`, check known compilations and refusals and compare two cold snapshots byte for byte. The IR test also compares DXIL from runs with and without the dump option. - The corpus reuses the existing synthetic fixtures; the refusal, watch and mesh checks only expose their request builders as helpers. No lowering code changes. - `docs/experiments/translator-corpus.md` has the base-to-head procedure. Possible follow-up: a `translator-corpus` job in `windows.yml` that builds `compile_dxil` for the PR head and its merge base and requires identical TSVs. ## Validation Windows, MSVC, `dev` preset, at `2568a0d59`: 8/8 tests passed. ```powershell cmake --build --preset dev --target compile_dxil ctest --preset dev --no-tests=error -R '^(native_translator_corpus_(dxil|ir)|native_compile_dxil_(refusals|rekey|watch)|native_direct_mesh|native_rtv_variant_controls|startup_compute_translate_requests)$' --output-on-failure ``` Comparing two builds: ```powershell $sdk = (Get-Content out/build/dev/x2w-dxc-dir.txt -Raw).Trim() python -B tests/translator_corpus_hash.py $baseCompiler $sdk --out out/translator-base.tsv python -B tests/translator_corpus_hash.py $headCompiler $sdk --out out/translator-head.tsv git diff --no-index --exit-code -- out/translator-base.tsv out/translator-head.tsv ``` Fixtures are generated from the synthetic instruction words already in the repository's tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 22:55:27 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 01:56 UTC · original

The reviewed head passed Windows and Linux CI, but GitHub reports a merge conflict against current main. Please rebase compile_dxil.cpp while preserving #3796's MSVC warning handling, and rerun the batch, refusal and IR-dump tests on the rebased head.

**@⁠R0Y00** on GitHub · 2026-12-02 01:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3791#issuecomment-7332272400) The reviewed head passed Windows and Linux CI, but GitHub reports a merge conflict against current main. Please rebase `compile_dxil.cpp` while preserving #3796's MSVC warning handling, and rerun the batch, refusal and IR-dump tests on the rebased head.
github-bot force-pushed github-bot/gh-3791 from 2568a0d59f to 13625d24c5 2026-12-02 04:17:25 +00:00 Compare
Author
Owner

@⁠Leyukaka on GitHub · 2026-12-02 04:13 UTC · original

Rebased onto main (0dd65da11) after #3796 merged. The only conflict was in tools/startup/compile_dxil.cpp, where the IR dump option now sits after the #pragma warning(suppress: 4996) that #3796 added. The CTest selection from the description passes again with MSVC on the new head.

**@⁠Leyukaka** on GitHub · 2026-12-02 04:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3791#issuecomment-7334690720) Rebased onto `main` (0dd65da11) after #3796 merged. The only conflict was in `tools/startup/compile_dxil.cpp`, where the IR dump option now sits after the `#pragma warning(suppress: 4996)` that #3796 added. The CTest selection from the description passes again with MSVC on the new head.
github-bot changed target branch from main to gh-pr/3791/base 2026-12-02 05:23:54 +00:00
github manually merged commit 13625d24c5 into gh-pr/3791/base 2026-12-02 05:23:56 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 05:17 UTC · original · approved these changes

Thanks for the rebase. I confirmed the MSVC warning suppression still surrounds the legacy environment lookup and the explicit dump path is reserved alongside the output paths. On Windows Debug at 13625d24, the eight tests selected by ctest --preset dev --no-tests=error -j 2 -R '^(native_translator_corpus_(dxil|ir)|native_compile_dxil_(refusals|rekey|watch)|native_direct_mesh|native_rtv_variant_controls|startup_compute_translate_requests)$' --output-on-failure passed.

**@⁠R0Y00** on GitHub · 2026-12-02 05:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3791#pullrequestreview-6145172096) · **approved these changes** Thanks for the rebase. I confirmed the MSVC warning suppression still surrounds the legacy environment lookup and the explicit dump path is reserved alongside the output paths. On Windows Debug at `13625d24`, the eight tests selected by `ctest --preset dev --no-tests=error -j 2 -R '^(native_translator_corpus_(dxil|ir)|native_compile_dxil_(refusals|rekey|watch)|native_direct_mesh|native_rtv_variant_controls|startup_compute_translate_requests)$' --output-on-failure` passed.
This discussion has been locked. Commenting is limited to contributors.
No description provided.