1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Lift Direct3D Shader Model 6 programs (DXIL) to an [`iridia::Program`], every stage a DXIL container holds but
//! amplification, and read their reflection, signatures and a library's subobjects into the `iridia_interface`
//! vocabulary.
//!
//! The container, the LLVM bitcode of its `DXIL` part and the reflection and runtime-data records are read by
//! [`dxil_reader`]; this crate maps them. A DXIL function is LLVM's: values in single static assignment form over basic
//! blocks. The lifter turns them into structured control flow (an irreducible graph is refused by name), reads the
//! `dx.op` intrinsics (inputs and outputs, math, bit operations, constant buffers, textures, derivatives, wave, mesh,
//! ray query and ray tracing operations) and writes Direct3D's results where they differ from naga's out as
//! operations ([`iridia::D3dModes`]). The conventions are the same as `iridia-dxbc`'s, so a program lifted from either
//! has the same shape.
//!
//! [`interface`] reads a container's interface alone, without lifting its program, and [`subobjects`] maps the
//! subobjects of a ray tracing library.
//!
//! # Example
//!
//! ```
//! let container = include_bytes!("../tests/fixtures/flow.dxil"); // `dxc -T ps_6_0` output
//! let program = iridia_dxil::lift(container)?;
//!
//! assert_eq!(program.stage, iridia::Stage::Pixel);
//! assert_eq!(program.provenance.target, "ps_6_0");
//! // two colour targets, a float4 and a uint4, as the HLSL declares
//! let targets: Vec<_> = program.interface.outputs.iter().map(|v| (v.system, v.value.width)).collect();
//! assert_eq!(
//! targets,
//! [(Some(iridia::SystemValue::Target(0)), 4), (Some(iridia::SystemValue::Target(1)), 4)]
//! );
//!
//! let wgsl = iridia::emit::wgsl(&program)?;
//! assert!(wgsl.contains("@fragment"));
//!
//! // a refusal names the bit it is at and why
//! let refusal = iridia_dxil::lift(&container[..64]).unwrap_err();
//! assert_eq!(refusal.bytecode, "DXIL");
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// Run the examples in the README as doc tests.
;
pub use ;
pub use ;
/// A DXIL program or container refused or unreadable: the bit it is at (in the bitcode, or eight times a byte of the
/// container) and why ([`iridia::Refusal`]).
pub type Error = Refusal;
/// The result of every function in this crate: `Ok` or a refusal that names the bit of the DXIL module.
pub type Result<T> = Result;
pub
/// What the reader could not read, as a refusal of the program at the same bit.
pub