librashader_reflect/back/
targets.rs

1/// Marker trait for shader compiler targets.
2pub trait OutputTarget {
3    /// The output format for the target.
4    type Output;
5}
6
7/// Shader compiler target for GLSL.
8#[derive(Debug)]
9pub struct GLSL;
10/// Shader compiler target for HLSL.
11#[derive(Debug)]
12pub struct HLSL;
13/// Shader compiler target for SPIR-V.
14#[derive(Debug)]
15pub struct SPIRV;
16/// Shader compiler target for MSL.
17#[derive(Debug)]
18pub struct MSL;
19/// Shader compiler target for DXIL.
20///
21/// The resulting DXIL object is always unvalidated and
22/// must be validated using platform APIs before usage.
23#[derive(Debug)]
24pub struct DXIL;
25
26/// Shader compiler target for WGSL.
27///
28/// The resulting WGSL will split sampler2Ds into
29/// split textures and shaders. Shaders for each texture binding
30/// will be in descriptor set 1.
31#[derive(Debug)]
32pub struct WGSL;
33impl OutputTarget for GLSL {
34    type Output = String;
35}
36impl OutputTarget for HLSL {
37    type Output = String;
38}
39impl OutputTarget for WGSL {
40    type Output = String;
41}
42impl OutputTarget for MSL {
43    type Output = String;
44}
45impl OutputTarget for SPIRV {
46    type Output = Vec<u32>;
47}
48
49#[cfg(test)]
50mod test {
51    use crate::back::targets::GLSL;
52    use crate::back::FromCompilation;
53    use crate::front::SpirvCompilation;
54    #[allow(dead_code)]
55    pub fn test_compile(value: SpirvCompilation) {
56        let _x = GLSL::from_compilation(value).unwrap();
57    }
58}