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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Compiled Direct3D shaders as [`naga`] modules, so they can be validated, inspected and written as WGSL, SPIR-V or
//! whatever else a naga backend writes.
//!
//! This is the crate every bytecode reader of the iridia workspace lifts into. A [`Program`] is a `naga::Module` with
//! what a module cannot say: an [`Interface`] (inputs and outputs by semantic name with their D3D register and lanes
//! kept in provenance, constant buffers with explicit layouts, textures, samplers and buffers), the clip-space and
//! texture-origin [`Conventions`] it was written for, which of Direct3D's numeric behaviours its body spells out
//! ([`D3dModes`]) and where it came from ([`Provenance`]). The readers are separate crates:
//! `iridia-dxbc` (Shader Model 4 and 5), `iridia-dxil` (Shader Model 6), `iridia-d3d9` (raw Shader Model 2 and 3
//! tokens) and `iridia-mojo` (the GLSL MojoShader writes from Shader Model 2 and 3).
//!
//! # Example
//!
//! Lift a compiled pixel shader, check it and write WGSL (`iridia-dxbc` is a development dependency of this crate; a
//! program of your own depends on it directly):
//!
//! ```
//! let container = include_bytes!("../../iridia-dxbc/tests/fixtures/modes.dxbc");
//! let program = iridia_dxbc::lift(container)?;
//!
//! assert_eq!(program.stage, iridia::Stage::Pixel);
//! assert_eq!(program.provenance.target, "ps_5_0");
//! // the constant buffer `C` of the HLSL source, named by the container's reflection
//! assert_eq!(program.interface.resources[0].provenance.name, "C");
//!
//! program.validate().expect("a lifted program validates");
//! let wgsl = iridia::emit::wgsl(&program)?;
//! assert!(wgsl.contains("@fragment"));
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! # What is here
//!
//! - [`Program`], its [`validate`](Program::validate) (naga's validation, then the interface against the entry point and
//! the resources against the module's globals) and [`text`](Program::text) (a stable text form, for diffs);
//! - [`emit`]: WGSL writers, and [`emit::wgsl_for`], WGSL as one pipeline binds it;
//! - [`build::Builder`], the typed builder over naga's IR the readers lift with, and [`build::structure`], which turns a
//! control flow graph into structured control flow;
//! - [`d3d`]: Direct3D's enum numbers and packing rules mapped into the [`iridia_interface`] vocabulary, shared by the
//! DXBC and DXIL readers;
//! - [`Refusal`]: what every reader returns for bytecode it cannot lift, naming where and why;
//! - [`gate`]: the version check a reader's tests use so that a changed output comes with a bumped version number;
//! - analyses of a lifted program, none of which runs it: [`flow`] (what each output lane is made of), [`matrix`] (how
//! a constant buffer holds a matrix), [`output_stores`] and [`output_uses`] (what the entry point stores into its
//! outputs and what a discard or blend shows a lane is used for), and [`Program::constant_reads`] (which constant
//! words it reads);
//! - [`rt`]: the calls a ray tracing program makes in place of the pipeline's operations.
//!
//! Running a program on the CPU is the `iridia-exec` crate.
//!
//! The vocabulary types are those of [`iridia_interface`], re-exported here.
// Run the examples in the README as doc tests.
;
// ... and those of the repository's README.
;
pub use ;
pub use BoundSizes;
pub use ;
pub use ;
pub use ;
pub use ;