iridia_interface/stage.rs
1//! What a program is and where it runs: its encoding and its pipeline stage.
2use serde::Serialize;
3
4/// How a shader program's bytes are encoded. Only the encoding lives here; reading one is the job of the crate that
5/// knows it (`iridia-dxbc`, `iridia-dxil`, `iridia-d3d9`, `iridia-mojo`), and the program's meaning is lifted from it on
6/// demand.
7#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
8#[serde(rename_all = "snake_case")]
9#[non_exhaustive]
10pub enum ShaderFormat {
11 /// A DXBC container holding Shader Model 4 or 5 byte code.
12 Dxbc,
13 /// A DXBC container holding Shader Model 6 (DXIL, LLVM bitcode).
14 Dxil,
15 /// A SPIR-V module.
16 SpirV,
17 /// GLSL source text.
18 Glsl,
19 /// Raw Direct3D 9 shader tokens, including the version token and END (no DXBC container).
20 D3d9,
21}
22/// The pipeline stage a program runs in.
23#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
24#[serde(rename_all = "snake_case")]
25#[non_exhaustive]
26pub enum Stage {
27 /// A vertex program: one invocation per vertex.
28 Vertex,
29 /// A pixel (fragment) program: one invocation per covered pixel.
30 Pixel,
31 /// A compute program: no varyings, system inputs naming the invocation, a thread group size.
32 Compute,
33 /// A hull program: the control-point phase and the patch-constant function of a tessellated patch (see
34 /// [`crate::StageFacts::Hull`]).
35 Hull,
36 /// A domain program: a vertex of a tessellated patch from its domain location (see [`crate::StageFacts::Domain`]).
37 Domain,
38 /// A geometry program.
39 Geometry,
40 /// A mesh program: a thread group that writes the vertices and primitives of one meshlet (see
41 /// [`crate::StageFacts::Mesh`]); its outputs are the per-vertex varyings of the interface.
42 Mesh,
43 /// A ray generation program: the start of a ray tracing dispatch, one invocation per dispatched ray position.
44 RayGeneration,
45 /// An intersection program: tests a ray against a procedural primitive and reports hits.
46 Intersection,
47 /// An any-hit program: decides whether a candidate hit counts.
48 AnyHit,
49 /// A closest-hit program: runs for the nearest accepted hit of a traced ray.
50 ClosestHit,
51 /// A miss program: runs when a traced ray hits nothing.
52 Miss,
53 /// A callable program: run by another ray tracing program (`CallShader`).
54 Callable,
55}
56impl Stage {
57 /// Whether this is one of the ray tracing pipeline's stages: a program of it is functions that read the ray's
58 /// system values and carry a payload, not an entry point (see `iridia::stage_functions`).
59 pub fn is_ray_tracing(self) -> bool {
60 matches!(
61 self,
62 Self::RayGeneration
63 | Self::Intersection
64 | Self::AnyHit
65 | Self::ClosestHit
66 | Self::Miss
67 | Self::Callable
68 )
69 }
70}