Shaders: identify direct translation artifacts in dump manifests #2553

Open
github-bot wants to merge 3 commits from github-bot/gh-2553 into main AGit
Owner

@⁠mokkamokacaffe on GitHub · 2026-11-25 22:45 UTC · original
mokkamokacaffe:diagnostics/dxil-dump-identity → main · +191 −5 · 3 files · 3 commits · draft

Part of #2541.

What is in it

  • xcl shaders --direct --dump <dir> writes a versioned .manifest.json beside each program's guest.bin and direct.dxil or direct.err.txt. The files share a prefix so a report can be matched to its artifacts.
  • The manifest records the source record hash, FSSM index, program offset, guest-code hash, shader stage, wave settings, memory-window count, validation request, translation wall time, and either the emitted DXIL hash or translator error.
  • Required artifacts are written before their manifest. If guest.bin, direct.dxil, or direct.err.txt cannot be saved, XCL reports the exact path and does not publish a manifest that advertises the missing file.
  • scripts/verify_shader_dump.py verifies saved bundles without the source shader pack or a GPU: it recomputes the guest/DXIL FNV-1a hashes or compares rejected-translation diagnostic bytes exactly.
  • scripts/test_verify_shader_dump.py covers successful and rejected translations, large binary inputs, mismatches, absent files/fields, invalid schemas, malformed JSON, and multi-manifest failure handling.

translation_wall_us measures elapsed time around the translation worker call, including the wait for its result. Driver PSO creation is outside that interval.

Tested

  • Current clean head 76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee:
    • python3 -B -m unittest discover -s scripts -p 'test_*.py': 30 passed, 0 failed.
    • git diff --check: passed.
  • Runtime-write fix b6bd0c0:
    • cargo check -p xcl --tests --target x86_64-pc-windows-msvc: passed in a Linux cross-check environment using a local lib.exe-compatible archive wrapper. This was compile-only.
  • External Windows 11 / RTX 3060 Ti verification of earlier head effef671, merged locally with the contributor's current main:
    • cargo test -p xcl --lib: all tests that ran passed, 0 failed, 26 ignored.
  • The offline checker was independently exercised on Windows 11 with Python 3.14.3 using 12 two-manifest CLI cases, including a 131,073-byte guest file. Both valid outcome types passed; ten mismatch, missing-file/field, schema, and malformed-JSON cases returned failure while still processing the following valid manifest and leaving all inputs unchanged.

The Windows library run and earlier checker report predate the two commits added in response to review and are retained as supporting evidence, not exact-head runtime validation.

Regression run

Pending paired xcl-smoke blocks from current main and this PR's clean head 76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee, with the same title and duration.

Not tested

  • End-to-end dump generation from an actual shader pack on current head, including one successful and one rejected translation.
  • The new unwritable-sibling regression executed natively on Windows; it is included in the Windows-target test build but was not run in this environment.
  • AMD, NVIDIA, or Intel shader execution on current head.
  • Retail-title smoke.

AI use

  • OpenAI Codex implemented the manifest and review-requested artifact-write handling, added the missing-artifact regression, ran the Windows-target compile and script tests, reviewed the external reports, and drafted this description.
  • RavenCurseBurg contributed the offline checker and its tests in commit 38cdb20f, assisted by OpenAI Codex (GPT-6); the commit was cherry-picked with its original authorship preserved.
**@⁠mokkamokacaffe** on GitHub · 2026-11-25 22:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553) `mokkamokacaffe:diagnostics/dxil-dump-identity` → `main` · +191 −5 · 3 files · 3 commits · draft Part of #2541. **What is in it** - `xcl shaders --direct --dump <dir>` writes a versioned `.manifest.json` beside each program's `guest.bin` and `direct.dxil` or `direct.err.txt`. The files share a prefix so a report can be matched to its artifacts. - The manifest records the source record hash, FSSM index, program offset, guest-code hash, shader stage, wave settings, memory-window count, validation request, translation wall time, and either the emitted DXIL hash or translator error. - Required artifacts are written before their manifest. If `guest.bin`, `direct.dxil`, or `direct.err.txt` cannot be saved, XCL reports the exact path and does not publish a manifest that advertises the missing file. - `scripts/verify_shader_dump.py` verifies saved bundles without the source shader pack or a GPU: it recomputes the guest/DXIL FNV-1a hashes or compares rejected-translation diagnostic bytes exactly. - `scripts/test_verify_shader_dump.py` covers successful and rejected translations, large binary inputs, mismatches, absent files/fields, invalid schemas, malformed JSON, and multi-manifest failure handling. `translation_wall_us` measures elapsed time around the translation worker call, including the wait for its result. Driver PSO creation is outside that interval. **Tested** - Current clean head `76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee`: - `python3 -B -m unittest discover -s scripts -p 'test_*.py'`: 30 passed, 0 failed. - `git diff --check`: passed. - Runtime-write fix `b6bd0c0`: - `cargo check -p xcl --tests --target x86_64-pc-windows-msvc`: passed in a Linux cross-check environment using a local `lib.exe`-compatible archive wrapper. This was compile-only. - External Windows 11 / RTX 3060 Ti verification of earlier head `effef671`, merged locally with the contributor's current `main`: - `cargo test -p xcl --lib`: all tests that ran passed, 0 failed, 26 ignored. - The offline checker was independently exercised on Windows 11 with Python 3.14.3 using 12 two-manifest CLI cases, including a 131,073-byte guest file. Both valid outcome types passed; ten mismatch, missing-file/field, schema, and malformed-JSON cases returned failure while still processing the following valid manifest and leaving all inputs unchanged. The Windows library run and earlier checker report predate the two commits added in response to review and are retained as supporting evidence, not exact-head runtime validation. **Regression run** Pending paired `xcl-smoke` blocks from current `main` and this PR's clean head `76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee`, with the same title and duration. **Not tested** - End-to-end dump generation from an actual shader pack on current head, including one successful and one rejected translation. - The new unwritable-sibling regression executed natively on Windows; it is included in the Windows-target test build but was not run in this environment. - AMD, NVIDIA, or Intel shader execution on current head. - Retail-title smoke. **AI use** - OpenAI Codex implemented the manifest and review-requested artifact-write handling, added the missing-artifact regression, ran the Windows-target compile and script tests, reviewed the external reports, and drafted this description. - RavenCurseBurg contributed the offline checker and its tests in commit `38cdb20f`, assisted by OpenAI Codex (GPT-6); the commit was cherry-picked with its original authorship preserved.
Check the guest hash and the result selected by the manifest. Compare exact diagnostic bytes for rejected translations so saved artifacts can be verified without the source pack or a GPU.

