2023-01-18 20:54:57 -05:00
|
|
|
use crate::error::ShaderCompileError;
|
|
|
|
use librashader_preprocess::ShaderSource;
|
|
|
|
|
2024-02-07 22:26:17 -05:00
|
|
|
mod glslang;
|
2023-01-18 20:54:57 -05:00
|
|
|
|
2024-02-07 22:26:17 -05:00
|
|
|
pub use crate::front::glslang::GlslangCompilation;
|
2023-01-19 01:06:17 -05:00
|
|
|
|
|
|
|
/// Trait for types that can compile shader sources into a compilation unit.
|
2023-01-18 20:54:57 -05:00
|
|
|
pub trait ShaderCompilation: Sized {
|
|
|
|
/// Compile the input shader source file into a compilation unit.
|
|
|
|
fn compile(source: &ShaderSource) -> Result<Self, ShaderCompileError>;
|
|
|
|
}
|
2023-01-19 01:06:17 -05:00
|
|
|
|
|
|
|
impl<T: for<'a> TryFrom<&'a ShaderSource, Error = ShaderCompileError>> ShaderCompilation for T {
|
|
|
|
fn compile(source: &ShaderSource) -> Result<Self, ShaderCompileError> {
|
|
|
|
source.try_into()
|
|
|
|
}
|
|
|
|
}
|