qualia_core_db/wgsl_forge/ir/
intrinsics.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub enum SubgroupReduceOp {
6 Add,
7 Mul,
8 Min,
9 Max,
10 And,
11 Or,
12 Xor,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
19pub enum IntrinsicClass {
20 Subgroup,
22 CooperativeMatrix,
24 RayTracing,
26}
27
28#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
29#[serde(rename_all = "snake_case")]
30pub enum Intrinsic {
31 SubgroupReduce {
32 op: SubgroupReduceOp,
33 },
34 SubgroupShuffle {
35 delta: u32,
36 },
37 SubgroupBallot,
38 CoopMatMul {
39 m: u32,
40 n: u32,
41 k: u32,
42 },
43 RayQuery {
46 acceleration_structure: String,
47 origin: String,
48 direction: String,
49 t_min: String,
50 t_max: String,
51 destination: String,
52 },
53}
54
55impl Intrinsic {
56 pub const fn class(&self) -> IntrinsicClass {
57 match self {
58 Self::SubgroupReduce { .. } | Self::SubgroupShuffle { .. } | Self::SubgroupBallot => {
59 IntrinsicClass::Subgroup
60 }
61 Self::CoopMatMul { .. } => IntrinsicClass::CooperativeMatrix,
62 Self::RayQuery { .. } => IntrinsicClass::RayTracing,
63 }
64 }
65}