Repository navigation
Description
Summary
XCL directly emits DXIL in crates/xcl/src/gpu/dxil/. The current implementation is primarily checked through XCL unit tests, dxil.dll validation 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:
- shader feature flags matching actual operation use;
- compute initialization and entry-point metadata;
- wave32/wave64 compatibility;
- resource-handle properties;
- validator-version differences.
DXC is the practical Microsoft reference. LLVM’s documented DirectX backend provides a useful independent model of the lowering stages and invariants:
- Microsoft DXIL specification:
https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst - DXC operation database:
https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py - LLVM DXIL architecture:
https://llvm.org/docs/DirectX/DXILArchitecture.html
Proposed scope
Audit these XCL areas:
-
crates/xcl/src/gpu/dxil/ops.rsdx.opopcode, overload and argument signatures- shader-model and stage restrictions
-
crates/xcl/src/gpu/dxil/module.rs- target triple and data layout
- function attributes
- named metadata
- module and validator version declarations
-
crates/xcl/src/gpu/dxil/shader.rs- entry-point metadata
- shader feature flags
- stage-specific properties
-
crates/xcl/src/gpu/dxil/kernel.rs- compute thread-group and wave information
- resource and initialization metadata
-
crates/xcl/src/gpu/dxil/compact.rs- whether compaction preserves all referenced metadata and declarations
-
container/PSV/signature construction used by the direct emitter
- agreement between entry signatures, PSV and declared resources
Proposed method
For each representative shader family:
- Write the smallest HLSL shader exercising one behavior.
- Compile it with a pinned DXC version.
- Dump the resulting DXIL and container metadata.
- Produce the equivalent shader through XCL’s direct emitter.
- Compare semantic properties rather than allocation names or instruction order.
- Validate both outputs with the supported
dxil.dllversions. - Run the XCL output on AMD and NVIDIA where hardware behavior is relevant.
Initial shader families:
- empty compute shader and thread-group metadata;
- raw, structured and typed buffer loads/stores;
- static and dynamic resource handles;
- descriptor-heap resource access;
- wave operations under wave32 and wave64;
- derivatives and helper-lane operations;
- vertex/pixel signatures and interpolation modes;
- mesh shader output and topology metadata;
- operations requiring shader feature flags.
Test infrastructure
Add a semantic inspection helper that reports stable properties such as:
shader model and stage
validator/module versions
declared feature flags
dx.op names, opcodes and overloads
resource bindings and properties
entry-point properties
thread-group and wave-size metadata
input/output signatures
PSV resource and signature counts
Activity
mokkamokacaffe commentedon Nov 25, 2026
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
mokkamokacaffe commentedon Nov 27, 2026
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