use crate::back::targets::{GLSL, HLSL}; use crate::back::{CompileShader, CompilerBackend, FromCompilation}; use crate::error::ShaderReflectError; use crate::front::shaderc::GlslangCompilation; use crate::reflect::cross::{CompiledProgram, GlslReflect, HlslReflect}; use crate::reflect::ReflectShader; pub type GlVersion = spirv_cross::glsl::Version; pub struct GlslangGlslContext { pub sampler_bindings: Vec<(String, u32)>, pub compiler: CompiledProgram, } impl FromCompilation for GLSL { type Target = GLSL; type Options = GlVersion; type Context = GlslangGlslContext; type Output = impl CompileShader + ReflectShader; fn from_compilation( compile: GlslangCompilation, ) -> Result, ShaderReflectError> { Ok(CompilerBackend { backend: GlslReflect::try_from(compile)?, }) } } pub struct GlslangHlslContext { pub compiler: CompiledProgram, } impl FromCompilation for HLSL { type Target = HLSL; type Options = Option<()>; type Context = GlslangHlslContext; type Output = impl CompileShader + ReflectShader; fn from_compilation( compile: GlslangCompilation, ) -> Result, ShaderReflectError> { Ok(CompilerBackend { backend: HlslReflect::try_from(compile)?, }) } }