librashader_reflect/front/
mod.rs1use crate::error::ShaderCompileError;
2use librashader_preprocess::ShaderSource;
3pub(crate) mod spirv_passes;
4
5mod glslang;
6
7pub trait ShaderReflectObject: Sized {
9 type Compiler;
11}
12
13pub use crate::front::glslang::Glslang;
14
15pub trait ShaderInputCompiler<O: ShaderReflectObject>: Sized {
17 fn compile(source: &ShaderSource) -> Result<O, ShaderCompileError>;
19}
20
21impl ShaderReflectObject for SpirvCompilation {
23 type Compiler = Glslang;
24}
25
26#[derive(Debug, Clone)]
28#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
29pub struct SpirvCompilation {
30 pub(crate) vertex: Vec<u32>,
31 pub(crate) fragment: Vec<u32>,
32}
33
34impl TryFrom<&ShaderSource> for SpirvCompilation {
35 type Error = ShaderCompileError;
36
37 fn try_from(source: &ShaderSource) -> Result<Self, Self::Error> {
39 Glslang::compile(source)
40 }
41}