Assisted-by: OpenAI Codex (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:38 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 23:06 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-25 23:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7177163924) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 26 ignored. Thanks! — Devin
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-25 23:06 UTC · original · edited 2026-11-26 00:13 UTC

Verified 76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee after the cherry-pick. The offline checker and its tests match the original files from 38cdb20f byte-for-byte. python -B -m unittest discover -s scripts -p "test_*.py" passed 30/30. All 12 two-manifest CLI cases passed again: a valid second manifest was processed after an invalid first one, and none of the saved file snapshots changed. This verifies the adopted offline checker. I did not execute XCL’s Rust dump writer or load a retail pack. Windows 11, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ran the checks.

Earlier verification

I prepared an offline artifact checker and tests on effef6719d431ac360ce9d6f46c55e87b1bd486a for the success/error checks listed in this PR. Run python -B scripts/verify_shader_dump.py FILE.manifest.json on a saved dump. It reads the sibling guest file and the result selected by the manifest, recomputes the FNV-1a hashes, and compares a rejected translation's UTF-8 error bytes exactly. It also accepts multiple manifests and returns a failure status if any comparison fails.

I ran 12 two-manifest CLI cases using synthetic files, including a 131,073-byte binary guest with independently computed hash 9fd6a807c893b7df. Both outcome types passed. The ten mismatch, missing-file/field, schema and malformed-JSON cases returned 1, still processed the following valid manifest and left all files byte-identical. A rejection with an old DXIL file present selected the error file. python -B -m unittest discover -s scripts -p "test_*.py" passed all 30 tests, including five for the checker.

Windows 11 26100.9711, i7-13700, Python 3.14.3. I tested the offline checker only. End-to-end generation with XCL and a shader pack remains unverified here. OpenAI Codex (GPT-6) prepared the checker and ran the tests.

