librashader_reflect/front/
mod.rsuse crate::error::ShaderCompileError;
use librashader_preprocess::ShaderSource;
pub(crate) mod spirv_passes;
mod glslang;
pub trait ShaderReflectObject: Sized {
type Compiler;
}
pub use crate::front::glslang::Glslang;
pub trait ShaderInputCompiler<O: ShaderReflectObject>: Sized {
fn compile(source: &ShaderSource) -> Result<O, ShaderCompileError>;
}
impl ShaderReflectObject for SpirvCompilation {
type Compiler = Glslang;
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SpirvCompilation {
pub(crate) vertex: Vec<u32>,
pub(crate) fragment: Vec<u32>,
}
impl TryFrom<&ShaderSource> for SpirvCompilation {
type Error = ShaderCompileError;
fn try_from(source: &ShaderSource) -> Result<Self, Self::Error> {
Glslang::compile(source)
}
}