2022-11-11 17:44:41 +11:00
|
|
|
use crate::back::targets::{CompilerBackend, FromCompilation, GLSL, HLSL};
|
|
|
|
use crate::back::CompileShader;
|
2022-11-11 17:53:02 +11:00
|
|
|
use crate::error::ShaderReflectError;
|
2022-11-11 17:44:41 +11:00
|
|
|
use crate::front::shaderc::GlslangCompilation;
|
|
|
|
use crate::reflect::cross::{GlslReflect, HlslReflect};
|
2022-11-11 17:53:02 +11:00
|
|
|
use crate::reflect::ReflectShader;
|
2022-11-11 17:44:41 +11:00
|
|
|
|
|
|
|
pub type GlVersion = spirv_cross::glsl::Version;
|
|
|
|
impl FromCompilation<GlslangCompilation> for GLSL {
|
|
|
|
type Target = GLSL;
|
|
|
|
type Options = GlVersion;
|
|
|
|
|
|
|
|
fn from_compilation(
|
|
|
|
compile: GlslangCompilation,
|
|
|
|
) -> Result<
|
|
|
|
CompilerBackend<impl CompileShader<Self::Target, Options = Self::Options> + ReflectShader>,
|
|
|
|
ShaderReflectError,
|
|
|
|
> {
|
|
|
|
Ok(CompilerBackend {
|
|
|
|
backend: GlslReflect::try_from(compile)?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromCompilation<GlslangCompilation> for HLSL {
|
|
|
|
type Target = HLSL;
|
|
|
|
type Options = Option<()>;
|
|
|
|
|
|
|
|
fn from_compilation(
|
|
|
|
compile: GlslangCompilation,
|
|
|
|
) -> Result<
|
|
|
|
CompilerBackend<impl CompileShader<Self::Target, Options = Self::Options> + ReflectShader>,
|
|
|
|
ShaderReflectError,
|
|
|
|
> {
|
|
|
|
Ok(CompilerBackend {
|
|
|
|
backend: HlslReflect::try_from(compile)?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|