shader: add a GDK shader corpus harness #3290

Manually merged
github merged 2 commits from github-bot/gh-3288 into main 2026-11-28 08:31:57 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-28 05:21 UTC · original
lambirou:gdk/shader-corpus → main · +496 −0 · 11 files · 2 commits · merged 2026-11-28 08:26 UTC

The GDK knowledge plan needs a reproducible corpus for the Xbox HLSL compiler and the existing DXIL retargeter. This adds six original HLSL cases and a harness that compiles them with the GXDK Scarlett dxc, retargets each container, records the source and container SHA-256 values, and verifies the result without the SDK.

Measured on 28 November 2026 with dxcompiler_xs 1.8, build 2610.2608.12522.14643:

  • wave64_ballot_ps (ps_6_0): 4,316 -> 4,152 bytes.
  • root_constants_vs (vs_6_0): 3,972 -> 3,804 bytes.
  • image_sample_c_lz_ps (ps_6_0): 3,912 -> 3,756 bytes.
  • packed_types_cs (cs_6_0): 3,224 -> 3,068 bytes.
  • derivatives_ps (ps_6_0): 3,204 -> 3,048 bytes.
  • mesh_ngg_ms (ms_6_5): 3,104 -> 2,944 bytes.

All six compiled, retargeted from dxil-ms-xb2 to dxil-ms-dx and verified. The retarget removed xbox.compiler.options in every case. The cases cover wave ballot and lane access, a root signature with one constant buffer, a comparison sample at level zero, packed 16-bit fields in compute, implicit derivatives and fwidth, and a fixed three-vertex mesh shader.

Commands:

python -B tests/gdk_shader_corpus_check.py
python -B tools/gdk_shader_corpus.py build --gdk-root D:\gdk-ref\261000\gxdk\Microsoft GDK\261000 --corpus tests\gdk\shaders --out D:\gdk-oracle\knowledge\shaders\corpus
python -B tools/gdk_shader_corpus.py verify --manifest D:\gdk-oracle\knowledge\shaders\corpus\corpus.json

The check runs on Linux without dxc and covers case loading, hashing, manifest verification, triple checks and the missing-dxc skip. build returns 77 when dxc is absent.

A retargeted container is not a GPU execution result. The corpus does not prove that a desktop driver accepts the mesh or pixel pipeline, and it does not cover game shaders. The HLSL sources are versioned; the .cso files and the corpus manifest stay in D:\gdk-oracle.

**@⁠lambirou** on GitHub · 2026-11-28 05:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3288) `lambirou:gdk/shader-corpus` → `main` · +496 −0 · 11 files · 2 commits · merged 2026-11-28 08:26 UTC The GDK knowledge plan needs a reproducible corpus for the Xbox HLSL compiler and the existing DXIL retargeter. This adds six original HLSL cases and a harness that compiles them with the GXDK Scarlett dxc, retargets each container, records the source and container SHA-256 values, and verifies the result without the SDK. Measured on 28 November 2026 with dxcompiler_xs 1.8, build 2610.2608.12522.14643: - wave64_ballot_ps (ps_6_0): 4,316 -> 4,152 bytes. - root_constants_vs (vs_6_0): 3,972 -> 3,804 bytes. - image_sample_c_lz_ps (ps_6_0): 3,912 -> 3,756 bytes. - packed_types_cs (cs_6_0): 3,224 -> 3,068 bytes. - derivatives_ps (ps_6_0): 3,204 -> 3,048 bytes. - mesh_ngg_ms (ms_6_5): 3,104 -> 2,944 bytes. All six compiled, retargeted from dxil-ms-xb2 to dxil-ms-dx and verified. The retarget removed xbox.compiler.options in every case. The cases cover wave ballot and lane access, a root signature with one constant buffer, a comparison sample at level zero, packed 16-bit fields in compute, implicit derivatives and fwidth, and a fixed three-vertex mesh shader. Commands: python -B tests/gdk_shader_corpus_check.py python -B tools/gdk_shader_corpus.py build --gdk-root D:\gdk-ref\261000\gxdk\Microsoft GDK\261000 --corpus tests\gdk\shaders --out D:\gdk-oracle\knowledge\shaders\corpus python -B tools/gdk_shader_corpus.py verify --manifest D:\gdk-oracle\knowledge\shaders\corpus\corpus.json The check runs on Linux without dxc and covers case loading, hashing, manifest verification, triple checks and the missing-dxc skip. build returns 77 when dxc is absent. A retargeted container is not a GPU execution result. The corpus does not prove that a desktop driver accepts the mesh or pixel pipeline, and it does not cover game shaders. The HLSL sources are versioned; the .cso files and the corpus manifest stay in D:\gdk-oracle.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 05:27:43 +00:00
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-28 06:45 UTC · original

Thanks for the corpus harness. I reviewed f623e4c4 and found two problems in verify that I'd like to see fixed before this merges:

  1. verify doesn't check the sources or the case list. It never compares source_sha256 with the current HLSL and never cross-checks cases.json, so a stale or empty manifest still verifies. python -B tools/gdk_shader_corpus.py verify --manifest empty.json, with {"cases": []} in the file, prints verified 0 cases and exits 0. The valid manifest in check_verify also uses "source_sha256": "0" * 64 without a source file, and it passes (the Linux CI log shows verified 1 cases). Could verify take --corpus, recompute each source hash, require the case names to match cases.json, and fail when there are no cases?

  2. Most verify checks have no negative case. I ran tests/gdk_shader_corpus_check.py against five mutants of verify_command. Each one removes a single check: the size comparison, the original_triple check, the xbox.compiler.options removal check, the recorded-error check, or the desktop record (by looping over ("xbox",) only). All five still pass (rc=0). Because of the last one, the hash of the retargeted container is never tested, even though the check prints "verify: hashes, sizes, triples and missing files passed". One negative case for each would pin them.

I only ran the pure-Python check on Linux (Python 3.13), with each mutant in its own scratch copy. I did not run a GDK build.

This comment was AI-assisted.

**@⁠JohnConnorNPC** on GitHub · 2026-11-28 06:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3288#issuecomment-7235499308) Thanks for the corpus harness. I reviewed `f623e4c4` and found two problems in `verify` that I'd like to see fixed before this merges: 1. **`verify` doesn't check the sources or the case list.** It never compares `source_sha256` with the current HLSL and never cross-checks `cases.json`, so a stale or empty manifest still verifies. `python -B tools/gdk_shader_corpus.py verify --manifest empty.json`, with `{"cases": []}` in the file, prints `verified 0 cases` and exits 0. The valid manifest in `check_verify` also uses `"source_sha256": "0" * 64` without a source file, and it passes (the Linux CI log shows `verified 1 cases`). Could `verify` take `--corpus`, recompute each source hash, require the case names to match `cases.json`, and fail when there are no cases? 2. **Most `verify` checks have no negative case.** I ran `tests/gdk_shader_corpus_check.py` against five mutants of `verify_command`. Each one removes a single check: the size comparison, the `original_triple` check, the `xbox.compiler.options` removal check, the recorded-error check, or the desktop record (by looping over `("xbox",)` only). All five still pass (rc=0). Because of the last one, the hash of the retargeted container is never tested, even though the check prints "verify: hashes, sizes, triples and missing files passed". One negative case for each would pin them. I only ran the pure-Python check on Linux (Python 3.13), with each mutant in its own scratch copy. I did not run a GDK build. This comment was AI-assisted.
github manually merged commit 99e3ef0e25 into main 2026-11-28 08:31:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.