pub mod cross; pub mod targets; use std::fmt::Debug; use crate::back::targets::OutputTarget; use crate::error::{ShaderCompileError, ShaderReflectError}; use crate::reflect::{ReflectShader, ShaderReflection}; use crate::reflect::semantics::ReflectSemantics; #[derive(Debug)] pub struct ShaderCompilerOutput { pub vertex: T, pub fragment: T, pub context: Context, } pub trait CompileShader { type Options; type Context; fn compile( self, options: Self::Options, ) -> Result, ShaderCompileError>; } impl CompileShader for CompilerBackend where T: CompileShader, E: OutputTarget, { type Options = T::Options; type Context = T::Context; fn compile( self, options: Self::Options, ) -> Result, ShaderCompileError> { self.backend.compile(options) } } pub trait FromCompilation { type Target: OutputTarget; type Options; type Context; type Output: CompileShader + ReflectShader; fn from_compilation( compile: T, ) -> Result< CompilerBackend, ShaderReflectError, >; } pub struct CompilerBackend { pub(crate) backend: T, } impl ReflectShader for CompilerBackend where T: ReflectShader, { fn reflect( &mut self, pass_number: usize, semantics: &ReflectSemantics, ) -> Result { self.backend.reflect(pass_number, semantics) } }