Skip to content

Shaders: identify direct translation artifacts in dump manifests - #2553

Draft
mokkamokacaffe wants to merge 3 commits into
xcl-dev:mainfrom
mokkamokacaffe:diagnostics/dxil-dump-identity
Draft

mokkamokacaffe wants to merge 3 commits into
xcl-dev:mainfrom
mokkamokacaffe:diagnostics/dxil-dump-identity

Conversation

@mokkamokacaffe

@mokkamokacaffe mokkamokacaffe commented Nov 25, 2026 •

Copy link
Copy Markdown

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.

@RavenCurseBurg

RavenCurseBurg commented Nov 25, 2026 •

Copy link
Copy Markdown

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Comment thread crates/xcl/src/shaders.rs Resolved
mokkamokacaffe and others added 2 commits November 26, 2026 00:59
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)
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@SlopTart

Copy link
Copy Markdown

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.

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants