librashader_reflect/back/
targets.rs

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
/// Marker trait for shader compiler targets.
pub trait OutputTarget {
    /// The output format for the target.
    type Output;
}

/// Shader compiler target for GLSL.
#[derive(Debug)]
pub struct GLSL;
/// Shader compiler target for HLSL.
#[derive(Debug)]
pub struct HLSL;
/// Shader compiler target for SPIR-V.
#[derive(Debug)]
pub struct SPIRV;
/// Shader compiler target for MSL.
#[derive(Debug)]
pub struct MSL;
/// Shader compiler target for DXIL.
///
/// The resulting DXIL object is always unvalidated and
/// must be validated using platform APIs before usage.
#[derive(Debug)]
pub struct DXIL;

/// Shader compiler target for WGSL.
///
/// The resulting WGSL will split sampler2Ds into
/// split textures and shaders. Shaders for each texture binding
/// will be in descriptor set 1.
#[derive(Debug)]
pub struct WGSL;
impl OutputTarget for GLSL {
    type Output = String;
}
impl OutputTarget for HLSL {
    type Output = String;
}
impl OutputTarget for WGSL {
    type Output = String;
}
impl OutputTarget for MSL {
    type Output = String;
}
impl OutputTarget for SPIRV {
    type Output = Vec<u32>;
}

#[cfg(test)]
mod test {
    use crate::back::targets::GLSL;
    use crate::back::FromCompilation;
    use crate::front::SpirvCompilation;
    #[allow(dead_code)]
    pub fn test_compile(value: SpirvCompilation) {
        let _x = GLSL::from_compilation(value).unwrap();
    }
}