Direct DXIL: audit metadata and legalization against DXC and LLVM references #2531
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-25T22:24:36Z.
Current status
At
9ebc4a21on PR #2553, five sampled translations produced manifests that passed artifact verification. Shader validation was disabled for this sample. The workspace run reported 1,461 passed, 0 failed and 47 ignored. Paired 60-second RTX 4080 SUPER smokes completed without crashes or device removals. The minimal HLSL/DXC semantic comparison and AMD run remain pending for this sample. No metadata or legalization discrepancy was established. Revision-specific audit reportSummary
XCL directly emits DXIL in
crates/xcl/src/gpu/dxil/. The current implementation is primarily checked through XCL unit tests,dxil.dllvalidation and hardware execution.Add a structured audit comparing XCL’s emitted modules with minimal equivalent shaders produced by DXC, using LLVM’s DirectX backend as an independent architectural reference. The goal is not to replace XCL’s emitter or introduce LLVM as a dependency. It is to identify metadata, legalization and container inconsistencies that can cause validator-version differences, driver rejection or unnecessary driver compilation work.
Part of #1269.
Motivation
A module can be valid LLVM-derived bitcode while still violating DXIL-specific requirements. It can also pass one validator version yet expose inconsistent metadata or feature flags to another validator or GPU driver.
Recent work has encountered areas where exact DXIL declarations matter, including:
DXC is the practical Microsoft reference. LLVM’s documented DirectX backend provides a useful independent model of the lowering stages and invariants:
https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst
https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py
https://llvm.org/docs/DirectX/DXILArchitecture.html
Proposed scope
Audit these XCL areas:
crates/xcl/src/gpu/dxil/ops.rsdx.opopcode, overload and argument signaturescrates/xcl/src/gpu/dxil/module.rscrates/xcl/src/gpu/dxil/shader.rscrates/xcl/src/gpu/dxil/kernel.rscrates/xcl/src/gpu/dxil/compact.rscontainer/PSV/signature construction used by the direct emitter
Proposed method
For each representative shader family:
dxil.dllversions.Initial shader families:
Test infrastructure
Add a semantic inspection helper that reports stable properties such as:
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-25T22:26:31Z.
Notes for AI-assisted contributors
Please treat this issue as an audit and coordination tracker, not as a proposal to replace XCL’s direct-DXIL emitter.
Reference priority
Use these sources in this order:
hctdb.py)dxil.dllvalidator behaviorLLVM documentation is useful for comparing lowering stages and invariants, but it is not more authoritative than Microsoft’s specification, DXC or the validator.
Candidate XCL areas
crates/xcl/src/gpu/dxil/ops.rscrates/xcl/src/gpu/dxil/module.rscrates/xcl/src/gpu/dxil/shader.rscrates/xcl/src/gpu/dxil/kernel.rscrates/xcl/src/gpu/dxil/compact.rsRecommended first contribution
Start with a small, read-only semantic inspection helper and one minimal compute-shader fixture covering:
dx.opoperations and overloads;Avoid byte-for-byte DXIL comparisons. Declaration order, value numbering and instruction ordering may change without changing semantics.
Process
Before implementing a fix:
dxil.dllversion.Evidence template
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-27T11:21:23Z.
Status: Hypothesis requiring validation
XCL commit:
9ebc4a21e5442515a8fc6546d903928181dcd1f7Source file and function:
crates/xcl/src/shaders.rs:write_direct_dumpcrates/xcl/src/gpu/recomp/pso.rs:dump_directand translated-cache identity checkscrates/xcl/src/gpu/recomp/dxc.rs:compile_here,compile_here_in, andstore_symbol_bundleShader stage and model: Bounded direct sample contained 4 pixel shaders and 1 vertex shader. An exact shader-model/metadata comparison against DXC remains pending.
Minimal HLSL: Not produced yet. This update is evidence-enabling infrastructure, not a completed semantic comparison with a minimal DXC reference.
DXC version:
1.9.2609.5dxil.dll version:
1.9.2609.5XCL output:
scripts/verify_shader_dump.py; no individual shader hashes or private artifacts are posted.XCL_SHADER_DEBUG_DIRnow preserves the exact stripped DXIL submitted by the HLSL path together with the full PDB returned by that same compilation, generated HLSL, a manifest, and a DXIL-to-symbol-bundle index.DXC reference:
Validator result:
validation_requested: false, so it is not validator evidence.1.9.2609.5.AMD result:
Not run on AMD hardware.
NVIDIA result:
26100.9711; RTX 4080 SUPER 16 GiB; driver617.14.623d02e465a17497a757a4ce867f482b0a6c8f3b: exit0x0, 1,077 frames/PresentX calls, 0 device removals, 0 crashes.9ebc4a21e5442515a8fc6546d903928181dcd1f7: exit0x0, 1,084 frames/PresentX calls, 0 device removals, 0 crashes.Correctness risk:
Before #2553, a saved direct-DXIL artifact or later GPU fault could not be reliably tied to the exact guest program and artifact generation that produced it. That weakens discrepancy reports and can misattribute stale or partial files. No metadata/legalization discrepancy has yet been verified by this evidence.
Driver-compilation impact:
Not isolated by this evidence. The paired warm-cache smokes were successful and similar, but one run per revision is not a performance benchmark. Symbol mode is diagnostic-only and intentionally compiles whole programs to keep DXIL/PDB identity exact.
Reproduction commands:
Related issues: #1269
Related PRs: #2553