librashader/librashader-reflect/src/back/glsl.rs

36 lines
1.2 KiB
Rust
Raw Normal View History

use crate::back::targets::GLSL;
2022-11-30 17:38:05 +11:00
use crate::back::{CompileShader, CompilerBackend, FromCompilation};
2022-11-11 17:53:02 +11:00
use crate::error::ShaderReflectError;
use crate::front::SpirvCompilation;
use crate::reflect::cross::{CompiledProgram, SpirvCross};
use crate::reflect::ReflectShader;
/// The GLSL version to target.
pub use spirv_cross::glsl::Version as GlslVersion;
use crate::reflect::cross::glsl::GlslReflect;
2023-02-02 10:58:21 +11:00
/// The context for a GLSL compilation via spirv-cross.
pub struct CrossGlslContext {
/// A map of bindings of sampler names to binding locations.
pub sampler_bindings: Vec<(String, u32)>,
/// The compiled program artifact after compilation.
pub artifact: CompiledProgram<spirv_cross::glsl::Target>,
2022-11-11 18:26:57 +11:00
}
impl FromCompilation<SpirvCompilation, SpirvCross> for GLSL {
type Target = GLSL;
type Options = GlslVersion;
type Context = CrossGlslContext;
2023-01-17 11:35:23 +11:00
type Output = impl CompileShader<Self::Target, Options = GlslVersion, Context = Self::Context>
2022-11-30 17:38:05 +11:00
+ ReflectShader;
fn from_compilation(
compile: SpirvCompilation,
2022-11-30 17:38:05 +11:00
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
Ok(CompilerBackend {
backend: GlslReflect::try_from(&compile)?,
})
}
}