**@⁠RavenCurseBurg** on GitHub · 2026-11-25 23:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7177146260) · edited 2026-11-26 00:13 UTC Verified `76e7793dbb5ec337a0b30aa832d25f2fa2d1e5ee` after the cherry-pick. The offline checker and its tests match the original files from `38cdb20f` byte-for-byte. `python -B -m unittest discover -s scripts -p "test_*.py"` passed 30/30. All 12 two-manifest CLI cases passed again: a valid second manifest was processed after an invalid first one, and none of the saved file snapshots changed. This verifies the adopted offline checker. I did not execute XCL’s Rust dump writer or load a retail pack. Windows 11, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ran the checks. <details> <summary>Earlier verification</summary> I prepared an [offline artifact checker and tests](https://github.com/RavenCurseBurg/xcl/commit/38cdb20f38aac4d600af05272659f3f364dd8f76) on `effef6719d431ac360ce9d6f46c55e87b1bd486a` for the success/error checks listed in this PR. Run `python -B scripts/verify_shader_dump.py FILE.manifest.json` on a saved dump. It reads the sibling guest file and the result selected by the manifest, recomputes the FNV-1a hashes, and compares a rejected translation's UTF-8 error bytes exactly. It also accepts multiple manifests and returns a failure status if any comparison fails. I ran 12 two-manifest CLI cases using synthetic files, including a 131,073-byte binary guest with independently computed hash `9fd6a807c893b7df`. Both outcome types passed. The ten mismatch, missing-file/field, schema and malformed-JSON cases returned 1, still processed the following valid manifest and left all files byte-identical. A rejection with an old DXIL file present selected the error file. `python -B -m unittest discover -s scripts -p "test_*.py"` passed all 30 tests, including five for the checker. Windows 11 26100.9711, i7-13700, Python 3.14.3. I tested the offline checker only. End-to-end generation with XCL and a shader pack remains unverified here. OpenAI Codex (GPT-6) prepared the checker and ran the tests. </details>
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:36 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 01:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7179943203) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
@ -2374,3 +2415,1 @@
match &r {
Ok(dxil) => dump("direct.dxil", dxil),
Err(e) => dump("direct.err.txt", e.as_bytes()),
if let Some(dir) = &dump_dir {
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 23:39 UTC · original

The manifest is written even if the earlier dump("guest.bin", ...) or DXIL/error dump failed; that closure discards each write error. In that case this new record can advertise hashes for artifacts that were not saved, and the run gives no immediate clue which file failed. Could the artifact writes return/report their errors (or record which artifacts were persisted) before emitting the manifest? A small test can make one sibling path unwritable while allowing the manifest write and assert the failure is visible.

**@⁠luckyteagirl** on GitHub · 2026-11-25 23:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#discussion_r4702171080) The manifest is written even if the earlier `dump("guest.bin", ...)` or DXIL/error dump failed; that closure discards each `write` error. In that case this new record can advertise hashes for artifacts that were not saved, and the run gives no immediate clue which file failed. Could the artifact writes return/report their errors (or record which artifacts were persisted) before emitting the manifest? A small test can make one sibling path unwritable while allowing the manifest write and assert the failure is visible.
@ -2374,3 +2415,1 @@
match &r {
Ok(dxil) => dump("direct.dxil", dxil),
Err(e) => dump("direct.err.txt", e.as_bytes()),
if let Some(dir) = &dump_dir {
Author
Owner

@⁠mokkamokacaffe on GitHub · 2026-11-26 00:04 UTC · original

Addressed in b6bd0c0. The required guest.bin and DXIL/error artifact writes now return their errors and complete before the manifest is written. A failed sibling write reports its exact path and prevents publication of the manifest.

I also added direct_dump_does_not_publish_a_manifest_for_a_missing_artifact, which makes sample.guest.bin unwritable and verifies that the error is visible and neither the result artifact nor manifest is created. The Windows MSVC-target test build passes.

**@⁠mokkamokacaffe** on GitHub · 2026-11-26 00:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#discussion_r4702354445) Addressed in `b6bd0c0`. The required `guest.bin` and DXIL/error artifact writes now return their errors and complete before the manifest is written. A failed sibling write reports its exact path and prevents publication of the manifest. I also added `direct_dump_does_not_publish_a_manifest_for_a_missing_artifact`, which makes `sample.guest.bin` unwritable and verifies that the error is visible and neither the result artifact nor manifest is created. The Windows MSVC-target test build passes.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-26 05:13 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of direct_dump_does_not_publish_a_manifest_for_a_missing_artifact: passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#issuecomment-7183292716) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `direct_dump_does_not_publish_a_manifest_for_a_missing_artifact`: passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 06:55 UTC · original · reviewed

Reusing a --dump directory can leave a manifest that still verifies after a rerun fails. The prefix is stable for the same record and program. If the first run writes DXIL and a later run produces a translation error, a failed write to .direct.err.txt returns before the old manifest is replaced. The unchanged guest and old DXIL still match that manifest.

I reproduced the file sequence on Windows by placing a directory at the error artifact path. The sibling write raised PermissionError and the exact-head verifier exited 0 with “guest and translated DXIL match.”

Could the writer invalidate the existing manifest before it starts replacing artifacts, or use separate names for each generation? A regression can seed a valid bundle, force an artifact write failure on the rerun, and check that the old manifest cannot be mistaken for its result.

**@⁠luckyteagirl** on GitHub · 2026-11-26 06:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2553#pullrequestreview-6069735105) · **reviewed** Reusing a `--dump` directory can leave a manifest that still verifies after a rerun fails. The prefix is stable for the same record and program. If the first run writes DXIL and a later run produces a translation error, a failed write to `.direct.err.txt` returns before the old manifest is replaced. The unchanged guest and old DXIL still match that manifest. I reproduced the file sequence on Windows by placing a directory at the error artifact path. The sibling write raised `PermissionError` and the exact-head verifier exited 0 with “guest and translated DXIL match.” Could the writer invalidate the existing manifest before it starts replacing artifacts, or use separate names for each generation? A regression can seed a valid bundle, force an artifact write failure on the rerun, and check that the old manifest cannot be mistaken for its result.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2553/head:github-bot/gh-2553'
git switch 'github-bot/gh-2553'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2553'
git switch 'github-bot/gh-2553'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2553'
git switch 'github-bot/gh-2553'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2553'
git switch 'main'
git merge --squash 'github-bot/gh-2553'
git switch 'main'
git merge --ff-only 'github-bot/gh-2553'
git switch 'main'
git merge 'github-bot/gh-2553'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.